self.assertEqual("Missing required element 'restore' in request body.",
res_dict['badRequest']['message'])
- @mock.patch('cinder.volume.API.create')
+ @mock.patch('cinder.volume.api.API.create')
def test_restore_backup_volume_id_unspecified(self,
_mock_volume_api_create):
self.assertEqual(202, res.status_int)
self.assertEqual(backup_id, res_dict['restore']['backup_id'])
- @mock.patch('cinder.volume.API.create')
+ @mock.patch('cinder.volume.api.API.create')
def test_restore_backup_name_specified(self,
_mock_volume_api_create):
self.controller = volume_actions.VolumeActionsController()
self.api_patchers = {}
for _meth in self._methods:
- self.api_patchers[_meth] = mock.patch('cinder.volume.API.' + _meth)
+ self.api_patchers[_meth] = mock.patch('cinder.volume.api.API.' +
+ _meth)
self.api_patchers[_meth].start()
self.addCleanup(self.api_patchers[_meth].stop)
self.api_patchers[_meth].return_value = True
'size': 1, 'migration_status': None,
'volume_type_id': 'fake', 'project_id': 'project_id'}
vol = fake_volume.fake_volume_obj(self.context, **db_vol)
- self.get_patcher = mock.patch('cinder.volume.API.get')
+ self.get_patcher = mock.patch('cinder.volume.api.API.get')
self.mock_volume_get = self.get_patcher.start()
self.addCleanup(self.get_patcher.stop)
self.mock_volume_get.return_value = vol
- self.update_patcher = mock.patch('cinder.volume.API.update')
+ self.update_patcher = mock.patch('cinder.volume.api.API.update')
self.mock_volume_update = self.update_patcher.start()
self.addCleanup(self.update_patcher.stop)
self.mock_volume_update.return_value = vol
def test_begin_detaching(self):
def fake_begin_detaching(*args, **kwargs):
return {}
- self.stubs.Set(volume.API, 'begin_detaching',
+ self.stubs.Set(volume.api.API, 'begin_detaching',
fake_begin_detaching)
body = {'os-begin_detaching': {'fake': 'fake'}}
def test_roll_detaching(self):
def fake_roll_detaching(*args, **kwargs):
return {}
- self.stubs.Set(volume.API, 'roll_detaching',
+ self.stubs.Set(volume.api.API, 'roll_detaching',
fake_roll_detaching)
body = {'os-roll_detaching': {'fake': 'fake'}}
def test_extend_volume(self):
def fake_extend_volume(*args, **kwargs):
return {}
- self.stubs.Set(volume.API, 'extend',
+ self.stubs.Set(volume.api.API, 'extend',
fake_extend_volume)
body = {'os-extend': {'new_size': 5}}
def fake_extend_volume(*args, **kwargs):
msg = "Volume status must be available"
raise exception.InvalidVolume(reason=msg)
- self.stubs.Set(volume.API, 'extend',
+ self.stubs.Set(volume.api.API, 'extend',
fake_extend_volume)
body = {'os-extend': {'new_size': 5}}
def test_update_readonly_flag(self):
def fake_update_readonly_flag(*args, **kwargs):
return {}
- self.stubs.Set(volume.API, 'update_readonly_flag',
+ self.stubs.Set(volume.api.API, 'update_readonly_flag',
fake_update_readonly_flag)
def make_update_readonly_flag_test(self, readonly, return_code):
def setUp(self):
super(VolumeHostAttributeTest, self).setUp()
- self.stubs.Set(volume.API, 'get', fake_volume_api_get)
- self.stubs.Set(volume.API, 'get_all', fake_volume_get_all)
+ self.stubs.Set(volume.api.API, 'get', fake_volume_api_get)
+ self.stubs.Set(volume.api.API, 'get_all', fake_volume_get_all)
self.stubs.Set(db, 'volume_get', fake_db_volume_get)
self.UUID = uuid.uuid4()
def setUp(self):
super(VolumeImageMetadataTest, self).setUp()
- self.stubs.Set(volume.API, 'get', fake_volume_api_get)
- self.stubs.Set(volume.API, 'get_all', fake_volume_get_all)
- self.stubs.Set(volume.API, 'get_volume_image_metadata',
+ self.stubs.Set(volume.api.API, 'get', fake_volume_api_get)
+ self.stubs.Set(volume.api.API, 'get_all', fake_volume_get_all)
+ self.stubs.Set(volume.api.API, 'get_volume_image_metadata',
fake_get_volume_image_metadata)
- self.stubs.Set(volume.API, 'get_volumes_image_metadata',
+ self.stubs.Set(volume.api.API, 'get_volumes_image_metadata',
fake_get_volumes_image_metadata)
self.UUID = uuid.uuid4()
self.controller = (volume_image_metadata.
self._get_image_metadata_list(res.body)[0])
def test_create_image_metadata(self):
- self.stubs.Set(volume.API, 'get_volume_image_metadata',
+ self.stubs.Set(volume.api.API, 'get_volume_image_metadata',
return_empty_image_metadata)
self.stubs.Set(db, 'volume_metadata_update',
fake_create_volume_metadata)
def test_create_with_keys_case_insensitive(self):
# If the keys in uppercase_and_lowercase, should return the one
# which server added
- self.stubs.Set(volume.API, 'get_volume_image_metadata',
+ self.stubs.Set(volume.api.API, 'get_volume_image_metadata',
return_empty_image_metadata)
self.stubs.Set(db, 'volume_metadata_update',
fake_create_volume_metadata)
self.controller.create, req, 1, None)
def test_create_nonexistent_volume(self):
- self.stubs.Set(volume.API, 'get', return_volume_nonexistent)
+ self.stubs.Set(volume.api.API, 'get', return_volume_nonexistent)
req = fakes.HTTPRequest.blank('/v2/fake/volumes/1/action')
req.method = 'POST'
def setUp(self):
super(VolumeMigStatusAttributeTest, self).setUp()
- self.stubs.Set(volume.API, 'get', fake_volume_api_get)
- self.stubs.Set(volume.API, 'get_all', fake_volume_get_all)
+ self.stubs.Set(volume.api.API, 'get', fake_volume_api_get)
+ self.stubs.Set(volume.api.API, 'get_all', fake_volume_get_all)
self.UUID = uuid.uuid4()
def test_get_volume_allowed(self):
def setUp(self):
super(VolumeTenantAttributeTest, self).setUp()
- self.stubs.Set(volume.API, 'get', fake_volume_get)
- self.stubs.Set(volume.API, 'get_all', fake_volume_get_all)
+ self.stubs.Set(volume.api.API, 'get', fake_volume_get)
+ self.stubs.Set(volume.api.API, 'get_all', fake_volume_get_all)
self.UUID = uuid.uuid4()
def test_get_volume_allowed(self):
def setUp(self):
super(SnapshotMetaDataTest, self).setUp()
self.volume_api = cinder.volume.api.API()
- self.stubs.Set(volume.API, 'get', stub_get)
+ self.stubs.Set(volume.api.API, 'get', stub_get)
self.stubs.Set(cinder.db, 'snapshot_get', return_snapshot)
self.stubs.Set(self.volume_api, 'update_snapshot_metadata',
def setUp(self):
super(volumeMetaDataTest, self).setUp()
self.volume_api = cinder.volume.api.API()
- self.stubs.Set(volume.API, 'get', get_volume)
+ self.stubs.Set(volume.api.API, 'get', get_volume)
self.stubs.Set(cinder.db, 'volume_metadata_get',
return_volume_metadata)
self.stubs.Set(cinder.db, 'service_get_all_by_topic',
req, self.req_id, body)
def test_create_nonexistent_volume(self):
- self.stubs.Set(volume.API, 'get', return_volume_nonexistent)
+ self.stubs.Set(volume.api.API, 'get', return_volume_nonexistent)
self.stubs.Set(cinder.db, 'volume_metadata_get',
return_volume_metadata)
self.stubs.Set(cinder.db, 'volume_metadata_update',
def setUp(self):
super(SnapshotMetaDataTest, self).setUp()
self.volume_api = cinder.volume.api.API()
- self.stubs.Set(volume.API, 'get', stub_get)
+ self.stubs.Set(volume.api.API, 'get', stub_get)
self.stubs.Set(cinder.db, 'snapshot_get', return_snapshot)
self.stubs.Set(self.volume_api, 'update_snapshot_metadata',
def setUp(self):
super(volumeMetaDataTest, self).setUp()
self.volume_api = volume_api.API()
- self.stubs.Set(volume.API, 'get', get_volume)
+ self.stubs.Set(volume.api.API, 'get', get_volume)
self.stubs.Set(db, 'volume_metadata_get',
return_volume_metadata)
self.stubs.Set(db, 'service_get_all_by_topic',
req, self.req_id, body)
def test_create_nonexistent_volume(self):
- self.stubs.Set(volume.API, 'get', return_volume_nonexistent)
+ self.stubs.Set(volume.api.API, 'get', return_volume_nonexistent)
self.stubs.Set(db, 'volume_metadata_get',
return_volume_metadata)
self.stubs.Set(db, 'volume_metadata_update',
CONF = config.CONF
-API = importutils.import_class(CONF.volume_api_class)
+
+def API(*args, **kwargs):
+ class_name = CONF.volume_api_class
+ return importutils.import_object(class_name, *args, **kwargs)