def test_create_volume_from_snapshot_copy_job_fails(self): fake_dest_eseries_volume = copy.deepcopy(eseries_fake.VOLUME) self.mock_object(self.library, "_schedule_and_create_volume", mock.Mock(return_value=fake_dest_eseries_volume)) self.mock_object(self.library, "_create_snapshot_volume", mock.Mock(return_value=fake_dest_eseries_volume)) self.mock_object(self.library._client, "delete_snapshot_volume") self.mock_object(self.library._client, "delete_volume") fake_failed_volume_copy_job = copy.deepcopy( eseries_fake.VOLUME_COPY_JOB) fake_failed_volume_copy_job['status'] = 'failed' self.mock_object(self.library._client, "create_volume_copy_job", mock.Mock(return_value=fake_failed_volume_copy_job)) self.mock_object(self.library._client, "list_vol_copy_job", mock.Mock(return_value=fake_failed_volume_copy_job)) self.assertRaises(exception.NetAppDriverException, self.library.create_volume_from_snapshot, get_fake_volume(), fake_snapshot.fake_snapshot_obj(None)) self.assertEqual( 1, self.library._schedule_and_create_volume.call_count) self.assertEqual(1, self.library._create_snapshot_volume.call_count) self.assertEqual( 1, self.library._client.delete_snapshot_volume.call_count) # Ensure the volume we were going to copy to is cleaned up self.library._client.delete_volume.assert_called_once_with( fake_dest_eseries_volume['volumeRef'])
def test_invalid_metadata_items_on_create(self, snapshot_get_by_id): snapshot = {"id": fake.snapshot_id, "expected_attrs": ["metadata"]} ctx = context.RequestContext(fake.user_id, fake.project_id, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) snapshot_get_by_id.return_value = snapshot_obj self.stubs.Set(cinder.db, "snapshot_metadata_update", return_create_snapshot_metadata) req = fakes.HTTPRequest.blank(self.url) req.method = "POST" req.headers["content-type"] = "application/json" # test for long key data = {"metadata": {"a" * 260: "value1"}} req.body = jsonutils.dump_as_bytes(data) self.assertRaises(webob.exc.HTTPRequestEntityTooLarge, self.controller.create, req, fake.snapshot_id, data) # test for long value data = {"metadata": {"key": "v" * 260}} req.body = jsonutils.dump_as_bytes(data) self.assertRaises(webob.exc.HTTPRequestEntityTooLarge, self.controller.create, req, fake.snapshot_id, data) # test for empty key. data = {"metadata": {"": "value1"}} req.body = jsonutils.dump_as_bytes(data) self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create, req, fake.snapshot_id, data)
def test_snapshot_show(self, max_ver, snapshot_get_by_id, volume_get_by_id, snapshot_metadata_get): snapshot = { 'id': UUID, 'volume_id': fake.VOLUME_ID, 'status': fields.SnapshotStatus.AVAILABLE, 'volume_size': 100, 'display_name': 'Default name', 'display_description': 'Default description', 'expected_attrs': ['metadata'], 'group_snapshot_id': None, } ctx = context.RequestContext(fake.PROJECT_ID, fake.USER_ID, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) fake_volume_obj = fake_volume.fake_volume_obj(ctx) snapshot_get_by_id.return_value = snapshot_obj volume_get_by_id.return_value = fake_volume_obj req = fakes.HTTPRequest.blank('/v3/snapshots/%s' % UUID) req.api_version_request = api_version.APIVersionRequest(max_ver) resp_dict = self.controller.show(req, UUID) self.assertIn('snapshot', resp_dict) self.assertEqual(UUID, resp_dict['snapshot']['id']) self.assertIn('updated_at', resp_dict['snapshot']) if max_ver == '3.14': self.assertIn('group_snapshot_id', resp_dict['snapshot']) elif max_ver == '3.13': self.assertNotIn('group_snapshot_id', resp_dict['snapshot'])
def setUp(self): super(VZStorageTestCase, self).setUp() self._remotefsclient = mock.patch.object(remotefs, 'RemoteFsClient').start() get_mount_point = mock.Mock(return_value=self._FAKE_MNT_POINT) self._remotefsclient.get_mount_point = get_mount_point cfg = copy.copy(self._FAKE_VZ_CONFIG) self._vz_driver = vzstorage.VZStorageDriver(configuration=cfg) self._vz_driver._local_volume_dir = mock.Mock( return_value=self._FAKE_MNT_POINT) self._vz_driver._execute = mock.Mock() self._vz_driver.base = self._FAKE_MNT_BASE self.context = context.get_admin_context() vol_type = fake_volume.fake_volume_type_obj(self.context) vol_type.extra_specs = {} _FAKE_VOLUME = {'id': '4f711859-4928-4cb7-801a-a50c37ceaccc', 'size': 1, 'provider_location': self._FAKE_SHARE, 'name': self._FAKE_VOLUME_NAME, 'status': 'available'} self.vol = fake_volume.fake_volume_obj(self.context, volume_type_id=vol_type.id, **_FAKE_VOLUME) self.vol.volume_type = vol_type _FAKE_SNAPSHOT = {'id': self._FAKE_SNAPSHOT_ID, 'status': 'available', 'volume_size': 1} self.snap = fake_snapshot.fake_snapshot_obj(self.context, **_FAKE_SNAPSHOT) self.snap.volume = self.vol
def test_manage_existing_snapshot(self, mock_can_send_version): volume_update = {'host': 'fake_host'} snpshot = { 'id': fake.snapshot_id, 'volume_id': fake.volume_id, 'status': "creating", 'progress': '0%', 'volume_size': 0, 'display_name': 'fake_name', 'display_description': 'fake_description', 'volume': fake_volume.fake_db_volume(**volume_update), 'expected_attrs': ['volume'], } my_fake_snapshot_obj = fake_snapshot.fake_snapshot_obj(self.context, **snpshot) self._test_volume_api('manage_existing_snapshot', rpc_method='cast', snapshot=my_fake_snapshot_obj, ref='foo', host='fake_host', version='2.0') mock_can_send_version.return_value = False self._test_volume_api('manage_existing_snapshot', rpc_method='cast', snapshot=my_fake_snapshot_obj, ref='foo', host='fake_host', version='1.28')
def test_create(self, snapshot_get_by_id, volume_get_by_id, snapshot_update): snapshot = { 'id': self.req_id, 'expected_attrs': ['metadata'] } ctx = context.RequestContext('admin', 'fake', True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) fake_volume_obj = fake_volume.fake_volume_obj(ctx) snapshot_get_by_id.return_value = snapshot_obj volume_get_by_id.return_value = fake_volume_obj self.stubs.Set(cinder.db, 'snapshot_metadata_get', return_empty_snapshot_metadata) self.stubs.Set(cinder.db, 'snapshot_metadata_update', return_create_snapshot_metadata) req = fakes.HTTPRequest.blank('/v2/snapshot_metadata') req.method = 'POST' req.content_type = "application/json" body = {"metadata": {"key1": "value1", "key2": "value2", "key3": "value3"}} req.body = jsonutils.dumps(body) res_dict = self.controller.create(req, self.req_id, body) self.assertEqual(body, res_dict)
def test_delete_snapshot(self, volume_present): updates = { 'name': fake.SNAPSHOT_NAME, 'volume_size': fake.SIZE, 'volume_id': fake.VOLUME_ID, 'volume_name': fake.VOLUME_NAME, 'busy': False, } snapshot = fake_snapshot.fake_snapshot_obj(self.ctxt, **updates) self.mock_object(self.driver, '_get_provider_location', mock.Mock(return_value=fake.SNAPSHOT_MOUNT)) self.mock_object(self.driver, '_volume_not_present', mock.Mock(return_value=volume_present)) self.mock_object(self.driver, '_execute') self.mock_object(self.driver, '_get_volume_path', mock.Mock(return_value='fake')) self.driver._execute_as_root = True retval = self.driver.delete_snapshot(snapshot) if volume_present: self.assertTrue(retval) self.driver._execute.assert_not_called() else: self.assertIsNone(retval) self.driver._execute.assert_called_once_with( 'rm', 'fake', run_as_root=True)
def setUp(self): super(VolumeRpcAPITestCase, self).setUp() self.context = context.get_admin_context() vol = {} vol['host'] = 'fake_host' vol['availability_zone'] = CONF.storage_availability_zone vol['status'] = "available" vol['attach_status'] = "detached" vol['metadata'] = {"test_key": "test_val"} volume = db.volume_create(self.context, vol) snpshot = { 'id': 1, 'volume_id': 'fake_id', 'status': "creating", 'progress': '0%', 'volume_size': 0, 'display_name': 'fake_name', 'display_description': 'fake_description'} snapshot = db.snapshot_create(self.context, snpshot) self.fake_volume = jsonutils.to_primitive(volume) self.fake_volume_metadata = volume["volume_metadata"] self.fake_snapshot = jsonutils.to_primitive(snapshot) self.fake_snapshot_obj = fake_snapshot.fake_snapshot_obj(self.context, **snpshot) self.fake_reservations = ["RESERVATION"]
def setUp(self): super(VolumeRpcAPITestCase, self).setUp() self.context = context.get_admin_context() vol = {} vol["host"] = "fake_host" vol["availability_zone"] = CONF.storage_availability_zone vol["status"] = "available" vol["attach_status"] = "detached" vol["metadata"] = {"test_key": "test_val"} volume = db.volume_create(self.context, vol) snpshot = { "id": 1, "volume_id": "fake_id", "status": "creating", "progress": "0%", "volume_size": 0, "display_name": "fake_name", "display_description": "fake_description", } snapshot = db.snapshot_create(self.context, snpshot) self.fake_volume = jsonutils.to_primitive(volume) self.fake_volume_metadata = volume["volume_metadata"] self.fake_snapshot = jsonutils.to_primitive(snapshot) self.fake_snapshot_obj = fake_snapshot.fake_snapshot_obj(self.context, **snpshot) self.fake_reservations = ["RESERVATION"]
def test_snapshot_detail(self, get_all_snapshots, snapshot_get_by_id, volume_get_by_id, snapshot_metadata_get): snapshot = { 'id': UUID, 'volume_id': fake.volume_id, 'status': 'available', 'volume_size': 100, 'display_name': 'Default name', 'display_description': 'Default description', 'expected_attrs': ['metadata'] } ctx = context.RequestContext(fake.project_id, fake.user_id, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) fake_volume_obj = fake_volume.fake_volume_obj(ctx) snapshot_get_by_id.return_value = snapshot_obj volume_get_by_id.return_value = fake_volume_obj snapshots = objects.SnapshotList(objects=[snapshot_obj]) get_all_snapshots.return_value = snapshots req = fakes.HTTPRequest.blank('/v2/snapshots/detail') resp_dict = self.controller.detail(req) self.assertIn('snapshots', resp_dict) resp_snapshots = resp_dict['snapshots'] self.assertEqual(1, len(resp_snapshots)) self.assertIn('updated_at', resp_snapshots[0]) resp_snapshot = resp_snapshots.pop() self.assertEqual(UUID, resp_snapshot['id'])
def test_snapshot_update_with_null_validate( self, snapshot_get_by_id, volume_get, snapshot_metadata_get, update_snapshot): snapshot = { 'id': UUID, 'volume_id': fake.VOLUME_ID, 'status': fields.SnapshotStatus.AVAILABLE, 'created_at': "2014-01-01 00:00:00", 'volume_size': 100, 'name': 'Default name', 'description': 'Default description', 'expected_attrs': ['metadata'], } ctx = context.RequestContext(fake.PROJECT_ID, fake.USER_ID, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) fake_volume_obj = fake_volume.fake_volume_obj(ctx) snapshot_get_by_id.return_value = snapshot_obj volume_get.return_value = fake_volume_obj updates = { "name": None, "description": None, } body = {"snapshot": updates} req = fakes.HTTPRequest.blank('/v2/snapshots/%s' % UUID) res_dict = self.controller.update(req, UUID, body=body) self.assertEqual(fields.SnapshotStatus.AVAILABLE, res_dict['snapshot']['status']) self.assertIsNone(res_dict['snapshot']['name']) self.assertIsNone(res_dict['snapshot']['description'])
def test_create_with_keys_in_uppercase_and_lowercase( self, snapshot_get_by_id, snapshot_update): snapshot = { 'id': self.req_id, 'expected_attrs': ['metadata'] } ctx = context.RequestContext('admin', 'fake', True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) snapshot_get_by_id.return_value = snapshot_obj # if the keys in uppercase_and_lowercase, should return the one # which server added self.stubs.Set(cinder.db, 'snapshot_metadata_update', return_create_snapshot_metadata_insensitive) req = fakes.HTTPRequest.blank('/v2/snapshot_metadata') req.method = 'POST' req.content_type = "application/json" body = {"metadata": {"key1": "value1", "KEY1": "value1", "key2": "value2", "KEY2": "value2", "key3": "value3", "KEY4": "value4"}} expected = {"metadata": {"key1": "value1", "key2": "value2", "key3": "value3", "KEY4": "value4"}} req.body = jsonutils.dumps(body) res_dict = self.controller.create(req, self.req_id, body) self.assertEqual(expected, res_dict)
def _test_delete_snapshot( self, vops, from_provider_loc, delete_fcd, empty_provider_loc=False, use_fcd_snapshot=False): volume = self._create_volume_obj() snapshot = fake_snapshot.fake_snapshot_obj( self._context, volume=volume) if empty_provider_loc: snapshot.provider_location = None else: snapshot.provider_location = "test" if use_fcd_snapshot: fcd_snap_loc = mock.sentinel.fcd_snap_loc from_provider_loc.return_value = fcd_snap_loc else: from_provider_loc.return_value = None self._driver.delete_snapshot(snapshot) if empty_provider_loc: delete_fcd.assert_not_called() vops.delete_fcd_snapshot.assert_not_called() elif use_fcd_snapshot: vops.delete_fcd_snapshot.assert_called_once_with(fcd_snap_loc) else: delete_fcd.assert_called_once_with(snapshot.provider_location)
def _test_create_volume_from_snapshot( self, extend_if_needed, vops, get_storage_profile_id, from_provider_loc, create_volume_from_fcd, use_fcd_snapshot=False): src_volume = self._create_volume_obj(vol_id=self.SRC_VOL_ID) snapshot = fake_snapshot.fake_snapshot_obj( self._context, volume=src_volume) volume = self._create_volume_obj(size=self.VOL_SIZE + 1) if use_fcd_snapshot: fcd_snap_loc = mock.sentinel.fcd_snap_loc from_provider_loc.return_value = fcd_snap_loc profile_id = mock.sentinel.profile_id get_storage_profile_id.return_value = profile_id fcd_loc = mock.Mock() provider_loc = mock.sentinel.provider_loc fcd_loc.provider_location.return_value = provider_loc vops.create_fcd_from_snapshot.return_value = fcd_loc else: from_provider_loc.return_value = None ret = self._driver.create_volume_from_snapshot(volume, snapshot) if use_fcd_snapshot: self.assertEqual({'provider_location': provider_loc}, ret) vops.create_fcd_from_snapshot.assert_called_once_with( fcd_snap_loc, volume.name, profile_id=profile_id) extend_if_needed.assert_called_once_with( fcd_loc, snapshot.volume_size, volume.size) else: create_volume_from_fcd.assert_called_once_with( snapshot.provider_location, snapshot.volume.size, volume)
def _test_create_snapshot( self, from_provider_loc, vops, clone_fcd, select_ds_fcd, use_fcd_snapshot=False): self._driver._use_fcd_snapshot = use_fcd_snapshot provider_location = mock.sentinel.provider_location if use_fcd_snapshot: fcd_loc = mock.sentinel.fcd_loc from_provider_loc.return_value = fcd_loc fcd_snap_loc = mock.Mock() fcd_snap_loc.provider_location.return_value = provider_location vops.create_fcd_snapshot.return_value = fcd_snap_loc else: ds_ref = mock.sentinel.ds_ref select_ds_fcd.return_value = ds_ref dest_fcd_loc = mock.Mock() dest_fcd_loc.provider_location.return_value = provider_location clone_fcd.return_value = dest_fcd_loc volume = self._create_volume_obj() snapshot = fake_snapshot.fake_snapshot_obj( self._context, volume=volume) ret = self._driver.create_snapshot(snapshot) self.assertEqual({'provider_location': provider_location}, ret) if use_fcd_snapshot: vops.create_fcd_snapshot.assert_called_once_with( fcd_loc, description="snapshot-%s" % snapshot.id) else: select_ds_fcd.assert_called_once_with(snapshot.volume) clone_fcd.assert_called_once_with( volume.provider_location, snapshot.name, ds_ref)
def test_delete_snapshot(self): snapshot = fake_snapshot.fake_snapshot_obj(context.get_admin_context()) self._driver.delete_snapshot(snapshot) self._driver._tgt_utils.delete_snapshot.assert_called_once_with( snapshot.name)
def instantiate_snapshot(snap): snap = snap.copy() snap['volume'] = fake_volume.fake_volume_obj( None, **snap['volume']) snapshot = fake_snapshot.fake_snapshot_obj( None, expected_attrs=['volume'], **snap) return snapshot
def test_cg_operations(self, get_all_for_cgsnapshot, req): req.side_effect = xms_request d = self.data snapshot_obj = fake_snapshot.fake_snapshot_obj(d.context) snapshot_obj.consistencygroup_id = d.group['id'] get_all_for_cgsnapshot.return_value = [snapshot_obj] self.driver.create_consistencygroup(d.context, d.group) self.assertEqual(1, len(xms_data['consistency-groups'])) self.driver.update_consistencygroup(d.context, d.group, add_volumes=[d.test_volume, d.test_volume2]) self.assertEqual(2, len(xms_data['consistency-group-volumes'])) self.driver.update_consistencygroup(d.context, d.group, remove_volumes=[d.test_volume2]) self.assertEqual(1, len(xms_data['consistency-group-volumes'])) self.driver.db = mock.Mock() (self.driver.db. volume_get_all_by_group.return_value) = [mock.MagicMock()] self.driver.create_cgsnapshot(d.context, d.cgsnapshot) snaps_name = self.driver._get_cgsnap_name(d.cgsnapshot) snaps = xms_data['volumes'][1] snaps['index'] = 1 xms_data['snapshot-sets'] = {snaps_name: snaps, 1: snaps} self.assertRaises(exception.InvalidInput, self.driver.create_consistencygroup_from_src, d.context, d.group, []) self.driver.delete_cgsnapshot(d.context, d.cgsnapshot) self.driver.delete_consistencygroup(d.context, d.group)
def test_snapshot_update(self, snapshot_get_by_id, volume_get_by_id, snapshot_metadata_get, update_snapshot): snapshot = { "id": UUID, "volume_id": fake.VOLUME_ID, "status": fields.SnapshotStatus.AVAILABLE, "volume_size": 100, "display_name": "Default name", "display_description": "Default description", "expected_attrs": ["metadata"], } ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) fake_volume_obj = fake_volume.fake_volume_obj(ctx) snapshot_get_by_id.return_value = snapshot_obj volume_get_by_id.return_value = fake_volume_obj updates = {"display_name": "Updated Test Name"} body = {"snapshot": updates} req = fakes.HTTPRequest.blank("/v1/snapshots/%s" % UUID) res_dict = self.controller.update(req, UUID, body) expected = { "snapshot": { "id": UUID, "volume_id": fake.VOLUME_ID, "status": fields.SnapshotStatus.AVAILABLE, "size": 100, "created_at": None, "display_name": u"Updated Test Name", "display_description": u"Default description", "metadata": {}, } } self.assertEqual(expected, res_dict)
def test_update_all_with_keys_in_uppercase_and_lowercase( self, snapshot_get_by_id, snapshot_update): snapshot = { 'id': self.req_id, 'expected_attrs': ['metadata'] } ctx = context.RequestContext('admin', 'fake', True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) snapshot_get_by_id.return_value = snapshot_obj self.stubs.Set(cinder.db, 'snapshot_metadata_update', return_new_snapshot_metadata) req = fakes.HTTPRequest.blank(self.url) req.method = 'PUT' req.content_type = "application/json" body = { 'metadata': { 'key10': 'value10', 'KEY10': 'value10', 'key99': 'value99', 'KEY20': 'value20', }, } expected = { 'metadata': { 'key10': 'value10', 'key99': 'value99', 'KEY20': 'value20', }, } req.body = jsonutils.dumps(expected) res_dict = self.controller.update_all(req, self.req_id, body) self.assertEqual(expected, res_dict)
def test_cg_from_src_snapshot(self, get_all_for_cgsnapshot, req): req.side_effect = xms_request d = self.data snapshot_obj = fake_snapshot.fake_snapshot_obj(d.context) snapshot_obj.consistencygroup_id = d.group['id'] snapshot_obj.volume_id = d.test_volume['id'] get_all_for_cgsnapshot.return_value = [snapshot_obj] self.driver.create_consistencygroup(d.context, d.group) self.driver.create_volume(d.test_volume) self.driver.create_cgsnapshot(d.context, d.cgsnapshot, []) xms_data['volumes'][2]['ancestor-vol-id'] = (xms_data['volumes'][1] ['vol-id']) snapset_name = self.driver._get_cgsnap_name(d.cgsnapshot) snapset1 = {'vol-list': [xms_data['volumes'][2]['vol-id']], 'name': snapset_name, 'index': 1} xms_data['snapshot-sets'] = {snapset_name: snapset1, 1: snapset1} cg_obj = fake_cg.fake_consistencyobject_obj(d.context) new_vol1 = fake_volume.fake_volume_obj(d.context) snapshot1 = (fake_snapshot .fake_snapshot_obj (d.context, volume_id=d.test_volume['id'])) self.driver.create_consistencygroup_from_src(d.context, cg_obj, [new_vol1], d.cgsnapshot, [snapshot1])
def test_snapshot_update(self, snapshot_get_by_id, volume_get_by_id, snapshot_metadata_get, update_snapshot): snapshot = { 'id': UUID, 'volume_id': fake.volume_id, 'status': 'available', 'volume_size': 100, 'display_name': 'Default name', 'display_description': 'Default description', 'expected_attrs': ['metadata'], } ctx = context.RequestContext(fake.user_id, fake.project_id, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) fake_volume_obj = fake_volume.fake_volume_obj(ctx) snapshot_get_by_id.return_value = snapshot_obj volume_get_by_id.return_value = fake_volume_obj updates = {"display_name": "Updated Test Name", } body = {"snapshot": updates} req = fakes.HTTPRequest.blank('/v1/snapshots/%s' % UUID) res_dict = self.controller.update(req, UUID, body) expected = {'snapshot': { 'id': UUID, 'volume_id': fake.volume_id, 'status': u'available', 'size': 100, 'created_at': None, 'display_name': u'Updated Test Name', 'display_description': u'Default description', 'metadata': {}, }} self.assertEqual(expected, res_dict)
def test_cg_operations(self, get_all_for_cgsnapshot, req): req.side_effect = xms_request d = self.data snapshot_obj = fake_snapshot.fake_snapshot_obj(d.context) snapshot_obj.consistencygroup_id = d.group["id"] get_all_for_cgsnapshot.return_value = [snapshot_obj] self.driver.create_consistencygroup(d.context, d.group) self.assertEqual(1, len(xms_data["consistency-groups"])) self.driver.update_consistencygroup(d.context, d.group, add_volumes=[d.test_volume, d.test_volume2]) self.assertEqual(2, len(xms_data["consistency-group-volumes"])) self.driver.update_consistencygroup(d.context, d.group, remove_volumes=[d.test_volume2]) self.assertEqual(1, len(xms_data["consistency-group-volumes"])) self.driver.db = mock.Mock() (self.driver.db.volume_get_all_by_group.return_value) = [mock.MagicMock()] self.driver.create_cgsnapshot(d.context, d.cgsnapshot, []) snapset_name = self.driver._get_cgsnap_name(d.cgsnapshot) self.assertEqual(snapset_name, "192eb39b6c2f420cbae33cfd117f0345192eb39b6c2f420cbae" "33cfd117f9876") snapset1 = { "ancestor-vol-id": ["", d.test_volume["id"], 2], "consistencygroup_id": d.group["id"], "name": snapset_name, "index": 1, } xms_data["snapshot-sets"] = {snapset_name: snapset1, 1: snapset1} self.driver.delete_cgsnapshot(d.context, d.cgsnapshot, []) self.driver.delete_consistencygroup(d.context, d.group, []) xms_data["snapshot-sets"] = {}
def test_snapshot_detail(self, get_all_snapshots, snapshot_get_by_id, volume_get_by_id, snapshot_metadata_get): snapshot = { "id": UUID, "volume_id": 1, "status": "available", "volume_size": 100, "display_name": "Default name", "display_description": "Default description", "expected_attrs": ["metadata"], } ctx = context.RequestContext("admin", "fake", True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) fake_volume_obj = fake_volume.fake_volume_obj(ctx) snapshot_get_by_id.return_value = snapshot_obj volume_get_by_id.return_value = fake_volume_obj snapshots = objects.SnapshotList(objects=[snapshot_obj]) get_all_snapshots.return_value = snapshots req = fakes.HTTPRequest.blank("/v2/snapshots/detail") resp_dict = self.controller.detail(req) self.assertIn("snapshots", resp_dict) resp_snapshots = resp_dict["snapshots"] self.assertEqual(1, len(resp_snapshots)) resp_snapshot = resp_snapshots.pop() self.assertEqual(UUID, resp_snapshot["id"])
def setUp(self): super(BackupDeviceInfoTestCase, self).setUp() self.vol_obj = fake_volume.fake_volume_obj(self.context, **vol_props) self.snap_obj = fake_snapshot.fake_snapshot_obj(self.context, **snap_props) self.backup_device_dict = {'secure_enabled': False, 'is_snapshot': False, }
def test_update_all(self, snapshot_get_by_id, snapshot_update): snapshot = { 'id': fake.SNAPSHOT_ID, 'expected_attrs': [] } ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) snapshot_get_by_id.return_value = snapshot_obj self.stubs.Set(cinder.db, 'snapshot_metadata_update', return_new_snapshot_metadata) req = fakes.HTTPRequest.blank(self.url) req.method = 'PUT' req.content_type = "application/json" expected = { 'metadata': { 'key10': 'value10', 'key99': 'value99', 'KEY20': 'value20', }, } req.body = jsonutils.dump_as_bytes(expected) res_dict = self.controller.update_all(req, fake.SNAPSHOT_ID, expected) self.assertEqual(expected, res_dict)
def test_create_volume_from_snapshot(self): drv = self._driver src_volume = self._simple_volume() snap_ref = fake_snapshot.fake_snapshot_obj( self.context, volume_name=src_volume.name, display_name='clone-snap-%s' % src_volume.id, volume_size=src_volume.size, volume_id=src_volume.id, id=self.SNAP_UUID, status='available') snap_ref.volume = src_volume new_volume = self._simple_volume(size=snap_ref.volume_size) drv._ensure_shares_mounted = mock.Mock() drv._find_share = mock.Mock(return_value=self.TEST_QUOBYTE_VOLUME) drv._do_create_volume = mock.Mock() drv._copy_volume_from_snapshot = mock.Mock() drv.create_volume_from_snapshot(new_volume, snap_ref) drv._ensure_shares_mounted.assert_called_once_with() drv._find_share.assert_called_once_with(new_volume['size']) drv._do_create_volume.assert_called_once_with(new_volume) (drv._copy_volume_from_snapshot. assert_called_once_with(snap_ref, new_volume, new_volume['size']))
def test_cg_operations(self, get_all_for_cgsnapshot, req): req.side_effect = xms_request d = self.data snapshot_obj = fake_snapshot.fake_snapshot_obj(d.context) snapshot_obj.consistencygroup_id = d.group['id'] get_all_for_cgsnapshot.return_value = [snapshot_obj] self.driver.create_consistencygroup(d.context, d.group) self.assertEqual(1, len(xms_data['consistency-groups'])) self.driver.update_consistencygroup(d.context, d.group, add_volumes=[d.test_volume, d.test_volume2]) self.assertEqual(2, len(xms_data['consistency-group-volumes'])) self.driver.update_consistencygroup(d.context, d.group, remove_volumes=[d.test_volume2]) self.assertEqual(1, len(xms_data['consistency-group-volumes'])) self.driver.db = mock.Mock() (self.driver.db. volume_get_all_by_group.return_value) = [mock.MagicMock()] self.driver.create_cgsnapshot(d.context, d.cgsnapshot, []) snapset_name = self.driver._get_cgsnap_name(d.cgsnapshot) self.assertEqual(snapset_name, '192eb39b6c2f420cbae33cfd117f0345192eb39b6c2f420cbae' '33cfd117f9876') snapset1 = {'ancestor-vol-id': ['', d.test_volume['id'], 2], 'consistencygroup_id': d.group['id'], 'name': snapset_name, 'index': 1} xms_data['snapshot-sets'] = {snapset_name: snapset1, 1: snapset1} self.driver.delete_cgsnapshot(d.context, d.cgsnapshot, []) self.driver.delete_consistencygroup(d.context, d.group, []) xms_data['snapshot-sets'] = {}
def setUp(self): """Setup a test case environment. Creates fake volume and snapshot objects and sets up the required API responses. """ super(TestCreateSnapShot, self).setUp() ctx = context.RequestContext("fake", "fake", auth_token=True) self.snapshot = fake_snapshot.fake_snapshot_obj(ctx) self.volume_name_2x_enc = urllib.quote(urllib.quote(self.driver.id_to_base64(self.snapshot.volume_id))) self.snapshot_name_2x_enc = urllib.quote(urllib.quote(self.driver.id_to_base64(self.snapshot.id))) self.HTTPS_MOCK_RESPONSES = { self.RESPONSE_MODE.Valid: { "types/Volume/instances/getByName::" + self.volume_name_2x_enc: '"{}"'.format(self.snapshot.volume_id), "instances/System/action/snapshotVolumes": self.snapshot.id, "types/Volume/instances/getByName::" + self.snapshot_name_2x_enc: self.snapshot.id, }, self.RESPONSE_MODE.BadStatus: { "types/Volume/instances/getByName::" + self.volume_name_2x_enc: self.BAD_STATUS_RESPONSE, "types/Volume/instances/getByName::" + self.snapshot_name_2x_enc: mocks.MockHTTPSResponse( {"errorCode": 401, "message": "BadStatus Snapshot Test"}, 401 ), }, self.RESPONSE_MODE.Invalid: { "types/Volume/instances/getByName::" + self.volume_name_2x_enc: None, "instances/System/action/snapshotVolumes": mocks.MockHTTPSResponse( {"errorCode": 400, "message": "Invalid Volume Snapshot Test"}, 400 ), }, }
def test_invalid_metadata_items_on_create(self, snapshot_get_by_id): snapshot = { 'id': self.req_id, 'expected_attrs': ['metadata'] } ctx = context.RequestContext('admin', 'fake', True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) snapshot_get_by_id.return_value = snapshot_obj self.stubs.Set(cinder.db, 'snapshot_metadata_update', return_create_snapshot_metadata) req = fakes.HTTPRequest.blank(self.url) req.method = 'POST' req.headers["content-type"] = "application/json" # test for long key data = {"metadata": {"a" * 260: "value1"}} req.body = jsonutils.dumps(data) self.assertRaises(webob.exc.HTTPRequestEntityTooLarge, self.controller.create, req, self.req_id, data) # test for long value data = {"metadata": {"key": "v" * 260}} req.body = jsonutils.dumps(data) self.assertRaises(webob.exc.HTTPRequestEntityTooLarge, self.controller.create, req, self.req_id, data) # test for empty key. data = {"metadata": {"": "value1"}} req.body = jsonutils.dumps(data) self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create, req, self.req_id, data)
def test_invalid_metadata_items_on_create(self, data, snapshot_get_by_id): snapshot = { 'id': self.req_id, 'expected_attrs': ['metadata'] } ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) snapshot_get_by_id.return_value = snapshot_obj self.mock_object(cinder.db, 'snapshot_metadata_update', return_create_snapshot_metadata) req = fakes.HTTPRequest.blank(self.url) req.method = 'POST' req.headers["content-type"] = "application/json" exc = webob.exc.HTTPBadRequest if (len(list(data['metadata'].keys())[0]) > 255 or (list(data['metadata'].values())[0] is not None and len(list(data['metadata'].values())[0]) > 255)): exc = webob.exc.HTTPRequestEntityTooLarge req.body = jsonutils.dump_as_bytes(data) self.assertRaises(exc, self.controller.create, req, self.req_id, data)
def test_cg_snapshot(self, get_all_for_cgsnapshot, req): req.side_effect = xms_request d = self.data snapshot_obj = fake_snapshot.fake_snapshot_obj(d.context) snapshot_obj.consistencygroup_id = d.group['id'] get_all_for_cgsnapshot.return_value = [snapshot_obj] self.driver.create_consistencygroup(d.context, d.group) self.driver.update_consistencygroup( d.context, d.group, add_volumes=[d.test_volume, d.test_volume2]) snapset_name = self.driver._get_cgsnap_name(d.cgsnapshot) self.assertEqual( snapset_name, '192eb39b6c2f420cbae33cfd117f0345192eb39b6c2f420cbae' '33cfd117f9876') snapset1 = { 'ancestor-vol-id': ['', d.test_volume['id'], 2], 'consistencygroup_id': d.group['id'], 'name': snapset_name, 'index': 1 } xms_data['snapshot-sets'] = {snapset_name: snapset1, 1: snapset1} res = self.driver.delete_cgsnapshot(d.context, d.cgsnapshot, [snapshot_obj]) self.assertEqual((None, None), res)
def test_create_volume_from_snapshot_create_fails(self): fake_dest_eseries_volume = copy.deepcopy(eseries_fake.VOLUME) self.mock_object(self.library, "_schedule_and_create_volume", mock.Mock(return_value=fake_dest_eseries_volume)) self.mock_object(self.library, "_create_snapshot_volume", mock.Mock(side_effect=exception.NetAppDriverException) ) self.mock_object(self.library._client, "delete_snapshot_volume") self.mock_object(self.library._client, "delete_volume") self.assertRaises(exception.NetAppDriverException, self.library.create_volume_from_snapshot, get_fake_volume(), fake_snapshot.fake_snapshot_obj(None)) self.assertEqual( 1, self.library._schedule_and_create_volume.call_count) self.assertEqual(1, self.library._create_snapshot_volume.call_count) self.assertEqual( 0, self.library._client.delete_snapshot_volume.call_count) # Ensure the volume we were going to copy to is cleaned up self.library._client.delete_volume.assert_called_once_with( fake_dest_eseries_volume['volumeRef'])
def test_index(self, snapshot_get_by_id): snapshot = { 'id': self.req_id, 'expected_attrs': ['metadata'] } ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) snapshot_obj['metadata'] = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3'} snapshot_get_by_id.return_value = snapshot_obj req = fakes.HTTPRequest.blank(self.url) res_dict = self.controller.index(req, self.req_id) expected = { 'metadata': { 'key1': 'value1', 'key2': 'value2', 'key3': 'value3', }, } self.assertEqual(expected, res_dict)
def setUp(self): super(VZStorageTestCase, self).setUp() self._remotefsclient = mock.patch.object( remotefs, 'VZStorageRemoteFSClient').start() get_mount_point = mock.Mock(return_value=self._FAKE_MNT_POINT) self._remotefsclient.get_mount_point = get_mount_point cfg = copy.copy(self._FAKE_VZ_CONFIG) self._vz_driver = vzstorage.VZStorageDriver(configuration=cfg) self._vz_driver._local_volume_dir = mock.Mock( return_value=self._FAKE_MNT_POINT) self._vz_driver._execute = mock.Mock() self._vz_driver.base = self._FAKE_MNT_BASE self.context = context.get_admin_context() vol_type = fake_volume.fake_volume_type_obj(self.context) vol_type.extra_specs = {} _FAKE_VOLUME = { 'id': '4f711859-4928-4cb7-801a-a50c37ceaccc', 'size': 1, 'provider_location': self._FAKE_SHARE, 'name': self._FAKE_VOLUME_NAME, 'status': 'available' } self.vol = fake_volume.fake_volume_obj(self.context, volume_type_id=vol_type.id, **_FAKE_VOLUME) self.vol.volume_type = vol_type _FAKE_SNAPSHOT = { 'id': self._FAKE_SNAPSHOT_ID, 'status': 'available', 'volume_size': 1 } self.snap = fake_snapshot.fake_snapshot_obj(self.context, **_FAKE_SNAPSHOT) self.snap.volume = self.vol
def _test_create_volume_from_snapshot(self, extend_if_needed, vops, get_storage_profile_id, from_provider_loc, create_volume_from_fcd, use_fcd_snapshot=False): src_volume = self._create_volume_obj(vol_id=self.SRC_VOL_ID) snapshot = fake_snapshot.fake_snapshot_obj(self._context, volume=src_volume) volume = self._create_volume_obj(size=self.VOL_SIZE + 1) if use_fcd_snapshot: fcd_snap_loc = mock.sentinel.fcd_snap_loc from_provider_loc.return_value = fcd_snap_loc profile_id = mock.sentinel.profile_id get_storage_profile_id.return_value = profile_id fcd_loc = mock.Mock() provider_loc = mock.sentinel.provider_loc fcd_loc.provider_location.return_value = provider_loc vops.create_fcd_from_snapshot.return_value = fcd_loc else: from_provider_loc.return_value = None ret = self._driver.create_volume_from_snapshot(volume, snapshot) if use_fcd_snapshot: self.assertEqual({'provider_location': provider_loc}, ret) vops.create_fcd_from_snapshot.assert_called_once_with( fcd_snap_loc, volume.name, profile_id=profile_id) extend_if_needed.assert_called_once_with(fcd_loc, snapshot.volume_size, volume.size) else: create_volume_from_fcd.assert_called_once_with( snapshot.provider_location, snapshot.volume.size, volume)
def test_snapshot_update(self, mock_validate, snapshot_get_by_id, volume_get_by_id, snapshot_metadata_get, update_snapshot): snapshot = { 'id': UUID, 'volume_id': fake.VOLUME_ID, 'status': fields.SnapshotStatus.AVAILABLE, 'volume_size': 100, 'display_name': 'Default name', 'display_description': 'Default description', 'expected_attrs': ['metadata'], } ctx = context.RequestContext(fake.PROJECT_ID, fake.USER_ID, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) fake_volume_obj = fake_volume.fake_volume_obj(ctx) snapshot_get_by_id.return_value = snapshot_obj volume_get_by_id.return_value = fake_volume_obj updates = { "display_name": "Updated Test Name", } body = {"snapshot": updates} req = fakes.HTTPRequest.blank('/v1/snapshots/%s' % UUID) res_dict = self.controller.update(req, UUID, body) expected = { 'snapshot': { 'id': UUID, 'volume_id': fake.VOLUME_ID, 'status': fields.SnapshotStatus.AVAILABLE, 'size': 100, 'created_at': None, 'display_name': u'Updated Test Name', 'display_description': u'Default description', 'metadata': {}, } } self.assertEqual(expected, res_dict)
def test_snapshot_update(self, snapshot_get_by_id, volume_get_by_id, snapshot_metadata_get, update_snapshot): snapshot = { 'id': UUID, 'volume_id': 1, 'status': 'available', 'volume_size': 100, 'display_name': 'Default name', 'display_description': 'Default description', 'expected_attrs': ['metadata'], } ctx = context.RequestContext('admin', 'fake', True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) fake_volume_obj = fake_volume.fake_volume_obj(ctx) snapshot_get_by_id.return_value = snapshot_obj volume_get_by_id.return_value = fake_volume_obj updates = { "name": "Updated Test Name", } body = {"snapshot": updates} req = fakes.HTTPRequest.blank('/v2/snapshots/%s' % UUID) res_dict = self.controller.update(req, UUID, body) expected = { 'snapshot': { 'id': UUID, 'volume_id': '1', 'status': u'available', 'size': 100, 'created_at': None, 'name': u'Updated Test Name', 'description': u'Default description', 'metadata': {}, } } self.assertEqual(expected, res_dict) self.assertEqual(2, len(self.notifier.notifications))
def _test_create_snapshot(self, from_provider_loc, vops, clone_fcd, select_ds_fcd, use_fcd_snapshot=False): self._driver._use_fcd_snapshot = use_fcd_snapshot provider_location = mock.sentinel.provider_location if use_fcd_snapshot: fcd_loc = mock.sentinel.fcd_loc from_provider_loc.return_value = fcd_loc fcd_snap_loc = mock.Mock() fcd_snap_loc.provider_location.return_value = provider_location vops.create_fcd_snapshot.return_value = fcd_snap_loc else: ds_ref = mock.sentinel.ds_ref select_ds_fcd.return_value = ds_ref dest_fcd_loc = mock.Mock() dest_fcd_loc.provider_location.return_value = provider_location clone_fcd.return_value = dest_fcd_loc volume = self._create_volume_obj() snapshot = fake_snapshot.fake_snapshot_obj(self._context, volume=volume) ret = self._driver.create_snapshot(snapshot) self.assertEqual({'provider_location': provider_location}, ret) if use_fcd_snapshot: vops.create_fcd_snapshot.assert_called_once_with( fcd_loc, description="snapshot-%s" % snapshot.id) else: select_ds_fcd.assert_called_once_with(snapshot.volume) clone_fcd.assert_called_once_with(volume.provider_location, snapshot.name, ds_ref)
def setUp(self): super(SmbFsTestCase, self).setUp() self._FAKE_SMBFS_CONFIG = mock.MagicMock( smbfs_oversub_ratio=2, smbfs_used_ratio=0.5, smbfs_shares_config='/fake/config/path', smbfs_default_volume_format='raw', smbfs_sparsed_volumes=False) self._smbfs_driver = smbfs.SmbfsDriver(configuration=mock.Mock()) self._smbfs_driver._remotefsclient = mock.Mock() self._smbfs_driver._local_volume_dir = mock.Mock( return_value=self._FAKE_MNT_POINT) self._smbfs_driver._execute = mock.Mock() self._smbfs_driver.base = self._FAKE_MNT_BASE self._smbfs_driver._alloc_info_file_path = ( self._FAKE_ALLOCATION_DATA_PATH) self.context = context.get_admin_context() self.volume = fake_volume.fake_volume_obj( self.context, id='4f711859-4928-4cb7-801a-a50c37ceaccc', size=self._FAKE_VOLUME_SIZE, provider_location=self._FAKE_SHARE, display_name=self._FAKE_VOLUME_NAME, status='available') self.snapshot = fake_snapshot.fake_snapshot_obj( self.context, id=self._FAKE_SNAPSHOT_ID, status='available', volume_size=1) self.snapshot.volume = self.volume self.addCleanup(mock.patch.stopall)
def test_create(self, snapshot_get_by_id, volume_get_by_id, snapshot_update): snapshot = { 'id': self.req_id, 'expected_attrs': ['metadata'] } ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) fake_volume_obj = fake_volume.fake_volume_obj(ctx) snapshot_get_by_id.return_value = snapshot_obj volume_get_by_id.return_value = fake_volume_obj self.mock_object(cinder.db, 'snapshot_metadata_update', return_create_snapshot_metadata) req = fakes.HTTPRequest.blank('/v2/snapshot_metadata') req.method = 'POST' req.content_type = "application/json" body = {"metadata": {"key1": "value1", "key2": "value2", "key3": "value3"}} req.body = jsonutils.dump_as_bytes(body) res_dict = self.controller.create(req, self.req_id, body) self.assertEqual(body, res_dict)
def test_create_with_keys_in_uppercase_and_lowercase( self, snapshot_get_by_id, snapshot_update): snapshot = {'id': fake.snapshot_id, 'expected_attrs': ['metadata']} ctx = context.RequestContext(fake.user_id, fake.project_id, True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) snapshot_get_by_id.return_value = snapshot_obj # if the keys in uppercase_and_lowercase, should return the one # which server added self.stubs.Set(cinder.db, 'snapshot_metadata_update', return_create_snapshot_metadata_insensitive) req = fakes.HTTPRequest.blank('/v1/snapshot_metadata') req.method = 'POST' req.content_type = "application/json" body = { "metadata": { "key1": "value1", "KEY1": "value1", "key2": "value2", "KEY2": "value2", "key3": "value3", "KEY4": "value4" } } expected = { "metadata": { "key1": "value1", "key2": "value2", "key3": "value3", "KEY4": "value4" } } req.body = jsonutils.dump_as_bytes(body) res_dict = self.controller.create(req, fake.snapshot_id, body) self.assertEqual(expected, res_dict)
def setUp(self): """Setup a test case environment. Creates fake volume and snapshot objects and sets up the required API responses. """ super(TestCreateVolumeFromSnapShot, self).setUp() ctx = context.RequestContext('fake', 'fake', auth_token=True) self.snapshot = fake_snapshot.fake_snapshot_obj(ctx) self.snapshot_name_2x_enc = urllib.quote( urllib.quote(self.driver.id_to_base64(self.snapshot.id))) self.volume = fake_volume.fake_volume_obj(ctx) self.volume_name_2x_enc = urllib.quote( urllib.quote(self.driver.id_to_base64(self.volume.id))) self.HTTPS_MOCK_RESPONSES = { self.RESPONSE_MODE.Valid: { 'types/Volume/instances/getByName::' + self.snapshot_name_2x_enc: self.snapshot.id, 'instances/System/action/snapshotVolumes': self.volume.id, }, self.RESPONSE_MODE.BadStatus: { 'instances/System/action/snapshotVolumes::': self.BAD_STATUS_RESPONSE, 'types/Volume/instances/getByName::' + self.snapshot_name_2x_enc: self.BAD_STATUS_RESPONSE, self.snapshot_name_2x_enc: self.BAD_STATUS_RESPONSE, }, self.RESPONSE_MODE.Invalid: { 'types/Volume/instances/getByName::' + self.snapshot_name_2x_enc: None, }, }
def test_show(self, mock_authorize, snapshot_get_by_id, volume_get_by_id, snapshot_metadata_get): ctx = context.RequestContext(fake.USER_ID, fake.PROJECT_ID, auth_token=True) snapshot = _get_default_snapshot_param() snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) fake_volume_obj = fake_volume.fake_volume_obj(ctx) mock_authorize.return_value = True snapshot_get_by_id.return_value = snapshot_obj volume_get_by_id.return_value = fake_volume_obj url = '/v2/%s/snapshots/%s' % (fake.PROJECT_ID, UUID1) res = self._make_request(url) self.assertEqual(http_client.OK, res.status_int) self.assertSnapshotAttributes(self._get_snapshot(res.body), project_id=fake.PROJECT_ID, progress='0%') calls = [ mock.call(snap_policy.GET_POLICY, target_obj=snapshot_obj), mock.call(snap_policy.EXTEND_ATTRIBUTE, fatal=False) ] mock_authorize.assert_has_calls(calls)
def test_update_all_with_keys_in_uppercase_and_lowercase( self, snapshot_get_by_id, snapshot_update): snapshot = { 'id': self.req_id, 'expected_attrs': ['metadata'] } ctx = context.RequestContext('admin', 'fake', True) snapshot_obj = fake_snapshot.fake_snapshot_obj(ctx, **snapshot) snapshot_get_by_id.return_value = snapshot_obj self.stubs.Set(cinder.db, 'snapshot_metadata_get', return_create_snapshot_metadata) self.stubs.Set(cinder.db, 'snapshot_metadata_update', return_new_snapshot_metadata) req = fakes.HTTPRequest.blank(self.url) req.method = 'PUT' req.content_type = "application/json" body = { 'metadata': { 'key10': 'value10', 'KEY10': 'value10', 'key99': 'value99', 'KEY20': 'value20', }, } expected = { 'metadata': { 'key10': 'value10', 'key99': 'value99', 'KEY20': 'value20', }, } req.body = jsonutils.dumps(expected) res_dict = self.controller.update_all(req, self.req_id, body) self.assertEqual(expected, res_dict)
def test_delete_snapshot(self): snapshot = fake_snapshot.fake_snapshot_obj(self.context) snapshot.provider_id = fake.PROVIDER_ID self.assertIsNone(self._driver.delete_snapshot(snapshot))
def test_delete_snapshot_failure(self): snapshot = fake_snapshot.fake_snapshot_obj(self.context) snapshot.provider_id = fake.PROVIDER_ID self.assertRaises(exception.VolumeDriverException, self._driver.delete_snapshot, snapshot)
def test_delete_snapshot(self): snapshot = fake_snapshot.fake_snapshot_obj(self.context) snapshot.provider_id = 'snapshot-id' self.assertIsNone(self._driver.delete_snapshot(snapshot))
def test_create_snapshot(self): snapshot = fake_snapshot.fake_snapshot_obj(self.context) volume = fake_volume.fake_volume_obj(self.context) snapshot.volume = volume self._driver.create_snapshot(snapshot)
def _fake_snapshot_wrapper(*args, **kwargs): return fake_snapshot.fake_snapshot_obj(None, expected_attrs=( ['volume'] if 'volume' in kwargs else None), **kwargs)
def test_create_volume_from_snapshot_failure(self): snapshot = fake_snapshot.fake_snapshot_obj(self.context) volume = fake_volume.fake_volume_obj(self.context) self.assertRaises(exception.VolumeDriverException, self._driver.create_volume_from_snapshot, volume, snapshot)
def test_delete_snapshot_failure(self): snapshot = fake_snapshot.fake_snapshot_obj(self.context) self.assertRaises(exception.VolumeDriverException, self._driver.delete_snapshot, snapshot)
def test_create_volume_from_snapshot(self): snapshot = fake_snapshot.fake_snapshot_obj(self.context) volume = fake_volume.fake_volume_obj(self.context) self.assertEqual({'provider_location': self._provider_location}, self._driver.create_volume_from_snapshot( volume, snapshot))
def setUp(self): """Setup a test case environment. Creates a fake volume object and sets up the required API responses. """ super(TestManageExistingSnapshot, self).setUp() ctx = context.RequestContext('fake', 'fake', auth_token=True) self.volume = fake_volume.fake_volume_obj( ctx, **{'provider_id': fake.PROVIDER_ID}) self.snapshot = fake_snapshot.fake_snapshot_obj( ctx, **{'provider_id': fake.PROVIDER2_ID}) self.snapshot2 = fake_snapshot.fake_snapshot_obj( ctx, **{'provider_id': fake.PROVIDER3_ID}) self.snapshot.volume = self.snapshot2.volume = self.volume self.snapshot['volume_type_id'] = fake.VOLUME_TYPE_ID self.snapshot2['volume_type_id'] = fake.VOLUME_TYPE_ID self.snapshot_attached = fake_snapshot.fake_snapshot_obj( ctx, **{'provider_id': fake.PROVIDER4_ID}) self.HTTPS_MOCK_RESPONSES = { self.RESPONSE_MODE.Valid: { 'instances/Volume::' + self.volume['provider_id']: mocks.MockHTTPSResponse( { 'id': fake.PROVIDER_ID, 'sizeInKb': 8388608, 'mappedSdcInfo': None, 'ancestorVolumeId': None }, 200), 'instances/Volume::' + self.snapshot['provider_id']: mocks.MockHTTPSResponse( { 'id': fake.PROVIDER2_ID, 'sizeInKb': 8000000, 'mappedSdcInfo': None, 'ancestorVolumeId': fake.PROVIDER_ID }, 200), 'instances/Volume::' + self.snapshot2['provider_id']: mocks.MockHTTPSResponse( { 'id': fake.PROVIDER3_ID, 'sizeInKb': 8388608, 'mappedSdcInfo': None, 'ancestorVolumeId': fake.PROVIDER2_ID }, 200) }, self.RESPONSE_MODE.BadStatus: { 'instances/Volume::' + self.snapshot['provider_id']: mocks.MockHTTPSResponse( { 'errorCode': 401, 'message': 'BadStatus Volume Test', }, 401), 'instances/Volume::' + self.snapshot2['provider_id']: mocks.MockHTTPSResponse( { 'id': fake.PROVIDER3_ID, 'sizeInKb': 8388608, 'ancestorVolumeId': fake.PROVIDER2_ID }, 200), 'instances/Volume::' + self.snapshot_attached['provider_id']: mocks.MockHTTPSResponse( { 'id': fake.PROVIDER4_ID, 'sizeInKb': 8388608, 'mappedSdcInfo': 'Mapped', 'ancestorVolumeId': fake.PROVIDER_ID }, 200) } }
def test_create_group_from_src_generic(self, mock_create_clone, mock_create_vol_from_snap): grp = {'id': fake.GROUP_ID, 'name': 'group 1'} grp_snp = { 'id': fake.GROUP_SNAPSHOT_ID, 'group_id': fake.GROUP_ID, 'name': 'group snap 1' } grp2 = { 'id': fake.GROUP2_ID, 'name': 'group 2', 'group_snapshot_id': fake.GROUP_SNAPSHOT_ID } vol1 = { 'id': fake.VOLUME_ID, 'name': 'volume 1', 'group_id': fake.GROUP_ID } vol2 = { 'id': fake.VOLUME2_ID, 'name': 'volume 2', 'group_id': fake.GROUP_ID } snp1 = { 'id': fake.SNAPSHOT_ID, 'name': 'snap 1', 'group_snapshot_id': fake.GROUP_SNAPSHOT_ID, 'volume_id': fake.VOLUME_ID } snp2 = { 'id': fake.SNAPSHOT2_ID, 'name': 'snap 2', 'group_snapshot_id': fake.GROUP_SNAPSHOT_ID, 'volume_id': fake.VOLUME2_ID } snp1_obj = fake_snapshot.fake_snapshot_obj(self.context, **snp1) snp2_obj = fake_snapshot.fake_snapshot_obj(self.context, **snp2) snapshots = [] snapshots.append(snp1_obj) snapshots.append(snp2_obj) vol3 = { 'id': fake.VOLUME3_ID, 'name': 'volume 3', 'snapshot_id': fake.SNAPSHOT_ID, 'group_id': fake.GROUP2_ID } vol4 = { 'id': fake.VOLUME4_ID, 'name': 'volume 4', 'snapshot_id': fake.SNAPSHOT2_ID, 'group_id': fake.GROUP2_ID } vol3_obj = fake_volume.fake_volume_obj(self.context, **vol3) vol4_obj = fake_volume.fake_volume_obj(self.context, **vol4) vols2 = [] vols2.append(vol3_obj) vols2.append(vol4_obj) grp2_obj = fake_group.fake_group_obj(self.context, **grp2) grp_snp_obj = fake_group_snapshot.fake_group_snapshot_obj( self.context, **grp_snp) driver_update = {'test_key': 'test_val'} mock_create_vol_from_snap.return_value = driver_update model_update, vol_model_updates = ( self.volume._create_group_from_src_generic(self.context, grp2_obj, vols2, grp_snp_obj, snapshots)) for update in vol_model_updates: self.assertEqual(driver_update['test_key'], update['test_key']) vol1_obj = fake_volume.fake_volume_obj(self.context, **vol1) vol2_obj = fake_volume.fake_volume_obj(self.context, **vol2) vols = [] vols.append(vol1_obj) vols.append(vol2_obj) grp_obj = fake_group.fake_group_obj(self.context, **grp) grp3 = { 'id': fake.GROUP3_ID, 'name': 'group 3', 'source_group_id': fake.GROUP_ID } grp3_obj = fake_group.fake_group_obj(self.context, **grp3) vol5 = { 'id': fake.VOLUME5_ID, 'name': 'volume 5', 'source_volid': fake.VOLUME_ID, 'group_id': fake.GROUP3_ID } vol6 = { 'id': fake.VOLUME6_ID, 'name': 'volume 6', 'source_volid': fake.VOLUME2_ID, 'group_id': fake.GROUP3_ID } vol5_obj = fake_volume.fake_volume_obj(self.context, **vol5) vol6_obj = fake_volume.fake_volume_obj(self.context, **vol6) vols3 = [] vols3.append(vol5_obj) vols3.append(vol6_obj) driver_update = {'test_key2': 'test_val2'} mock_create_clone.return_value = driver_update model_update, vol_model_updates = ( self.volume._create_group_from_src_generic(self.context, grp3_obj, vols3, None, None, grp_obj, vols)) for update in vol_model_updates: self.assertEqual(driver_update['test_key2'], update['test_key2'])
def test_sort_snapshots(self): vol1 = { 'id': fake.VOLUME_ID, 'name': 'volume 1', 'snapshot_id': fake.SNAPSHOT_ID, 'group_id': fake.GROUP_ID } vol2 = { 'id': fake.VOLUME2_ID, 'name': 'volume 2', 'snapshot_id': fake.SNAPSHOT2_ID, 'group_id': fake.GROUP_ID } vol3 = { 'id': fake.VOLUME3_ID, 'name': 'volume 3', 'snapshot_id': fake.SNAPSHOT3_ID, 'group_id': fake.GROUP_ID } snp1 = { 'id': fake.SNAPSHOT_ID, 'name': 'snap 1', 'group_snapshot_id': fake.GROUP_ID } snp2 = { 'id': fake.SNAPSHOT2_ID, 'name': 'snap 2', 'group_snapshot_id': fake.GROUP_ID } snp3 = { 'id': fake.SNAPSHOT3_ID, 'name': 'snap 3', 'group_snapshot_id': fake.GROUP_ID } snp1_obj = fake_snapshot.fake_snapshot_obj(self.context, **snp1) snp2_obj = fake_snapshot.fake_snapshot_obj(self.context, **snp2) snp3_obj = fake_snapshot.fake_snapshot_obj(self.context, **snp3) volumes = [] snapshots = [] volumes.append(vol1) volumes.append(vol2) volumes.append(vol3) snapshots.append(snp2_obj) snapshots.append(snp3_obj) snapshots.append(snp1_obj) i = 0 for vol in volumes: snap = snapshots[i] i += 1 self.assertNotEqual(vol['snapshot_id'], snap.id) sorted_snaps = self.volume._sort_snapshots(volumes, snapshots) i = 0 for vol in volumes: snap = sorted_snaps[i] i += 1 self.assertEqual(vol['snapshot_id'], snap.id) snapshots[2]['id'] = fake.WILL_NOT_BE_FOUND_ID self.assertRaises(exception.SnapshotNotFound, self.volume._sort_snapshots, volumes, snapshots) self.assertRaises(exception.InvalidInput, self.volume._sort_snapshots, volumes, [])
def test_delete_snapshot(self): snapshot = fake_snapshot.fake_snapshot_obj(self.context) self._driver.delete_snapshot(snapshot)
class PowerMaxData(object): # array info array = '000197800123' uni_array = u'000197800123' array_herc = '000197900123' srp = 'SRP_1' srp2 = 'SRP_2' slo = 'Diamond' workload = 'DSS' port_group_name_f = 'OS-fibre-PG' port_group_name_i = 'OS-iscsi-PG' masking_view_name_f = 'OS-HostX-F-OS-fibre-PG-MV' masking_view_name_i = 'OS-HostX-SRP_1-I-OS-iscsi-PG-MV' initiatorgroup_name_f = 'OS-HostX-F-IG' initiatorgroup_name_i = 'OS-HostX-I-IG' parent_sg_f = 'OS-HostX-F-OS-fibre-PG-SG' parent_sg_i = 'OS-HostX-I-OS-iscsi-PG-SG' storagegroup_name_f = 'OS-HostX-SRP_1-DiamondDSS-OS-fibre-PG' storagegroup_name_i = 'OS-HostX-SRP_1-Diamond-DSS-OS-iscsi-PG' defaultstoragegroup_name = 'OS-SRP_1-Diamond-DSS-SG' storagegroup_list = [defaultstoragegroup_name] default_sg_no_slo = 'OS-no_SLO-SG' default_sg_compr_disabled = 'OS-SRP_1-Diamond-DSS-CD-SG' default_sg_re_enabled = 'OS-SRP_1-Diamond-DSS-RE-SG' failed_resource = 'OS-failed-resource' fake_host = 'HostX@Backend#Diamond+DSS+SRP_1+000197800123' new_host = 'HostX@Backend#Silver+OLTP+SRP_1+000197800123' none_host = 'HostX@Backend#Diamond+None+SRP_1+000197800123' version = '3.1.0' volume_wwn = '600000345' remote_array = '000197800124' device_id = '00001' device_id2 = '00002' device_id3 = '00003' device_id4 = '00004' rdf_group_name = '23_24_007' rdf_group_no = '70' u4v_version = '91' storagegroup_name_source = 'Grp_source_sg' storagegroup_name_target = 'Grp_target_sg' group_snapshot_name = 'Grp_snapshot' target_group_name = 'Grp_target' storagegroup_name_with_id = 'GrpId_group_name' rdf_managed_async_grp = 'OS-%s-Asynchronous-rdf-sg' % rdf_group_name volume_id = '2b06255d-f5f0-4520-a953-b029196add6a' no_slo_sg_name = 'OS-HostX-No_SLO-OS-fibre-PG' temp_snapvx = 'temp-00001-snapshot_for_clone' # connector info wwpn1 = '123456789012345' wwpn2 = '123456789054321' wwnn1 = '223456789012345' initiator = 'iqn.1993-08.org.debian: 01: 222' ip, ip2 = u'123.456.7.8', u'123.456.7.9' iqn = u'iqn.1992-04.com.emc:600009700bca30c01e3e012e00000001,t,0x0001' iqn2 = u'iqn.1992-04.com.emc:600009700bca30c01e3e012e00000002,t,0x0001' connector = { 'ip': ip, 'initiator': initiator, 'wwpns': [wwpn1, wwpn2], 'wwnns': [wwnn1], 'host': 'HostX' } fabric_name_prefix = 'fakeFabric' end_point_map = { connector['wwpns'][0]: [wwnn1], connector['wwpns'][1]: [wwnn1] } target_wwns = [wwnn1] zoning_mappings = { 'array': u'000197800123', 'init_targ_map': end_point_map, 'initiator_group': initiatorgroup_name_f, 'port_group': port_group_name_f, 'target_wwns': target_wwns } zoning_mappings_metro = deepcopy(zoning_mappings) zoning_mappings_metro.update({ 'metro_port_group': port_group_name_f, 'metro_ig': initiatorgroup_name_f, 'metro_array': remote_array }) device_map = {} for wwn in connector['wwpns']: fabric_name = ''.join([fabric_name_prefix, wwn[-2:]]) target_wwn = wwn[::-1] fabric_map = { 'initiator_port_wwn_list': [wwn], 'target_port_wwn_list': [target_wwn] } device_map[fabric_name] = fabric_map iscsi_device_info = { 'maskingview': masking_view_name_i, 'ip_and_iqn': [{ 'ip': ip, 'iqn': initiator }], 'is_multipath': True, 'array': array, 'controller': { 'host': '10.00.00.00' }, 'hostlunid': 3 } iscsi_device_info_metro = deepcopy(iscsi_device_info) iscsi_device_info_metro['metro_ip_and_iqn'] = [{'ip': ip2, 'iqn': iqn2}] iscsi_device_info_metro['metro_hostlunid'] = 2 fc_device_info = { 'maskingview': masking_view_name_f, 'array': array, 'controller': { 'host': '10.00.00.00' }, 'hostlunid': 3 } # snapshot info snapshot_id = '390eeb4d-0f56-4a02-ba14-167167967014' snapshot_display_id = 'my_snap' managed_snap_id = 'OS-390eeb4d-0f56-4a02-ba14-167167967014' test_snapshot_snap_name = 'OS-' + snapshot_id[:6] + snapshot_id[-9:] snap_location = { 'snap_name': test_snapshot_snap_name, 'source_id': device_id } # cinder volume info ctx = context.RequestContext('admin', 'fake', True) provider_location = {'array': array, 'device_id': device_id} provider_location2 = { 'array': six.text_type(array), 'device_id': device_id2 } provider_location3 = { 'array': six.text_type(remote_array), 'device_id': device_id2 } provider_location4 = { 'array': six.text_type(uni_array), 'device_id': device_id } provider_location_clone = { 'array': array, 'device_id': device_id, 'snap_name': temp_snapvx, 'source_device_id': device_id } provider_location_snapshot = { 'array': array, 'device_id': device_id, 'snap_name': test_snapshot_snap_name, 'source_device_id': device_id } provider_location5 = {'array': remote_array, 'device_id': device_id} legacy_provider_location = { 'classname': 'Symm_StorageVolume', 'keybindings': { 'CreationClassName': u'Symm_StorageVolume', 'SystemName': u'SYMMETRIX+000197800123', 'DeviceID': device_id, 'SystemCreationClassName': u'Symm_StorageSystem' } } legacy_provider_location2 = { 'classname': 'Symm_StorageVolume', 'keybindings': { 'CreationClassName': u'Symm_StorageVolume', 'SystemName': u'SYMMETRIX+000197800123', 'DeviceID': device_id2, 'SystemCreationClassName': u'Symm_StorageSystem' } } test_volume_type = fake_volume.fake_volume_type_obj(context=ctx) test_volume = fake_volume.fake_volume_obj( context=ctx, name='vol1', size=2, provider_auth=None, provider_location=six.text_type(provider_location), volume_type=test_volume_type, host=fake_host, replication_driver_data=six.text_type(provider_location3)) test_attached_volume = fake_volume.fake_volume_obj( id='4732de9b-98a4-4b6d-ae4b-3cafb3d34220', context=ctx, name='vol1', size=0, provider_auth=None, attach_status='attached', provider_location=six.text_type(provider_location), host=fake_host, volume_type=test_volume_type, replication_driver_data=six.text_type(provider_location3)) test_legacy_vol = fake_volume.fake_volume_obj( context=ctx, name='vol1', size=2, provider_auth=None, provider_location=six.text_type(legacy_provider_location), replication_driver_data=six.text_type(legacy_provider_location2), host=fake_host, volume_type=test_volume_type) test_clone_volume = fake_volume.fake_volume_obj( context=ctx, name='vol1', size=2, provider_auth=None, provider_location=six.text_type(provider_location2), host=fake_host, source_volid=test_volume.id, snapshot_id=snapshot_id, _name_id=test_volume.id) test_volume_snap_manage = fake_volume.fake_volume_obj( context=ctx, name='vol1', size=2, provider_auth=None, display_name='vol1', provider_location=six.text_type(provider_location), volume_type=test_volume_type, host=fake_host, replication_driver_data=six.text_type(provider_location4)) test_snapshot = fake_snapshot.fake_snapshot_obj( context=ctx, id=snapshot_id, name='my_snap', size=2, provider_location=six.text_type(snap_location), host=fake_host, volume=test_volume) test_legacy_snapshot = fake_snapshot.fake_snapshot_obj( context=ctx, id=test_volume.id, name='my_snap', size=2, provider_location=six.text_type(legacy_provider_location), host=fake_host, volume=test_volume) test_failed_snap = fake_snapshot.fake_snapshot_obj( context=ctx, id='4732de9b-98a4-4b6d-ae4b-3cafb3d34220', name=failed_resource, size=2, provider_location=six.text_type(snap_location), host=fake_host, volume=test_volume) test_snapshot_manage = fake_snapshot.fake_snapshot_obj( context=ctx, id=snapshot_id, name='my_snap', size=2, provider_location=six.text_type(snap_location), host=fake_host, volume=test_volume_snap_manage, display_name='my_snap') test_volume_attachment = volume_attachment.VolumeAttachment( id='2b06255d-f5f0-4520-a953-b029196add6b', volume_id=test_volume.id, connector=connector) location_info = { 'location_info': '000197800123#SRP_1#Diamond#DSS', 'storage_protocol': 'FC' } test_host = {'capabilities': location_info, 'host': fake_host} # extra-specs vol_type_extra_specs = {'pool_name': u'Diamond+DSS+SRP_1+000197800123'} vol_type_extra_specs_compr_disabled = { 'pool_name': u'Diamond+DSS+SRP_1+000197800123', 'storagetype:disablecompression': 'true' } vol_type_extra_specs_rep_enabled = { 'pool_name': u'Diamond+DSS+SRP_1+000197800123', 'replication_enabled': '<is> True' } extra_specs = { 'pool_name': u'Diamond+DSS+SRP_1+000197800123', 'slo': slo, 'workload': workload, 'srp': srp, 'array': array, 'interval': 3, 'retries': 120 } extra_specs_migrate = deepcopy(extra_specs) extra_specs_migrate[utils.PORTGROUPNAME] = port_group_name_f extra_specs_disable_compression = deepcopy(extra_specs) extra_specs_disable_compression[utils.DISABLECOMPRESSION] = 'true' extra_specs_intervals_set = deepcopy(extra_specs) extra_specs_intervals_set['interval'] = 1 extra_specs_intervals_set['retries'] = 1 extra_specs_rep_enabled = deepcopy(extra_specs) extra_specs_rep_enabled['replication_enabled'] = True rep_extra_specs = deepcopy(extra_specs_rep_enabled) rep_extra_specs['array'] = remote_array rep_extra_specs['interval'] = 1 rep_extra_specs['retries'] = 1 rep_extra_specs['srp'] = srp2 rep_extra_specs['rep_mode'] = 'Synchronous' rep_extra_specs2 = deepcopy(rep_extra_specs) rep_extra_specs2[utils.PORTGROUPNAME] = port_group_name_f rep_extra_specs3 = deepcopy(rep_extra_specs) rep_extra_specs3['slo'] = slo rep_extra_specs3['workload'] = workload rep_extra_specs4 = deepcopy(rep_extra_specs3) rep_extra_specs4['rdf_group_label'] = rdf_group_name rep_extra_specs5 = deepcopy(rep_extra_specs2) rep_extra_specs5['target_array_model'] = 'VMAX250F' test_volume_type_1 = volume_type.VolumeType( id='2b06255d-f5f0-4520-a953-b029196add6a', name='abc', extra_specs=extra_specs) test_volume_type_list = volume_type.VolumeTypeList( objects=[test_volume_type_1]) test_vol_grp_name_id_only = 'ec870a2f-6bf7-4152-aa41-75aad8e2ea96' test_vol_grp_name = 'Grp_source_sg_%s' % test_vol_grp_name_id_only test_fo_vol_group = 'fo_vol_group_%s' % test_vol_grp_name_id_only test_group_1 = group.Group( context=None, name=storagegroup_name_source, group_id='abc', size=1, id=test_vol_grp_name_id_only, status='available', provider_auth=None, volume_type_ids=['abc'], group_type_id='grptypeid', volume_types=test_volume_type_list, host=fake_host, provider_location=six.text_type(provider_location)) test_group_failed = group.Group( context=None, name=failed_resource, group_id='14b8894e-54ec-450a-b168-c172a16ed166', size=1, id='318c721c-51ad-4160-bfe1-ebde2273836f', status='available', provider_auth=None, volume_type_ids=['abc'], group_type_id='grptypeid', volume_types=test_volume_type_list, host=fake_host, provider_location=six.text_type(provider_location), replication_status=fields.ReplicationStatus.DISABLED) test_rep_group = fake_group.fake_group_obj( context=ctx, name=storagegroup_name_source, id=test_vol_grp_name_id_only, host=fake_host, replication_status=fields.ReplicationStatus.ENABLED) test_group = fake_group.fake_group_obj(context=ctx, name=storagegroup_name_source, id=test_vol_grp_name_id_only, host=fake_host) test_group_without_name = fake_group.fake_group_obj( context=ctx, name=None, id=test_vol_grp_name_id_only, host=fake_host) test_group_snapshot_1 = group_snapshot.GroupSnapshot( context=None, id='6560405d-b89a-4f79-9e81-ad1752f5a139', group_id='876d9fbb-de48-4948-9f82-15c913ed05e7', name=group_snapshot_name, group_type_id='c6934c26-dde8-4bf8-a765-82b3d0130e9f', status='available', group=test_group_1) test_group_snapshot_failed = group_snapshot.GroupSnapshot( context=None, id='0819dd5e-9aa1-4ec7-9dda-c78e51b2ad76', group_id='1fc735cb-d36c-4352-8aa6-dc1e16b5a0a7', name=failed_resource, group_type_id='6b70de13-98c5-46b2-8f24-e4e96a8988fa', status='available', group=test_group_failed) test_volume_group_member = fake_volume.fake_volume_obj( context=ctx, name='vol1', size=2, provider_auth=None, provider_location=six.text_type(provider_location), volume_type=test_volume_type, host=fake_host, replication_driver_data=six.text_type(provider_location3), group_id=test_vol_grp_name_id_only) # masking view dict masking_view_dict = { 'array': array, 'connector': connector, 'device_id': device_id, 'init_group_name': initiatorgroup_name_f, 'initiator_check': None, 'maskingview_name': masking_view_name_f, 'parent_sg_name': parent_sg_f, 'srp': srp, 'storagetype:disablecompression': False, utils.PORTGROUPNAME: port_group_name_f, 'slo': slo, 'storagegroup_name': storagegroup_name_f, 'volume_name': test_volume.name, 'workload': workload, 'replication_enabled': False } masking_view_dict_no_slo = deepcopy(masking_view_dict) masking_view_dict_no_slo.update({ 'slo': None, 'workload': None, 'storagegroup_name': no_slo_sg_name }) masking_view_dict_compression_disabled = deepcopy(masking_view_dict) masking_view_dict_compression_disabled.update({ 'storagetype:disablecompression': True, 'storagegroup_name': 'OS-HostX-SRP_1-DiamondDSS-OS-fibre-PG-CD' }) masking_view_dict_replication_enabled = deepcopy(masking_view_dict) masking_view_dict_replication_enabled.update({ 'replication_enabled': True, 'storagegroup_name': 'OS-HostX-SRP_1-DiamondDSS-OS-fibre-PG-RE' }) masking_view_dict_multiattach = deepcopy(masking_view_dict) masking_view_dict_multiattach.update({ utils.EXTRA_SPECS: extra_specs, utils.IS_MULTIATTACH: True, utils.OTHER_PARENT_SG: parent_sg_i, utils.FAST_SG: storagegroup_name_i, utils.NO_SLO_SG: no_slo_sg_name }) # vmax data # sloprovisioning compression_info = {'symmetrixId': ['000197800128']} inititiatorgroup = [{ 'initiator': [wwpn1], 'hostId': initiatorgroup_name_f, 'maskingview': [masking_view_name_f] }, { 'initiator': [initiator], 'hostId': initiatorgroup_name_i, 'maskingview': [masking_view_name_i] }] initiator_list = [{ 'host': initiatorgroup_name_f, 'initiatorId': wwpn1, 'maskingview': [masking_view_name_f] }, { 'host': initiatorgroup_name_i, 'initiatorId': initiator, 'maskingview': [masking_view_name_i] }, { 'initiatorId': ['FA-1D:4:' + wwpn1, 'SE-4E:0:' + initiator] }] maskingview = [{ 'maskingViewId': masking_view_name_f, 'portGroupId': port_group_name_f, 'storageGroupId': storagegroup_name_f, 'hostId': initiatorgroup_name_f, 'maskingViewConnection': [{ 'host_lun_address': '0003' }] }, { 'maskingViewId': masking_view_name_i, 'portGroupId': port_group_name_i, 'storageGroupId': storagegroup_name_i, 'hostId': initiatorgroup_name_i, 'maskingViewConnection': [{ 'host_lun_address': '0003' }] }, {}] portgroup = [{ 'portGroupId': port_group_name_f, 'symmetrixPortKey': [{ 'directorId': 'FA-1D', 'portId': '4' }], 'maskingview': [masking_view_name_f] }, { 'portGroupId': port_group_name_i, 'symmetrixPortKey': [{ 'directorId': 'SE-4E', 'portId': '0' }], 'maskingview': [masking_view_name_i] }] port_list = [{ 'symmetrixPort': { 'num_of_masking_views': 1, 'maskingview': [masking_view_name_f], 'identifier': wwnn1, 'symmetrixPortKey': { 'directorId': 'FA-1D', 'portId': '4' }, 'portgroup': [port_group_name_f] } }, { 'symmetrixPort': { 'identifier': initiator, 'symmetrixPortKey': { 'directorId': 'SE-4E', 'portId': '0' }, 'ip_addresses': [ip], 'num_of_masking_views': 1, 'maskingview': [masking_view_name_i], 'portgroup': [port_group_name_i] } }] sg_details = [{ 'srp': srp, 'num_of_vols': 2, 'cap_gb': 2, 'storageGroupId': defaultstoragegroup_name, 'slo': slo, 'workload': workload }, { 'srp': srp, 'num_of_vols': 2, 'cap_gb': 2, 'storageGroupId': storagegroup_name_f, 'slo': slo, 'workload': workload, 'maskingview': [masking_view_name_f], 'parent_storage_group': [parent_sg_f] }, { 'srp': srp, 'num_of_vols': 2, 'cap_gb': 2, 'storageGroupId': storagegroup_name_i, 'slo': slo, 'workload': workload, 'maskingview': [masking_view_name_i], 'parent_storage_group': [parent_sg_i] }, { 'num_of_vols': 2, 'cap_gb': 2, 'storageGroupId': parent_sg_f, 'num_of_child_sgs': 1, 'child_storage_group': [storagegroup_name_f], 'maskingview': [masking_view_name_f] }, { 'num_of_vols': 2, 'cap_gb': 2, 'storageGroupId': parent_sg_i, 'num_of_child_sgs': 1, 'child_storage_group': [storagegroup_name_i], 'maskingview': [masking_view_name_i], }, { 'srp': srp, 'num_of_vols': 2, 'cap_gb': 2, 'storageGroupId': no_slo_sg_name, 'slo': None, 'workload': None, 'maskingview': [masking_view_name_i], 'parent_storage_group': [parent_sg_i] }] sg_details_rep = [{ 'childNames': [], 'numDevicesNonGk': 2, 'isLinkTarget': False, 'rdf': True, 'capacityGB': 2.0, 'name': storagegroup_name_source, 'snapVXSnapshots': ['6560405d-752f5a139'], 'symmetrixId': array, 'numSnapVXSnapshots': 1 }] sg_rdf_details = [{ 'storageGroupName': test_vol_grp_name, 'symmetrixId': array, 'modes': ['Synchronous'], 'rdfGroupNumber': rdf_group_no, 'states': ['Synchronized'] }, { 'storageGroupName': test_fo_vol_group, 'symmetrixId': array, 'modes': ['Synchronous'], 'rdfGroupNumber': rdf_group_no, 'states': ['Failed Over'] }] sg_list = { 'storageGroupId': [storagegroup_name_f, defaultstoragegroup_name] } sg_list_rep = [storagegroup_name_with_id] srp_details = { 'srp_capacity': { u'subscribed_total_tb': 93.52, u'usable_used_tb': 8.62, u'usable_total_tb': 24.45, u'snapshot_modified_tb': 0.0, u'subscribed_allocated_tb': 18.77, u'snapshot_total_tb': 1.58 }, 'srpId': srp, 'reserved_cap_percent': 10 } array_info_wl = { 'RestServerIp': '1.1.1.1', 'RestServerPort': 3448, 'RestUserName': '******', 'RestPassword': '******', 'SSLVerify': False, 'SerialNumber': array, 'srpName': 'SRP_1', 'PortGroup': port_group_name_i, 'SLO': 'Diamond', 'Workload': 'OLTP' } array_info_no_wl = { 'RestServerIp': '1.1.1.1', 'RestServerPort': 3448, 'RestUserName': '******', 'RestPassword': '******', 'SSLVerify': False, 'SerialNumber': array, 'srpName': 'SRP_1', 'PortGroup': port_group_name_i, 'SLO': 'Diamond' } volume_details = [ { 'cap_gb': 2, 'num_of_storage_groups': 1, 'volumeId': device_id, 'volume_identifier': 'OS-%s' % test_volume.id, 'wwn': volume_wwn, 'snapvx_target': 'false', 'snapvx_source': 'false', 'storageGroupId': [defaultstoragegroup_name, storagegroup_name_f] }, { 'cap_gb': 1, 'num_of_storage_groups': 1, 'volumeId': device_id2, 'volume_identifier': 'OS-%s' % test_volume.id, 'wwn': '600012345', 'storageGroupId': [defaultstoragegroup_name, storagegroup_name_f] }, { 'cap_gb': 1, 'num_of_storage_groups': 0, 'volumeId': device_id3, 'volume_identifier': '123', 'wwn': '600012345' }, { 'cap_gb': 1, 'num_of_storage_groups': 1, 'volumeId': device_id4, 'volume_identifier': 'random_name', 'wwn': '600012345', 'storageGroupId': ['random_sg_1', 'random_sg_2'] }, ] volume_details_attached = { 'cap_gb': 2, 'num_of_storage_groups': 1, 'volumeId': device_id, 'volume_identifier': 'OS-%s' % test_volume.id, 'wwn': volume_wwn, 'snapvx_target': 'false', 'snapvx_source': 'false', 'storageGroupId': [storagegroup_name_f] } volume_details_no_sg = { 'cap_gb': 2, 'num_of_storage_groups': 1, 'volumeId': device_id, 'volume_identifier': 'OS-%s' % test_volume.id, 'wwn': volume_wwn, 'snapvx_target': 'false', 'snapvx_source': 'false', 'storageGroupId': [] } volume_list = [{ 'id': '6b70de13-98c5-46b2-8f24-e4e96a8988fa', 'count': 2, 'maxPageSize': 1, 'resultList': { 'result': [{ 'volumeId': device_id }], 'from': 0, 'to': 1 } }, { 'resultList': { 'result': [{ 'volumeId': device_id2 }] } }, { 'id': '6b70de13-98c5-46b2-8f24-e4e96a8988fa', 'count': 2, 'maxPageSize': 1, 'resultList': { 'result': [{ 'volumeId': device_id }, { 'volumeId': device_id2 }], 'from': 0, 'to': 1 } }] private_vol_details = { 'id': '6b70de13-98c5-46b2-8f24-e4e96a8988fa', 'count': 2, 'maxPageSize': 1, 'resultList': { 'result': [{ 'timeFinderInfo': { 'snapVXSession': [{ 'srcSnapshotGenInfo': [{ 'snapshotHeader': { 'snapshotName': 'temp-1', 'device': device_id, 'generation': '0' }, 'lnkSnapshotGenInfo': [{ 'targetDevice': device_id2, 'state': 'Copied' }] }] }, { 'tgtSrcSnapshotGenInfo': { 'snapshotName': 'temp-1', 'targetDevice': device_id2, 'sourceDevice': device_id, 'generation': '0', 'state': 'Copied' } }], 'snapVXSrc': 'true', 'snapVXTgt': 'true' }, 'rdfInfo': { 'RDFSession': [{ 'SRDFStatus': 'Ready', 'pairState': 'Synchronized', 'remoteDeviceID': device_id2, 'remoteSymmetrixID': remote_array }] } }], 'from': 0, 'to': 1 } } # Service Levels / Workloads workloadtype = {'workloadId': ['OLTP', 'OLTP_REP', 'DSS', 'DSS_REP']} srp_slo_details = { 'serviceLevelDemand': [{ 'serviceLevelId': 'None' }, { 'serviceLevelId': 'Diamond' }, { 'serviceLevelId': 'Gold' }, { 'serviceLevelId': 'Optimized' }] } slo_details = ['None', 'Diamond', 'Gold', 'Optimized'] powermax_slo_details = { 'sloId': ['Bronze', 'Diamond', 'Gold', 'Optimized', 'Platinum', 'Silver'] } powermax_model_details = { 'symmetrixId': array, 'model': 'PowerMax_2000', 'ucode': '5978.1091.1092' } vmax_slo_details = {'sloId': ['Diamond', 'Optimized']} vmax_model_details = {'model': 'VMAX450F'} # replication volume_snap_vx = { 'snapshotLnks': [], 'snapshotSrcs': [{ 'generation': 0, 'linkedDevices': [{ 'targetDevice': device_id2, 'percentageCopied': 100, 'state': 'Copied', 'copy': True, 'defined': True, 'linked': True }], 'snapshotName': test_snapshot_snap_name, 'state': 'Established' }] } capabilities = { 'symmetrixCapability': [{ 'rdfCapable': True, 'snapVxCapable': True, 'symmetrixId': '0001111111' }, { 'symmetrixId': array, 'snapVxCapable': True, 'rdfCapable': True }] } group_snap_vx = { 'generation': 0, 'isLinked': False, 'numUniqueTracks': 0, 'isRestored': False, 'name': group_snapshot_name, 'numStorageGroupVolumes': 1, 'state': ['Established'], 'timeToLiveExpiryDate': 'N/A', 'isExpired': False, 'numSharedTracks': 0, 'timestamp': '00:30:50 Fri, 02 Jun 2017 IST +0100', 'numSourceVolumes': 1 } group_snap_vx_1 = { 'generation': 0, 'isLinked': False, 'numUniqueTracks': 0, 'isRestored': False, 'name': group_snapshot_name, 'numStorageGroupVolumes': 1, 'state': ['Copied'], 'timeToLiveExpiryDate': 'N/A', 'isExpired': False, 'numSharedTracks': 0, 'timestamp': '00:30:50 Fri, 02 Jun 2017 IST +0100', 'numSourceVolumes': 1, 'linkedStorageGroup': { 'name': target_group_name, 'percentageCopied': 100 }, } grp_snapvx_links = [{ 'name': target_group_name, 'percentageCopied': 100 }, { 'name': 'another-target', 'percentageCopied': 90 }] rdf_group_list = { 'rdfGroupID': [{ 'rdfgNumber': rdf_group_no, 'label': rdf_group_name }] } rdf_group_details = { 'modes': ['Synchronous'], 'remoteSymmetrix': remote_array, 'label': rdf_group_name, 'type': 'Dynamic', 'numDevices': 1, 'remoteRdfgNumber': rdf_group_no, 'rdfgNumber': rdf_group_no } rdf_group_vol_details = { 'remoteRdfGroupNumber': rdf_group_no, 'localSymmetrixId': array, 'volumeConfig': 'RDF1+TDEV', 'localRdfGroupNumber': rdf_group_no, 'localVolumeName': device_id, 'rdfpairState': 'Synchronized', 'remoteVolumeName': device_id2, 'localVolumeState': 'Ready', 'rdfMode': 'Synchronous', 'remoteVolumeState': 'Write Disabled', 'remoteSymmetrixId': remote_array } # system job_list = [{ 'status': 'SUCCEEDED', 'jobId': '12345', 'result': 'created', 'resourceLink': 'storagegroup/%s' % storagegroup_name_f }, { 'status': 'RUNNING', 'jobId': '55555' }, { 'status': 'FAILED', 'jobId': '09999' }] symmetrix = [{ 'symmetrixId': array, 'model': 'VMAX250F', 'ucode': '5977.1091.1092' }, { 'symmetrixId': array_herc, 'model': 'PowerMax 2000', 'ucode': '5978.1091.1092' }] version_details = {'version': 'V9.1.0.1'} headroom = {'headroom': [{'headroomCapacity': 20348.29}]} ucode_5978_foxtail = {'ucode': '5978.435.435'} p_vol_rest_response_single = { 'id': 'f3aab01c-a5a8-4fb4-af2b-16ae1c46dc9e_0', 'count': 1, 'expirationTime': 1521650650793, 'maxPageSize': 1000, 'resultList': { 'to': 1, 'from': 1, 'result': [{ 'volumeHeader': { 'capGB': 1.0, 'capMB': 1026.0, 'volumeId': '00001', 'status': 'Ready', 'configuration': 'TDEV' } }] } } p_vol_rest_response_none = { 'id': 'f3aab01c-a5a8-4fb4-af2b-16ae1c46dc9e_0', 'count': 0, 'expirationTime': 1521650650793, 'maxPageSize': 1000, 'resultList': { 'to': 0, 'from': 0, 'result': [] } } p_vol_rest_response_iterator_1 = { 'id': 'f3aab01c-a5a8-4fb4-af2b-16ae1c46dc9e_0', 'count': 1500, 'expirationTime': 1521650650793, 'maxPageSize': 1000, 'resultList': { 'to': 1, 'from': 1, 'result': [{ 'volumeHeader': { 'capGB': 1.0, 'capMB': 1026.0, 'volumeId': '00002', 'status': 'Ready', 'configuration': 'TDEV' } }] } } p_vol_rest_response_iterator_2 = { 'to': 2000, 'from': 1001, 'result': [{ 'volumeHeader': { 'capGB': 1.0, 'capMB': 1026.0, 'volumeId': '00001', 'status': 'Ready', 'configuration': 'TDEV' } }] } rest_iterator_resonse_one = { 'to': 1000, 'from': 1, 'result': [{ 'volumeHeader': { 'capGB': 1.0, 'capMB': 1026.0, 'volumeId': '00001', 'status': 'Ready', 'configuration': 'TDEV' } }] } rest_iterator_resonse_two = { 'to': 1500, 'from': 1001, 'result': [{ 'volumeHeader': { 'capGB': 1.0, 'capMB': 1026.0, 'volumeId': '00002', 'status': 'Ready', 'configuration': 'TDEV' } }] } # COMMON.PY priv_vol_func_response_single = [{ 'volumeHeader': { 'private': False, 'capGB': 1.0, 'capMB': 1026.0, 'serviceState': 'Normal', 'emulationType': 'FBA', 'volumeId': '00001', 'status': 'Ready', 'mapped': False, 'numStorageGroups': 0, 'reservationInfo': { 'reserved': False }, 'encapsulated': False, 'formattedName': '00001', 'system_resource': False, 'numSymDevMaskingViews': 0, 'nameModifier': "", 'configuration': 'TDEV' }, 'maskingInfo': { 'masked': False }, 'rdfInfo': { 'dynamicRDF': False, 'RDF': False, 'concurrentRDF': False, 'getDynamicRDFCapability': 'RDF1_Capable', 'RDFA': False }, 'timeFinderInfo': { 'mirror': False, 'snapVXTgt': False, 'cloneTarget': False, 'cloneSrc': False, 'snapVXSrc': True, 'snapVXSession': [{ 'srcSnapshotGenInfo': [{ 'snapshotHeader': { 'timestamp': 1512763278000, 'expired': False, 'secured': False, 'snapshotName': 'testSnap1', 'device': '00001', 'generation': 0, 'timeToLive': 0 } }] }] } }] priv_vol_func_response_multi = [{ 'volumeHeader': { 'private': False, 'capGB': 100.0, 'capMB': 102400.0, 'serviceState': 'Normal', 'emulationType': 'FBA', 'volumeId': '00001', 'status': 'Ready', 'numStorageGroups': 0, 'reservationInfo': { 'reserved': False }, 'mapped': False, 'encapsulated': False, 'formattedName': '00001', 'system_resource': False, 'numSymDevMaskingViews': 0, 'nameModifier': "", 'configuration': 'TDEV' }, 'rdfInfo': { 'dynamicRDF': False, 'RDF': False, 'concurrentRDF': False, 'getDynamicRDFCapability': 'RDF1_Capable', 'RDFA': False }, 'maskingInfo': { 'masked': False }, 'timeFinderInfo': { 'mirror': False, 'snapVXTgt': False, 'cloneTarget': False, 'cloneSrc': False, 'snapVXSrc': True, 'snapVXSession': [{ 'srcSnapshotGenInfo': [{ 'snapshotHeader': { 'timestamp': 1512763278000, 'expired': False, 'secured': False, 'snapshotName': 'testSnap1', 'device': '00001', 'generation': 0, 'timeToLive': 0 } }] }] } }, { 'volumeHeader': { 'private': False, 'capGB': 200.0, 'capMB': 204800.0, 'serviceState': 'Normal', 'emulationType': 'FBA', 'volumeId': '00002', 'status': 'Ready', 'numStorageGroups': 0, 'reservationInfo': { 'reserved': False }, 'mapped': False, 'encapsulated': False, 'formattedName': '00002', 'system_resource': False, 'numSymDevMaskingViews': 0, 'nameModifier': "", 'configuration': 'TDEV' }, 'rdfInfo': { 'dynamicRDF': False, 'RDF': False, 'concurrentRDF': False, 'getDynamicRDFCapability': 'RDF1_Capable', 'RDFA': False }, 'maskingInfo': { 'masked': False }, 'timeFinderInfo': { 'mirror': False, 'snapVXTgt': False, 'cloneTarget': False, 'cloneSrc': False, 'snapVXSrc': True, 'snapVXSession': [{ 'srcSnapshotGenInfo': [{ 'snapshotHeader': { 'timestamp': 1512763278000, 'expired': False, 'secured': False, 'snapshotName': 'testSnap2', 'device': '00002', 'generation': 0, 'timeToLive': 0 } }] }] } }, { 'volumeHeader': { 'private': False, 'capGB': 300.0, 'capMB': 307200.0, 'serviceState': 'Normal', 'emulationType': 'FBA', 'volumeId': '00003', 'status': 'Ready', 'numStorageGroups': 0, 'reservationInfo': { 'reserved': False }, 'mapped': False, 'encapsulated': False, 'formattedName': '00003', 'system_resource': False, 'numSymDevMaskingViews': 0, 'nameModifier': "", 'configuration': 'TDEV' }, 'rdfInfo': { 'dynamicRDF': False, 'RDF': False, 'concurrentRDF': False, 'getDynamicRDFCapability': 'RDF1_Capable', 'RDFA': False }, 'maskingInfo': { 'masked': False }, 'timeFinderInfo': { 'mirror': False, 'snapVXTgt': False, 'cloneTarget': False, 'cloneSrc': False, 'snapVXSrc': True, 'snapVXSession': [{ 'srcSnapshotGenInfo': [{ 'snapshotHeader': { 'timestamp': 1512763278000, 'expired': False, 'secured': False, 'snapshotName': 'testSnap3', 'device': '00003', 'generation': 0, 'timeToLive': 0 } }] }] } }, { 'volumeHeader': { 'private': False, 'capGB': 400.0, 'capMB': 409600.0, 'serviceState': 'Normal', 'emulationType': 'FBA', 'volumeId': '00004', 'status': 'Ready', 'numStorageGroups': 0, 'reservationInfo': { 'reserved': False }, 'mapped': False, 'encapsulated': False, 'formattedName': '00004', 'system_resource': False, 'numSymDevMaskingViews': 0, 'nameModifier': "", 'configuration': 'TDEV' }, 'rdfInfo': { 'dynamicRDF': False, 'RDF': False, 'concurrentRDF': False, 'getDynamicRDFCapability': 'RDF1_Capable', 'RDFA': False }, 'maskingInfo': { 'masked': False }, 'timeFinderInfo': { 'mirror': False, 'snapVXTgt': False, 'cloneTarget': False, 'cloneSrc': False, 'snapVXSrc': True, 'snapVXSession': [{ 'srcSnapshotGenInfo': [{ 'snapshotHeader': { 'timestamp': 1512763278000, 'expired': False, 'secured': False, 'snapshotName': 'testSnap4', 'device': '00004', 'generation': 0, 'timeToLive': 0 } }] }] } }] priv_vol_func_response_multi_invalid = [{ 'volumeHeader': { 'private': False, 'capGB': 1.0, 'capMB': 10.0, 'serviceState': 'Normal', 'emulationType': 'FBA', 'volumeId': '00001', 'status': 'Ready', 'mapped': False, 'numStorageGroups': 0, 'reservationInfo': { 'reserved': False }, 'encapsulated': False, 'formattedName': '00001', 'system_resource': False, 'numSymDevMaskingViews': 0, 'nameModifier': "", 'configuration': 'TDEV' }, 'maskingInfo': { 'masked': False }, 'rdfInfo': { 'dynamicRDF': False, 'RDF': False, 'concurrentRDF': False, 'getDynamicRDFCapability': 'RDF1_Capable', 'RDFA': False }, 'timeFinderInfo': { 'snapVXTgt': False, 'snapVXSrc': False } }, { 'volumeHeader': { 'private': False, 'capGB': 1.0, 'capMB': 1026.0, 'serviceState': 'Normal', 'emulationType': 'FBA', 'volumeId': '00002', 'status': 'Ready', 'mapped': False, 'numStorageGroups': 0, 'reservationInfo': { 'reserved': False }, 'encapsulated': False, 'formattedName': '00002', 'system_resource': False, 'numSymDevMaskingViews': 1, 'nameModifier': "", 'configuration': 'TDEV' }, 'maskingInfo': { 'masked': False }, 'rdfInfo': { 'dynamicRDF': False, 'RDF': False, 'concurrentRDF': False, 'getDynamicRDFCapability': 'RDF1_Capable', 'RDFA': False }, 'timeFinderInfo': { 'snapVXTgt': False, 'snapVXSrc': False } }, { 'volumeHeader': { 'private': False, 'capGB': 1.0, 'capMB': 1026.0, 'serviceState': 'Normal', 'emulationType': 'CKD', 'volumeId': '00003', 'status': 'Ready', 'mapped': False, 'numStorageGroups': 0, 'reservationInfo': { 'reserved': False }, 'encapsulated': False, 'formattedName': '00003', 'system_resource': False, 'numSymDevMaskingViews': 0, 'nameModifier': "", 'configuration': 'TDEV' }, 'maskingInfo': { 'masked': False }, 'rdfInfo': { 'dynamicRDF': False, 'RDF': False, 'concurrentRDF': False, 'getDynamicRDFCapability': 'RDF1_Capable', 'RDFA': False }, 'timeFinderInfo': { 'snapVXTgt': False, 'snapVXSrc': False } }, { 'volumeHeader': { 'private': False, 'capGB': 1.0, 'capMB': 1026.0, 'serviceState': 'Normal', 'emulationType': 'FBA', 'volumeId': '00004', 'status': 'Ready', 'mapped': False, 'numStorageGroups': 0, 'reservationInfo': { 'reserved': False }, 'encapsulated': False, 'formattedName': '00004', 'system_resource': False, 'numSymDevMaskingViews': 0, 'nameModifier': "", 'configuration': 'TDEV' }, 'maskingInfo': { 'masked': False }, 'rdfInfo': { 'dynamicRDF': False, 'RDF': False, 'concurrentRDF': False, 'getDynamicRDFCapability': 'RDF1_Capable', 'RDFA': False }, 'timeFinderInfo': { 'snapVXTgt': True, 'snapVXSrc': False } }, { 'volumeHeader': { 'private': False, 'capGB': 1.0, 'capMB': 1026.0, 'serviceState': 'Normal', 'emulationType': 'FBA', 'volumeId': '00005', 'status': 'Ready', 'mapped': False, 'numStorageGroups': 0, 'reservationInfo': { 'reserved': False }, 'encapsulated': False, 'formattedName': '00005', 'system_resource': False, 'numSymDevMaskingViews': 0, 'nameModifier': 'OS-vol', 'configuration': 'TDEV' }, 'maskingInfo': { 'masked': False }, 'rdfInfo': { 'dynamicRDF': False, 'RDF': False, 'concurrentRDF': False, 'getDynamicRDFCapability': 'RDF1_Capable', 'RDFA': False }, 'timeFinderInfo': { 'snapVXTgt': False, 'snapVXSrc': False } }] volume_info_dict = { 'volume_id': volume_id, 'service_level': 'Diamond', 'masking_view': 'OS-HostX-F-OS-fibre-PG-MV', 'host': fake_host, 'display_name': 'attach_vol_name', 'volume_updated_time': '2018-03-05 20:32:41', 'port_group': 'OS-fibre-PG', 'operation': 'attach', 'srp': 'SRP_1', 'initiator_group': 'OS-HostX-F-IG', 'serial_number': '000197800123', 'parent_storage_group': 'OS-HostX-F-OS-fibre-PG-SG', 'workload': 'DSS', 'child_storage_group': 'OS-HostX-SRP_1-DiamondDSS-OS-fibre-PG' } data_dict = {volume_id: volume_info_dict} platform = 'Linux-4.4.0-104-generic-x86_64-with-Ubuntu-16.04-xenial' unisphere_version = u'V9.1.0.1' openstack_release = '12.0.0.0b3.dev401' openstack_version = '12.0.0' python_version = '2.7.12' vmax_driver_version = '4.1' vmax_firmware_version = u'5977.1125.1125' vmax_model = u'VMAX250F' version_dict = { 'unisphere_for_powermax_version': unisphere_version, 'openstack_release': openstack_release, 'openstack_version': openstack_version, 'python_version': python_version, 'powermax_cinder_driver_version': vmax_driver_version, 'openstack_platform': platform, 'storage_firmware_version': vmax_firmware_version, 'serial_number': array, 'storage_model': vmax_model } u4p_failover_config = { 'u4p_failover_backoff_factor': '2', 'u4p_failover_retries': '3', 'u4p_failover_timeout': '10', 'u4p_primary': '10.10.10.10', 'u4p_failover_autofailback': 'True', 'u4p_failover_targets': [{ 'san_ip': '10.10.10.11', 'san_api_port': '8443', 'san_login': '******', 'san_password': '******', 'driver_ssl_cert_verify': '/path/to/cert', 'driver_ssl_cert_path': 'True' }, { 'san_ip': '10.10.10.12', 'san_api_port': '8443', 'san_login': '******', 'san_password': '******', 'driver_ssl_cert_verify': 'True' }, { 'san_ip': '10.10.10.11', 'san_api_port': '8443', 'san_login': '******', 'san_password': '******', 'driver_ssl_cert_verify': '/path/to/cert', 'driver_ssl_cert_path': 'False' }] } u4p_failover_target = [{ 'RestServerIp': '10.10.10.11', 'RestServerPort': '8443', 'RestUserName': '******', 'RestPassword': '******', 'SSLVerify': '/path/to/cert' }, { 'RestServerIp': '10.10.10.12', 'RestServerPort': '8443', 'RestUserName': '******', 'RestPassword': '******', 'SSLVerify': 'True' }]
def setUp(self): """Setup a test case environment. Creates a fake volume object and sets up the required API responses. """ super(TestConsistencyGroups, self).setUp() self.ctx = context.RequestContext('fake', 'fake', auth_token=True) self.consistency_group = ( fake_consistencygroup.fake_consistencyobject_obj( self.ctx, **{'id': fake.CONSISTENCY_GROUP_ID})) fake_volume1 = fake_volume.fake_volume_obj( self.ctx, **{ 'id': fake.VOLUME_ID, 'provider_id': fake.PROVIDER_ID }) fake_volume2 = fake_volume.fake_volume_obj( self.ctx, **{ 'id': fake.VOLUME2_ID, 'provider_id': fake.PROVIDER2_ID }) fake_volume3 = fake_volume.fake_volume_obj( self.ctx, **{ 'id': fake.VOLUME3_ID, 'provider_id': fake.PROVIDER3_ID }) fake_volume4 = fake_volume.fake_volume_obj( self.ctx, **{ 'id': fake.VOLUME4_ID, 'provider_id': fake.PROVIDER4_ID }) self.volumes = [fake_volume1, fake_volume2] self.volumes2 = [fake_volume3, fake_volume4] fake_snapshot1 = fake_snapshot.fake_snapshot_obj( self.ctx, **{ 'id': fake.SNAPSHOT_ID, 'volume_id': fake.VOLUME_ID, 'volume': fake_volume1 }) fake_snapshot2 = fake_snapshot.fake_snapshot_obj( self.ctx, **{ 'id': fake.SNAPSHOT2_ID, 'volume_id': fake.VOLUME2_ID, 'volume': fake_volume2 }) self.snapshots = [fake_snapshot1, fake_snapshot2] self.snapshot_reply = json.dumps({ 'volumeIdList': ['sid1', 'sid2'], 'snapshotGroupId': 'sgid1' }) self.HTTPS_MOCK_RESPONSES = { self.RESPONSE_MODE.Valid: { 'instances/Volume::{}/action/removeVolume'.format(fake_volume1['provider_id']): fake_volume1['provider_id'], 'instances/Volume::{}/action/removeVolume'.format(fake_volume2['provider_id']): fake_volume2['provider_id'], 'instances/Volume::{}/action/removeMappedSdc'.format(fake_volume1['provider_id']): fake_volume1['provider_id'], 'instances/Volume::{}/action/removeMappedSdc'.format(fake_volume2['provider_id']): fake_volume2['provider_id'], 'instances/System/action/snapshotVolumes': self.snapshot_reply, }, self.RESPONSE_MODE.BadStatus: { 'instances/Volume::{}/action/removeVolume'.format(fake_volume1['provider_id']): mocks.MockHTTPSResponse( { 'errorCode': 401, 'message': 'BadStatus Volume Test', }, 401), 'instances/Volume::{}/action/removeVolume'.format(fake_volume2['provider_id']): mocks.MockHTTPSResponse( { 'errorCode': 401, 'message': 'BadStatus Volume Test', }, 401), 'instances/System/action/snapshotVolumes': self.BAD_STATUS_RESPONSE }, }
def setUp(self): """Initialise variables and mock functions.""" super(CreateVolumeFromSnapshotTestCase, self).setUp() self.snapshot = fake_snapshot.fake_snapshot_obj( self.ctx, **{'volume': self.volume}) # Mock restoreFromSnapshot, restoreDetail # and volume detail since they are in the function path mock.patch.object(self.requester, 'restoreFromSnapshot', self.restore_request).start() mock.patch.object(self.requester, 'restoreDetail', self.restore_detail_request).start() mock.patch.object(self.requester, 'volumeDetailByName', self.volume_detail_request).start() restore_detail_response = { 'status': 0, 'restoreInfoResult': { 'restoreId': 1234, 'startTime': '', 'statusPercent': '', 'volumeName': 'aVolumeName', 'snapshotId': 1234, 'status': 0 } } self.volume_detail_response = { 'status': 0, 'volumeInfoResult': { 'volumeId': 1234567 } } rest_success = copy.deepcopy(restore_detail_response) rest_pending = copy.deepcopy(restore_detail_response) rest_fail = copy.deepcopy(restore_detail_response) rest_response_fail = copy.deepcopy(restore_detail_response) rest_success['restoreInfoResult']['status'] = ( self.DETAIL_OPTIONS['success']) rest_pending['restoreInfoResult']['status'] = ( self.DETAIL_OPTIONS['pending']) rest_fail['restoreInfoResult']['status'] = ( self.DETAIL_OPTIONS['failure']) rest_response_fail['status'] = 1 self.FAKE_RESPONSE['restore_detail'] = { 'success': rest_success, 'fail': rest_fail, 'pending': rest_pending, 'request_fail': rest_response_fail } self.response = self.FAKE_RESPONSE['standard']['success'] self.response['result'] = '1234' self.response_detail = ( self.FAKE_RESPONSE['restore_detail']['success']) self.test_pending = False self.test_pending_count = 0