]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Storwize/SVC can not get the right host
authorLi Min Liu <liminliu@cn.ibm.com>
Tue, 29 Jul 2014 06:03:40 +0000 (14:03 +0800)
committerLi Min Liu <liminliu@cn.ibm.com>
Wed, 30 Jul 2014 02:42:53 +0000 (10:42 +0800)
When only config FC host, Storwize/SVC driver can not get the host
by remote WWPNs except the first one.

Filter 'iscsi_name' and 'WWPN' from host information, if not configure
iSCSI port, only return the first WWPN.

Change-Id: I27852e49f5dfb3a94eed08bea0e5d81a9d7aef9c
Closes-Bug: #1343142

cinder/tests/test_storwize_svc.py
cinder/volume/drivers/ibm/storwize_svc/helpers.py

index abcc47ec0e98072cf544ab99589fee10e01542ae..475f7ad2a2417027e4632a8a9a9e7c692a741a46 100644 (file)
@@ -2394,6 +2394,19 @@ class StorwizeSVCDriverTestCase(test.TestCase):
             self.driver.delete_volume(volume)
             self.assertNotIn(volume['id'], self.driver._vdiskcopyops)
 
+    def test_storwize_get_host_with_fc_connection(self):
+        # Create a FC host
+        del self._connector['initiator']
+        helper = self.driver._helpers
+        host_name = helper.create_host(self._connector)
+
+        # Remove the first wwpn from connector, and then try get host
+        wwpns = self._connector['wwpns']
+        wwpns.remove(wwpns[0])
+        host_name = helper.get_host_from_connector(self._connector)
+
+        self.assertIsNotNone(host_name)
+
     def test_storwize_initiator_multiple_preferred_nodes_matching(self):
 
         # Generate us a test volume
index a25f4831b196762639315a2b4bbbd93c8631a17f..14ad82d05b16cc7e4623558471409d70407bdeb2 100644 (file)
@@ -194,21 +194,30 @@ class StorwizeHelpers(object):
                     except KeyError:
                         self.handle_keyerror('lsfabric', wwpn_info)
 
+        if host_name:
+            LOG.debug('leave: get_host_from_connector: host %s' % host_name)
+            return host_name
+
         # That didn't work, so try exhaustive search
-        if host_name is None:
-            hosts_info = self.ssh.lshost()
-            for name in hosts_info.select('name'):
-                resp = self.ssh.lshost(host=name)
-                for iscsi, wwpn in resp.select('iscsi_name', 'WWPN'):
-                    if ('initiator' in connector and
-                            iscsi == connector['initiator']):
+        hosts_info = self.ssh.lshost()
+        found = False
+        for name in hosts_info.select('name'):
+            resp = self.ssh.lshost(host=name)
+            if 'initiator' in connector:
+                for iscsi in resp.select('iscsi_name'):
+                    if iscsi == connector['initiator']:
                         host_name = name
-                    elif ('wwpns' in connector and
-                          len(connector['wwpns']) and
-                          wwpn and
-                          wwpn.lower() in
-                          [str(x).lower() for x in connector['wwpns']]):
+                        found = True
+                        break
+            elif 'wwpns' in connector and len(connector['wwpns']):
+                connector_wwpns = [str(x).lower() for x in connector['wwpns']]
+                for wwpn in resp.select('WWPN'):
+                    if wwpn and wwpn.lower() in connector_wwpns:
                         host_name = name
+                        found = True
+                        break
+            if found:
+                break
 
         LOG.debug('leave: get_host_from_connector: host %s' % host_name)
         return host_name