This feature helps cinder drivers to access provider
information without resorting to DB access in their driver code.
Closes-Bug: #
1430145
Change-Id: I72bcbdafd1c2ec24fa4c52978c88b8518db2a1ec
'volume_type_id': fields.UUIDField(nullable=True),
'provider_location': fields.StringField(nullable=True),
+ 'provider_id': fields.UUIDField(nullable=True),
'metadata': fields.DictOfStringsField(),
'volume': fields.ObjectField('Volume', nullable=True),
'display_name': fields.StringField(nullable=True),
'display_description': fields.StringField(nullable=True),
+ 'provider_id': fields.UUIDField(nullable=True),
'provider_location': fields.StringField(nullable=True),
'provider_auth': fields.StringField(nullable=True),
'provider_geometry': fields.StringField(nullable=True),
self.assertEqual(fake_snapshot['id'], snapshot.id)
self.assertEqual(fake_snapshot['volume_id'], snapshot.volume_id)
+ @mock.patch('cinder.db.snapshot_create',
+ return_value=dict(provider_id='1111-aaaa', **fake_snapshot))
+ def test_create_with_provider_id(self, snapshot_create):
+ snapshot = snapshot_obj.Snapshot(context=self.context)
+ snapshot.create()
+ self.assertEqual('1111-aaaa', snapshot.provider_id)
+
@mock.patch('cinder.db.snapshot_update')
def test_save(self, snapshot_update):
snapshot = snapshot_obj.Snapshot._from_db_object(
self.assertEqual(volume['volume_type_id'], db_vol_type.get('id'))
self.assertIsNotNone(volume['encryption_key_id'])
+ def test_create_volume_with_provider_id(self):
+ volume_params_with_provider_id = dict(provider_id='1111-aaaa',
+ **self.volume_params)
+
+ volume = tests_utils.create_volume(self.context,
+ **volume_params_with_provider_id)
+
+ self.volume.create_volume(self.context, volume['id'])
+ self.assertEqual('1111-aaaa', volume['provider_id'])
+
def test_create_delete_volume_with_encrypted_volume_type(self):
self.stubs.Set(keymgr, "API", fake_keymgr.fake_api)