From bbdcfcc08cb88738c6eec26ba53f49e1a3cd95fc Mon Sep 17 00:00:00 2001 From: Ryan Liang Date: Tue, 27 Jun 2017 17:29:41 +0800 Subject: [PATCH] VNX: share server cannot be deleted The output of share server's interface changed. The VNX driver failed to detect the NFS interface of share server. So the detach of interface was skipped, and deletion of share server failed because some interface was still attached. Closes-bug: 1700727 Change-Id: I07d7be889d565249e3542925d2ad404106752d3d (cherry picked from commit 619e22e5a6663a97bb1af5a19b4027ff1f4cbe53) --- .../dell_emc/plugins/vnx/object_manager.py | 3 +- .../drivers/dell_emc/plugins/vnx/fakes.py | 30 +++++++++++++++++-- .../dell_emc/plugins/vnx/test_connection.py | 12 ++++---- .../plugins/vnx/test_object_manager.py | 11 ++++--- ...erver-delete-failure-ca29d6b286a2c790.yaml | 5 ++++ 5 files changed, 48 insertions(+), 13 deletions(-) create mode 100644 releasenotes/notes/share-server-delete-failure-ca29d6b286a2c790.yaml diff --git a/manila/share/drivers/dell_emc/plugins/vnx/object_manager.py b/manila/share/drivers/dell_emc/plugins/vnx/object_manager.py index 47cf3aa52f..b90e3ce8d4 100644 --- a/manila/share/drivers/dell_emc/plugins/vnx/object_manager.py +++ b/manila/share/drivers/dell_emc/plugins/vnx/object_manager.py @@ -1015,7 +1015,8 @@ class VDM(StorageObject): if_name = m_if.group('if').strip() if 'cifs' == m_if.group('type') and if_name != '': interfaces['cifs'].append(if_name) - elif 'vdm' == m_if.group('type') and if_name != '': + elif (m_if.group('type') in ('vdm', 'nfs') + and if_name != ''): interfaces['nfs'].append(if_name) return interfaces diff --git a/manila/tests/share/drivers/dell_emc/plugins/vnx/fakes.py b/manila/tests/share/drivers/dell_emc/plugins/vnx/fakes.py index 738eeb304f..bbcb358ced 100644 --- a/manila/tests/share/drivers/dell_emc/plugins/vnx/fakes.py +++ b/manila/tests/share/drivers/dell_emc/plugins/vnx/fakes.py @@ -758,8 +758,9 @@ class VDMTestData(StorageObjectTestData): '-vdm', self.vdm_name, ] - def output_get_interfaces(self, cifs_interface=FakeData.interface_name1, - nfs_interface=FakeData.interface_name2): + def output_get_interfaces_vdm(self, + cifs_interface=FakeData.interface_name1, + nfs_interface=FakeData.interface_name2): return ( """id = %(vdmid)s name = %(name)s @@ -782,6 +783,31 @@ class VDMTestData(StorageObjectTestData): 'cifs_if_name': cifs_interface} ) + def output_get_interfaces_nfs(self, + cifs_interface=FakeData.interface_name1, + nfs_interface=FakeData.interface_name2): + return ( + """id = %(vdmid)s + name = %(name)s + acl = 0 + type = vdm + server = server_2 + rootfs = root_fs_vdm_vdm-fakeid + I18N mode = UNICODE + mountedfs = + member_of = + status : + defined = enabled + actual = loaded, active + Interfaces to services mapping: + interface=%(nfs_if_name)s :nfs + interface=%(cifs_if_name)s :cifs""" % + {'vdmid': self.vdm_id, + 'name': self.vdm_name, + 'nfs_if_name': nfs_interface, + 'cifs_if_name': cifs_interface} + ) + class PoolTestData(StorageObjectTestData): def __init__(self): diff --git a/manila/tests/share/drivers/dell_emc/plugins/vnx/test_connection.py b/manila/tests/share/drivers/dell_emc/plugins/vnx/test_connection.py index d291f8769c..c31013b687 100644 --- a/manila/tests/share/drivers/dell_emc/plugins/vnx/test_connection.py +++ b/manila/tests/share/drivers/dell_emc/plugins/vnx/test_connection.py @@ -716,7 +716,7 @@ class StorageConnectionTestCase(test.TestCase): xml_req_mock = utils.EMCMock(side_effect=hook) self.connection.manager.connectors['XML'].request = xml_req_mock ssh_hook = utils.SSHSideEffect() - ssh_hook.append(self.vdm.output_get_interfaces(nfs_interface='')) + ssh_hook.append(self.vdm.output_get_interfaces_vdm(nfs_interface='')) ssh_cmd_mock = mock.Mock(side_effect=ssh_hook) self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock @@ -755,7 +755,7 @@ class StorageConnectionTestCase(test.TestCase): self.connection.manager.connectors['XML'].request = xml_req_mock ssh_hook = utils.SSHSideEffect() - ssh_hook.append(self.vdm.output_get_interfaces(nfs_interface='')) + ssh_hook.append(self.vdm.output_get_interfaces_vdm(nfs_interface='')) ssh_cmd_mock = mock.Mock(side_effect=ssh_hook) self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock @@ -805,7 +805,7 @@ class StorageConnectionTestCase(test.TestCase): self.connection.manager.connectors['XML'].request = xml_req_mock ssh_hook = utils.SSHSideEffect() - ssh_hook.append(self.vdm.output_get_interfaces()) + ssh_hook.append(self.vdm.output_get_interfaces_vdm()) ssh_hook.append() ssh_cmd_mock = mock.Mock(side_effect=ssh_hook) self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock @@ -848,7 +848,7 @@ class StorageConnectionTestCase(test.TestCase): self.connection.manager.connectors['XML'].request = xml_req_mock ssh_hook = utils.SSHSideEffect() - ssh_hook.append(self.vdm.output_get_interfaces()) + ssh_hook.append(self.vdm.output_get_interfaces_vdm()) ssh_hook.append() ssh_cmd_mock = mock.Mock(side_effect=ssh_hook) self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock @@ -906,7 +906,7 @@ class StorageConnectionTestCase(test.TestCase): self.connection.manager.connectors['XML'].request = xml_req_mock ssh_hook = utils.SSHSideEffect() - ssh_hook.append(self.vdm.output_get_interfaces()) + ssh_hook.append(self.vdm.output_get_interfaces_vdm()) ssh_hook.append() ssh_cmd_mock = mock.Mock(side_effect=ssh_hook) self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock @@ -947,7 +947,7 @@ class StorageConnectionTestCase(test.TestCase): self.connection.manager.connectors['XML'].request = xml_req_mock ssh_hook = utils.SSHSideEffect() - ssh_hook.append(self.vdm.output_get_interfaces()) + ssh_hook.append(self.vdm.output_get_interfaces_vdm()) ssh_hook.append() ssh_cmd_mock = mock.Mock(side_effect=ssh_hook) self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock diff --git a/manila/tests/share/drivers/dell_emc/plugins/vnx/test_object_manager.py b/manila/tests/share/drivers/dell_emc/plugins/vnx/test_object_manager.py index 03d895d8df..ac65762714 100644 --- a/manila/tests/share/drivers/dell_emc/plugins/vnx/test_object_manager.py +++ b/manila/tests/share/drivers/dell_emc/plugins/vnx/test_object_manager.py @@ -851,6 +851,7 @@ class MountPointTestCase(StorageObjectTestCaseBase): context.conn['XML'].request.assert_has_calls(expected_calls) +@ddt.ddt class VDMTestCase(StorageObjectTestCaseBase): def setUp(self): super(self.__class__, self).setUp() @@ -1075,11 +1076,11 @@ class VDMTestCase(StorageObjectTestCaseBase): def test_detach_nfs_interface_with_error(self): self.ssh_hook.append(ex=processutils.ProcessExecutionError( stdout=self.vdm.fake_output)) - self.ssh_hook.append(self.vdm.output_get_interfaces( + self.ssh_hook.append(self.vdm.output_get_interfaces_vdm( self.mover.interface_name2)) self.ssh_hook.append(ex=processutils.ProcessExecutionError( stdout=self.vdm.fake_output)) - self.ssh_hook.append(self.vdm.output_get_interfaces( + self.ssh_hook.append(self.vdm.output_get_interfaces_vdm( nfs_interface=fakes.FakeData.interface_name1)) context = self.manager.getStorageContext('VDM') @@ -1101,8 +1102,10 @@ class VDMTestCase(StorageObjectTestCaseBase): ] context.conn['SSH'].run_ssh.assert_has_calls(ssh_calls) - def test_get_cifs_nfs_interface(self): - self.ssh_hook.append(self.vdm.output_get_interfaces()) + @ddt.data(fakes.VDMTestData().output_get_interfaces_vdm(), + fakes.VDMTestData().output_get_interfaces_nfs()) + def test_get_cifs_nfs_interface(self, fake_output): + self.ssh_hook.append(fake_output) context = self.manager.getStorageContext('VDM') context.conn['SSH'].run_ssh = mock.Mock(side_effect=self.ssh_hook) diff --git a/releasenotes/notes/share-server-delete-failure-ca29d6b286a2c790.yaml b/releasenotes/notes/share-server-delete-failure-ca29d6b286a2c790.yaml new file mode 100644 index 0000000000..0f14c4d50b --- /dev/null +++ b/releasenotes/notes/share-server-delete-failure-ca29d6b286a2c790.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - Fix the issue of deleting share server in VNX driver. The VNX driver failed + to detect the NFS interface of share server, so the detach and deletion of + NFS interface were skipped.