]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Switch SVC driver to use lsportfc to determine FC target WWPNS
authorGerald McBrearty <gfm@us.ibm.com>
Thu, 3 Sep 2015 03:08:54 +0000 (22:08 -0500)
committerGerald McBrearty <gfm@us.ibm.com>
Thu, 3 Sep 2015 19:05:13 +0000 (14:05 -0500)
Switched the startup code within SVC driver to use the
SVC lsportfc command rather than the lsnode command to determine the
target WWPNs for an SVC node, and updated SVC testcases.
The SVC lsportfc command returns all of the FC ports so that
all of the FC ports can be zoned and thus utilized by
the VM that a volume is attached to.
Where the lsnode command is documented to only report the
first 4 FC ports.

Closes-Bug: 1490041

Change-Id: I6acac0080a96a5b3dfbc6fb8b54a456206b21688

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

index 6b16eed8af39945fbc505421d39ced68f2dced5a..73c0167071665d863f72f32280d50edef2d6e21d 100644 (file)
@@ -463,6 +463,48 @@ port_speed!N/A
         stdout = node_infos.get(node_id, '')
         return stdout, ''
 
+    # Print made up stuff for the ports
+    def _cmd_lsportfc(self, **kwargs):
+        node_1 = [None] * 7
+        node_1[0] = ['id', 'fc_io_port_id', 'port_id', 'type',
+                     'port_speed', 'node_id', 'node_name', 'WWPN',
+                     'nportid', 'status', 'attachment']
+        node_1[1] = ['0', '1', '1', 'fc', '8Gb', '1', 'node1',
+                     '5005076802132ADE', '012E00', 'active', 'switch']
+        node_1[2] = ['1', '2', '2', 'fc', '8Gb', '1', 'node1',
+                     '5005076802232ADE', '012E00', 'active', 'switch']
+        node_1[3] = ['2', '3', '3', 'fc', '8Gb', '1', 'node1',
+                     '5005076802332ADE', '9B0600', 'active', 'switch']
+        node_1[4] = ['3', '4', '4', 'fc', '8Gb', '1', 'node1',
+                     '5005076802432ADE', '012A00', 'active', 'switch']
+        node_1[5] = ['4', '5', '5', 'fc', '8Gb', '1', 'node1',
+                     '5005076802532ADE', '014A00', 'active', 'switch']
+        node_1[6] = ['5', '6', '4', 'ethernet', 'N/A', '1', 'node1',
+                     '5005076802632ADE', '000000',
+                     'inactive_unconfigured', 'none']
+
+        node_2 = [None] * 7
+        node_2[0] = ['id', 'fc_io_port_id', 'port_id', 'type',
+                     'port_speed', 'node_id', 'node_name', 'WWPN',
+                     'nportid', 'status', 'attachment']
+        node_2[1] = ['6', '7', '7', 'fc', '8Gb', '2', 'node2',
+                     '5005086802132ADE', '012E00', 'active', 'switch']
+        node_2[2] = ['7', '8', '8', 'fc', '8Gb', '2', 'node2',
+                     '5005086802232ADE', '012E00', 'active', 'switch']
+        node_2[3] = ['8', '9', '9', 'fc', '8Gb', '2', 'node2',
+                     '5005086802332ADE', '9B0600', 'active', 'switch']
+        node_2[4] = ['9', '10', '10', 'fc', '8Gb', '2', 'node2',
+                     '5005086802432ADE', '012A00', 'active', 'switch']
+        node_2[5] = ['10', '11', '11', 'fc', '8Gb', '2', 'node2',
+                     '5005086802532ADE', '014A00', 'active', 'switch']
+        node_2[6] = ['11', '12', '12', 'ethernet', 'N/A', '2', 'node2',
+                     '5005086802632ADE', '000000',
+                     'inactive_unconfigured', 'none']
+        node_infos = [node_1, node_2]
+        node_id = int(kwargs['filtervalue'].split('=')[1]) - 1
+
+        return self._print_info_cmd(rows=node_infos[node_id], **kwargs)
+
     # Print mostly made-up stuff in the correct syntax
     def _cmd_lsportip(self, **kwargs):
         if self._next_cmd_error['lsportip'] == 'ip_no_config':
@@ -2339,7 +2381,7 @@ class StorwizeSVCDriverTestCase(test.TestCase):
                     expected_fc_npiv = {
                         'driver_volume_type': 'fibre_channel',
                         'data': {'target_lun': 1,
-                                 'target_wwn': '500507680220C744',
+                                 'target_wwn': '5005076802432ADE',
                                  'target_discovered': False}}
                     ret = self.driver.initialize_connection(volume2,
                                                             self._connector)
@@ -3458,15 +3500,29 @@ class StorwizeSVCDriverTestCase(test.TestCase):
         # Check that the initiator_target_map is as expected
         init_data = {'driver_volume_type': 'fibre_channel',
                      'data': {'initiator_target_map':
-                              {'ff00000000000000': ['500507680220C744',
-                                                    '500507680210C744',
-                                                    '500507680220C745'],
-                               'ff00000000000001': ['500507680220C744',
-                                                    '500507680210C744',
-                                                    '500507680220C745']},
+                              {'ff00000000000000': ['5005076802432ADE',
+                                                    '5005076802332ADE',
+                                                    '5005076802532ADE',
+                                                    '5005076802232ADE',
+                                                    '5005076802132ADE',
+                                                    '5005086802132ADE',
+                                                    '5005086802332ADE',
+                                                    '5005086802532ADE',
+                                                    '5005086802232ADE',
+                                                    '5005086802432ADE'],
+                               'ff00000000000001': ['5005076802432ADE',
+                                                    '5005076802332ADE',
+                                                    '5005076802532ADE',
+                                                    '5005076802232ADE',
+                                                    '5005076802132ADE',
+                                                    '5005086802132ADE',
+                                                    '5005086802332ADE',
+                                                    '5005086802532ADE',
+                                                    '5005086802232ADE',
+                                                    '5005086802432ADE']},
                               'target_discovered': False,
                               'target_lun': 0,
-                              'target_wwn': '500507680220C744',
+                              'target_wwn': '5005076802432ADE',
                               'volume_id': volume['id']
                               }
                      }
index b34ed0864140b2d095578c2f33547a2424d18e7b..b0b53ddf2e97c6d12f3c247a74bf5c8a6802d2a7 100644 (file)
@@ -150,11 +150,12 @@ class StorwizeHelpers(object):
         """Add FC WWPNs to system node information."""
         for key in storage_nodes:
             node = storage_nodes[key]
-            resp = self.ssh.lsnode(node_id=node['id'])
             wwpns = set(node['WWPN'])
-            for i, s in resp.select('port_id', 'port_status'):
-                if 'active' == s:
-                    wwpns.add(i)
+            resp = self.ssh.lsportfc(node_id=node['id'])
+            for port_info in resp:
+                if (port_info['type'] == 'fc' and
+                        port_info['status'] == 'active'):
+                    wwpns.add(port_info['WWPN'])
             node['WWPN'] = list(wwpns)
             LOG.info(_LI('WWPN on node %(node)s: %(wwpn)s.'),
                      {'node': node['id'], 'wwpn': node['WWPN']})
index 4cc30f27463919a551c3830f0927e1e3bab34815..11596dee5d459fb411fb3b74efecda996f344a10 100644 (file)
@@ -361,6 +361,11 @@ class StorwizeSSH(object):
         ssh_cmd = ['svctask', 'rmvdiskaccess', '-iogrp', iogrp, vdisk]
         self.run_ssh_assert_no_output(ssh_cmd)
 
+    def lsportfc(self, node_id):
+        ssh_cmd = ['svcinfo', 'lsportfc', '-delim', '!',
+                   '-filtervalue', 'node_id=%s' % node_id]
+        return self.run_ssh_info(ssh_cmd, with_header=True)
+
 
 class CLIResponse(object):
     """Parse SVC CLI output and generate iterable."""