]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fixes creating volume issue for multiple management IPs
authorstack <yixuan_z@hotmail.com>
Fri, 4 Mar 2016 09:13:06 +0000 (04:13 -0500)
committerstack <yixuan_z@hotmail.com>
Tue, 8 Mar 2016 08:19:00 +0000 (03:19 -0500)
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

cinder/tests/unit/test_storwize_svc.py
cinder/volume/drivers/ibm/storwize_svc/storwize_svc_common.py

index 492e2a8b221f8bee84163931ab139525c6d2df7f..970555c3b3789648c4afc10c1c84ccdc021b1e58 100644 (file)
@@ -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))
index 34ce1a334ca330098520131aef01aa3a38341d45..4a9993671af5a6d70d0745e536c6425564683eee 100644 (file)
@@ -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 '