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
This commit is contained in:
Ryan Liang 2017-06-27 17:29:41 +08:00
parent 8e6c4c6351
commit 619e22e5a6
5 changed files with 48 additions and 13 deletions

View File

@ -1015,7 +1015,8 @@ class VDM(StorageObject):
if_name = m_if.group('if').strip() if_name = m_if.group('if').strip()
if 'cifs' == m_if.group('type') and if_name != '': if 'cifs' == m_if.group('type') and if_name != '':
interfaces['cifs'].append(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) interfaces['nfs'].append(if_name)
return interfaces return interfaces

View File

@ -758,8 +758,9 @@ class VDMTestData(StorageObjectTestData):
'-vdm', self.vdm_name, '-vdm', self.vdm_name,
] ]
def output_get_interfaces(self, cifs_interface=FakeData.interface_name1, def output_get_interfaces_vdm(self,
nfs_interface=FakeData.interface_name2): cifs_interface=FakeData.interface_name1,
nfs_interface=FakeData.interface_name2):
return ( return (
"""id = %(vdmid)s """id = %(vdmid)s
name = %(name)s name = %(name)s
@ -782,6 +783,31 @@ class VDMTestData(StorageObjectTestData):
'cifs_if_name': cifs_interface} '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): class PoolTestData(StorageObjectTestData):
def __init__(self): def __init__(self):

View File

@ -716,7 +716,7 @@ class StorageConnectionTestCase(test.TestCase):
xml_req_mock = utils.EMCMock(side_effect=hook) xml_req_mock = utils.EMCMock(side_effect=hook)
self.connection.manager.connectors['XML'].request = xml_req_mock self.connection.manager.connectors['XML'].request = xml_req_mock
ssh_hook = utils.SSHSideEffect() 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) ssh_cmd_mock = mock.Mock(side_effect=ssh_hook)
self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock 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 self.connection.manager.connectors['XML'].request = xml_req_mock
ssh_hook = utils.SSHSideEffect() 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) ssh_cmd_mock = mock.Mock(side_effect=ssh_hook)
self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock 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 self.connection.manager.connectors['XML'].request = xml_req_mock
ssh_hook = utils.SSHSideEffect() 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_hook.append()
ssh_cmd_mock = mock.Mock(side_effect=ssh_hook) ssh_cmd_mock = mock.Mock(side_effect=ssh_hook)
self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock 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 self.connection.manager.connectors['XML'].request = xml_req_mock
ssh_hook = utils.SSHSideEffect() 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_hook.append()
ssh_cmd_mock = mock.Mock(side_effect=ssh_hook) ssh_cmd_mock = mock.Mock(side_effect=ssh_hook)
self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock 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 self.connection.manager.connectors['XML'].request = xml_req_mock
ssh_hook = utils.SSHSideEffect() 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_hook.append()
ssh_cmd_mock = mock.Mock(side_effect=ssh_hook) ssh_cmd_mock = mock.Mock(side_effect=ssh_hook)
self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock 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 self.connection.manager.connectors['XML'].request = xml_req_mock
ssh_hook = utils.SSHSideEffect() 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_hook.append()
ssh_cmd_mock = mock.Mock(side_effect=ssh_hook) ssh_cmd_mock = mock.Mock(side_effect=ssh_hook)
self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock

View File

@ -853,6 +853,7 @@ class MountPointTestCase(StorageObjectTestCaseBase):
context.conn['XML'].request.assert_has_calls(expected_calls) context.conn['XML'].request.assert_has_calls(expected_calls)
@ddt.ddt
class VDMTestCase(StorageObjectTestCaseBase): class VDMTestCase(StorageObjectTestCaseBase):
def setUp(self): def setUp(self):
super(self.__class__, self).setUp() super(self.__class__, self).setUp()
@ -1077,11 +1078,11 @@ class VDMTestCase(StorageObjectTestCaseBase):
def test_detach_nfs_interface_with_error(self): def test_detach_nfs_interface_with_error(self):
self.ssh_hook.append(ex=processutils.ProcessExecutionError( self.ssh_hook.append(ex=processutils.ProcessExecutionError(
stdout=self.vdm.fake_output)) 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.mover.interface_name2))
self.ssh_hook.append(ex=processutils.ProcessExecutionError( self.ssh_hook.append(ex=processutils.ProcessExecutionError(
stdout=self.vdm.fake_output)) 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)) nfs_interface=fakes.FakeData.interface_name1))
context = self.manager.getStorageContext('VDM') context = self.manager.getStorageContext('VDM')
@ -1103,8 +1104,10 @@ class VDMTestCase(StorageObjectTestCaseBase):
] ]
context.conn['SSH'].run_ssh.assert_has_calls(ssh_calls) context.conn['SSH'].run_ssh.assert_has_calls(ssh_calls)
def test_get_cifs_nfs_interface(self): @ddt.data(fakes.VDMTestData().output_get_interfaces_vdm(),
self.ssh_hook.append(self.vdm.output_get_interfaces()) 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 = self.manager.getStorageContext('VDM')
context.conn['SSH'].run_ssh = mock.Mock(side_effect=self.ssh_hook) context.conn['SSH'].run_ssh = mock.Mock(side_effect=self.ssh_hook)

View File

@ -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.