Merge "EMC: Fix bugs when domain controller is not available"

This commit is contained in:
Jenkins 2015-12-04 08:05:34 +00:00 committed by Gerrit Code Review
commit b7188a21d2
5 changed files with 71 additions and 15 deletions

View File

@ -597,8 +597,13 @@ class VNXStorageConnection(driver.StorageConnection):
'is_vdm': True,
}
self._get_context('CIFSServer').modify(
cifs_server_args)
try:
self._get_context('CIFSServer').modify(
cifs_server_args)
except exception.EMCVnxXMLAPIError as expt:
LOG.debug("Failed to modify CIFS server "
"%(server)s. Reason: %(err)s.",
{'server': server, 'err': expt})
self._get_context('CIFSServer').delete(name, vdm_name)

View File

@ -1766,7 +1766,7 @@ class NFSShare(StorageObject):
self.nfs_share_map.pop(name)
def get(self, name, mover_name, force=False):
def get(self, name, mover_name, force=False, check_exit_code=False):
if name in self.nfs_share_map and not force:
return constants.STATUS_OK, self.nfs_share_map[name]
@ -1789,7 +1789,8 @@ class NFSShare(StorageObject):
]
try:
out, err = self._execute_cmd(nfs_query_cmd, check_exit_code=True)
out, err = self._execute_cmd(nfs_query_cmd,
check_exit_code=check_exit_code)
except processutils.ProcessExecutionError as expt:
dup_msg = (r'%(mover_name)s : No such file or directory' %
{'mover_name': mover_name})
@ -1824,6 +1825,8 @@ class NFSShare(StorageObject):
nfs_share['RoHosts'] = field[3:].split(":")
self.nfs_share_map[name] = nfs_share
else:
return constants.STATUS_NOT_FOUND, None
return constants.STATUS_OK, self.nfs_share_map[name]
@ -1877,7 +1880,7 @@ class NFSShare(StorageObject):
accesshosts)
# Update self.nfs_share_map
self.get(share_name, mover_name, True)
self.get(share_name, mover_name, True, True)
do_allow_access(share_name, host_ip, mover_name, access_level)
@ -1923,7 +1926,7 @@ class NFSShare(StorageObject):
accesshosts)
# Update self.nfs_share_map
self.get(share_name, mover_name, True)
self.get(share_name, mover_name, True, True)
do_deny_access(share_name, host_ip, mover_name)

View File

@ -1107,7 +1107,7 @@ class CIFSServerTestData(StorageObjectTestData):
)
@start_task
def req_modify(self, mover_id, is_vdm, join_domain):
def req_modify(self, mover_id, is_vdm=True, join_domain=False):
return (
'<ModifyW2KCifsServer mover="%(mover_id)s" '
'moverIdIsVdm="%(is_vdm)s" name="%(cifsserver)s">'

View File

@ -405,7 +405,7 @@ class StorageConnectionTestCase(test.TestCase):
xml_req_mock.assert_has_calls(expected_calls)
ssh_calls = [
mock.call(self.nfs_share.cmd_get(), True),
mock.call(self.nfs_share.cmd_get(), False),
mock.call(self.nfs_share.cmd_delete(), True),
]
ssh_cmd_mock.assert_has_calls(ssh_calls)
@ -806,6 +806,47 @@ class StorageConnectionTestCase(test.TestCase):
]
ssh_cmd_mock.assert_has_calls(ssh_calls)
def test_teardown_server_with_invalid_cifs_server_modification(self):
hook = utils.RequestSideEffect()
hook.append(self.vdm.resp_get_succeed())
hook.append(self.cifs_server.resp_get_succeed(
mover_id=self.vdm.vdm_id, is_vdm=True, join_domain=True))
hook.append(self.cifs_server.resp_task_error())
hook.append(self.cifs_server.resp_task_succeed())
hook.append(self.mover.resp_task_succeed())
hook.append(self.mover.resp_task_succeed())
hook.append(self.vdm.resp_task_succeed())
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())
ssh_hook.append()
ssh_cmd_mock = mock.Mock(side_effect=ssh_hook)
self.connection.manager.connectors['SSH'].run_ssh = ssh_cmd_mock
self.connection.teardown_server(fakes.SERVER_DETAIL,
fakes.SECURITY_SERVICE)
expected_calls = [
mock.call(self.vdm.req_get()),
mock.call(self.cifs_server.req_get(self.vdm.vdm_id)),
mock.call(self.cifs_server.req_modify(self.vdm.vdm_id)),
mock.call(self.cifs_server.req_delete(self.vdm.vdm_id)),
mock.call(self.mover.req_delete_interface(
fakes.FakeData.network_allocations_ip1)),
mock.call(self.mover.req_delete_interface(
fakes.FakeData.network_allocations_ip2)),
mock.call(self.vdm.req_delete()),
]
xml_req_mock.assert_has_calls(expected_calls)
ssh_calls = [
mock.call(self.vdm.cmd_get_interfaces(), False),
mock.call(self.vdm.cmd_detach_nfs_interface(), True),
]
ssh_cmd_mock.assert_has_calls(ssh_calls)
def test_allow_cifs_rw_access(self):
share_server = fakes.SHARE_SERVER
share = fakes.CIFS_SHARE

View File

@ -2732,7 +2732,7 @@ class NFSShareTestCase(StorageObjectTestCase):
mover_name=self.vdm.vdm_name)
ssh_calls = [
mock.call(self.nfs_share.cmd_get(), True),
mock.call(self.nfs_share.cmd_get(), False),
mock.call(self.nfs_share.cmd_delete(), True),
]
context.conn['SSH'].run_ssh.assert_has_calls(ssh_calls)
@ -2748,7 +2748,7 @@ class NFSShareTestCase(StorageObjectTestCase):
context.delete(name=self.nfs_share.share_name,
mover_name=self.vdm.vdm_name)
ssh_calls = [mock.call(self.nfs_share.cmd_get(), True)]
ssh_calls = [mock.call(self.nfs_share.cmd_get(), False)]
context.conn['SSH'].run_ssh.assert_has_calls(ssh_calls)
@mock.patch('time.sleep')
@ -2768,7 +2768,7 @@ class NFSShareTestCase(StorageObjectTestCase):
mover_name=self.vdm.vdm_name)
ssh_calls = [
mock.call(self.nfs_share.cmd_get(), True),
mock.call(self.nfs_share.cmd_get(), False),
mock.call(self.nfs_share.cmd_delete(), True),
mock.call(self.nfs_share.cmd_delete(), True),
]
@ -2793,7 +2793,7 @@ class NFSShareTestCase(StorageObjectTestCase):
mover_name=self.vdm.vdm_name)
ssh_calls = [
mock.call(self.nfs_share.cmd_get(), True),
mock.call(self.nfs_share.cmd_get(), False),
mock.call(self.nfs_share.cmd_delete(), True),
]
context.conn['SSH'].run_ssh.assert_has_calls(ssh_calls)
@ -2813,13 +2813,14 @@ class NFSShareTestCase(StorageObjectTestCase):
context.get(name=self.nfs_share.share_name,
mover_name=self.vdm.vdm_name)
ssh_calls = [mock.call(self.nfs_share.cmd_get(), True)]
ssh_calls = [mock.call(self.nfs_share.cmd_get(), False)]
context.conn['SSH'].run_ssh.assert_has_calls(ssh_calls)
def test_get_nfs_share_not_found(self):
expt_not_found = processutils.ProcessExecutionError(
stdout=self.nfs_share.output_get_but_not_found())
self.ssh_hook.append(ex=expt_not_found)
self.ssh_hook.append(self.nfs_share.output_get_but_not_found())
context = self.manager.getStorageContext('NFSShare')
context.conn['SSH'].run_ssh = mock.Mock(side_effect=self.ssh_hook)
@ -2827,7 +2828,13 @@ class NFSShareTestCase(StorageObjectTestCase):
context.get(name=self.nfs_share.share_name,
mover_name=self.vdm.vdm_name)
ssh_calls = [mock.call(self.nfs_share.cmd_get(), True)]
context.get(name=self.nfs_share.share_name,
mover_name=self.vdm.vdm_name)
ssh_calls = [
mock.call(self.nfs_share.cmd_get(), False),
mock.call(self.nfs_share.cmd_get(), False),
]
context.conn['SSH'].run_ssh.assert_has_calls(ssh_calls)
def test_get_nfs_share_with_error(self):
@ -2843,7 +2850,7 @@ class NFSShareTestCase(StorageObjectTestCase):
name=self.nfs_share.share_name,
mover_name=self.vdm.vdm_name)
ssh_calls = [mock.call(self.nfs_share.cmd_get(), True)]
ssh_calls = [mock.call(self.nfs_share.cmd_get(), False)]
context.conn['SSH'].run_ssh.assert_has_calls(ssh_calls)
def test_allow_share_access(self):