From 2780283903333457f3c5a44c67f67f07104933ea Mon Sep 17 00:00:00 2001 From: Kumar Prashant Date: Tue, 18 Sep 2018 11:32:57 +0530 Subject: [PATCH] VMAX Driver - Place volume in SG as part of unmanage volume A cinder unmanage operation using the VMAX driver doesn't place the volume in any storage group on the array. This leads to querying information about the volume very difficult. The volume being unmanaged should be placed in some storage group as part of the unmanage operation Change-Id: I4fd5370005848205e1bbc9d58d8452f38719dac8 Closes-bug: 1792888 --- .../volume/drivers/dell_emc/vmax/test_vmax.py | 9 +++++++++ cinder/volume/drivers/dell_emc/vmax/common.py | 18 ++++++++++++++++++ cinder/volume/drivers/dell_emc/vmax/utils.py | 3 +++ ...aned_unmanaged_volume-db63ec0509b70b8f.yaml | 7 +++++++ 4 files changed, 37 insertions(+) create mode 100644 releasenotes/notes/orphaned_unmanaged_volume-db63ec0509b70b8f.yaml diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vmax/test_vmax.py b/cinder/tests/unit/volume/drivers/dell_emc/vmax/test_vmax.py index 6f9779c95b0..72864a988fa 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vmax/test_vmax.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vmax/test_vmax.py @@ -4979,6 +4979,15 @@ class VMAXCommonTest(test.TestCase): self.rest.rename_volume.assert_called_once_with( self.data.array, self.data.device_id, self.data.test_volume.id) + # Test for success when create storage group fails + with mock.patch.object(self.rest, 'rename_volume'): + with mock.patch.object( + self.provision, 'create_storage_group', + side_effect=exception.VolumeBackendAPIException): + self.common.unmanage(volume) + self.rest.rename_volume.assert_called_once_with( + self.data.array, self.data.device_id, + self.data.test_volume.id) def test_unmanage_device_not_found(self): volume = self.data.test_volume diff --git a/cinder/volume/drivers/dell_emc/vmax/common.py b/cinder/volume/drivers/dell_emc/vmax/common.py index 71fd6677fd2..8f85ee46dc1 100644 --- a/cinder/volume/drivers/dell_emc/vmax/common.py +++ b/cinder/volume/drivers/dell_emc/vmax/common.py @@ -2163,6 +2163,24 @@ class VMAXCommon(object): # Rename the volume to volumeId, thus remove the 'OS-' prefix. self.rest.rename_volume( extra_specs[utils.ARRAY], device_id, volume_id) + # First check/create the unmanaged sg + # Don't fail if we fail to create the SG + try: + self.provision.create_storage_group( + extra_specs[utils.ARRAY], utils.UNMANAGED_SG, + extra_specs[utils.SRP], None, + None, extra_specs=extra_specs) + except Exception as e: + msg = ("Exception creating %(sg)s. " + "Exception received was %(e)s." + % {'sg': utils.UNMANAGED_SG, + 'e': six.text_type(e)}) + LOG.warning(msg) + return + # Try to add the volume + self.masking._check_adding_volume_to_storage_group( + extra_specs[utils.ARRAY], device_id, utils.UNMANAGED_SG, + volume_id, extra_specs) def manage_existing_snapshot(self, snapshot, existing_ref): """Manage an existing VMAX Snapshot (import to Cinder). diff --git a/cinder/volume/drivers/dell_emc/vmax/utils.py b/cinder/volume/drivers/dell_emc/vmax/utils.py index 7543d358335..277632ed273 100644 --- a/cinder/volume/drivers/dell_emc/vmax/utils.py +++ b/cinder/volume/drivers/dell_emc/vmax/utils.py @@ -81,6 +81,9 @@ OTHER_PARENT_SG = 'other_parent_sg_name' FAST_SG = 'fast_managed_sg' NO_SLO_SG = 'no_slo_sg' +# SG for unmanaged volumes +UNMANAGED_SG = 'OS-Unmanaged' + # Cinder.conf vmax configuration VMAX_SERVER_IP = 'san_ip' VMAX_USER_NAME = 'san_login' diff --git a/releasenotes/notes/orphaned_unmanaged_volume-db63ec0509b70b8f.yaml b/releasenotes/notes/orphaned_unmanaged_volume-db63ec0509b70b8f.yaml new file mode 100644 index 00000000000..5e4a8216104 --- /dev/null +++ b/releasenotes/notes/orphaned_unmanaged_volume-db63ec0509b70b8f.yaml @@ -0,0 +1,7 @@ +--- +other: + - | + This PowerMax driver now puts the unmanaged "orphan" volume in a storage + group called OS-Unmanaged. It is not possible to query a volume's + associated snapvx snapshots using the PowerMax management software, unless + it belongs to a storage group.