From: stack Date: Fri, 4 Mar 2016 09:13:06 +0000 (-0500) Subject: Fixes creating volume issue for multiple management IPs X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=acd274da023179508be12e1a9e43b945a20ddc74;p=openstack-build%2Fcinder-build.git Fixes creating volume issue for multiple management IPs Currently there is an issue with the multiple management IPs in Storwize SVC where volume creation would fail when storwize_san_sencondory_ip switch to san_ip. This patch adds a condition to check the sshpool.ip, if the sshpool.ip equals to storwize_san_sencondory_ip, switch it back to san_ip. Change-Id: I44f056b59109db24441c62a55f3da35424cade3a Closes-Bug: 1553045 --- diff --git a/cinder/tests/unit/test_storwize_svc.py b/cinder/tests/unit/test_storwize_svc.py index 492e2a8b2..970555c3b 100644 --- a/cinder/tests/unit/test_storwize_svc.py +++ b/cinder/tests/unit/test_storwize_svc.py @@ -2742,6 +2742,30 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase): min_size=self._driver.configuration.ssh_min_pool_conn, max_size=self._driver.configuration.ssh_max_pool_conn) + @mock.patch.object(ssh_utils, 'SSHPool') + @mock.patch.object(processutils, 'ssh_execute') + def test_run_secondary_ip_ssh_fail_to_san_ip(self, mock_ssh_execute, + mock_ssh_pool): + mock_ssh_pool.side_effect = [ + paramiko.SSHException, + mock.MagicMock( + ip = self._driver.configuration.storwize_san_secondary_ip), + mock.MagicMock()] + mock_ssh_execute.side_effect = [processutils.ProcessExecutionError, + mock.MagicMock()] + ssh_cmd = ['svcinfo'] + self._driver._run_ssh(ssh_cmd) + + mock_ssh_pool.assert_called_with( + self._driver.configuration.san_ip, + self._driver.configuration.san_ssh_port, + self._driver.configuration.ssh_conn_timeout, + self._driver.configuration.san_login, + password=self._driver.configuration.san_password, + privatekey=self._driver.configuration.san_private_key, + min_size=self._driver.configuration.ssh_min_pool_conn, + max_size=self._driver.configuration.ssh_max_pool_conn) + def _generate_vol_info(self, vol_name, vol_id): pool = _get_test_pool() rand_id = six.text_type(random.randint(10000, 99999)) diff --git a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py index 34ce1a334..4a9993671 100644 --- a/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py +++ b/cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py @@ -2007,14 +2007,25 @@ class StorwizeSVCCommonDriver(san.SanDriver, # before raising an error. if self.configuration.storwize_san_secondary_ip is not None: - - LOG.warning(_LW("Unable to execute SSH command. " - "Attempting to switch IP to %s."), - self.configuration.storwize_san_secondary_ip) - self.sshpool = self._set_up_sshpool( - self.configuration.storwize_san_secondary_ip) - return self._ssh_execute(self.sshpool, command, - check_exit_code, attempts) + if (self.sshpool.ip == + self.configuration.storwize_san_secondary_ip): + LOG.warning(_LW("Unable to execute SSH command with " + "storwize_san_secondary_ip. " + "Attempting to switch IP back " + "to san_ip %s."), + self.configuration.san_ip) + self.sshpool = self._set_up_sshpool( + self.configuration.san_ip) + return self._ssh_execute(self.sshpool, command, + check_exit_code, attempts) + else: + LOG.warning(_LW("Unable to execute SSH command. " + "Attempting to switch IP to %s."), + self.configuration.storwize_san_secondary_ip) + self.sshpool = self._set_up_sshpool( + self.configuration.storwize_san_secondary_ip) + return self._ssh_execute(self.sshpool, command, + check_exit_code, attempts) else: LOG.warning(_LW('Unable to execute SSH command. ' 'Not able to use '