Browse Source

Fix FC case sensitive scanning

For FC connections there are multiple places where we check the
initiator target map provided by the backend against the port names of
the HBAs on the system.

Currently this check is case sensitive, but some backends are returning
the port names in the initiator target map upper cased, which usually
results in attach failures.

Some of the reasons for the attach failures is that os-brick will not
issue scan requests.

Example from a 3PAR backend from a specific system:

  Connector properties:
    {
     'wwpns': ['10001409dcd71ff6', '10001409dcd71ff7'],
     'wwnns': ['20001409dcd71ff6', '20001409dcd71ff7'],
     ...
    }

  Connection properties:
    {
     'initiator_target_map': {
       '10001409DCD71FF6': ['20320002AC01E166', '21420002AC01E166'],
       '10001409DCD71FF7': ['20410002AC01E166', '21410002AC01E166']
     }
     ...
    }

This patch converts to lower case the
initiator_target_map and the target_wwn/target_wwns.

Closes-Bug: #1775677
Change-Id: I12b9535d8a9969356394e406a1ed5ac4a5f1f959
(cherry picked from commit 037f9fe667)
Conflicts:
	os_brick/initiator/connectors/fibre_channel.py
(cherry picked from commit 00a4d96d25)
tags/2.3.8^0
Gorka Eguileor 7 months ago
parent
commit
bdd05d2232

+ 14
- 2
os_brick/initiator/connectors/fibre_channel.py View File

@@ -83,6 +83,13 @@ class FibreChannelConnector(base.BaseLinuxConnector):
83 83
         else:
84 84
             wwns = []
85 85
 
86
+        # Convert wwns to lower case
87
+        wwns = [wwn.lower() for wwn in wwns]
88
+        if target_wwns:
89
+            connection_properties['target_wwns'] = wwns
90
+        elif target_wwn:
91
+            connection_properties['target_wwn'] = wwns
92
+
86 93
         target_lun = connection_properties.get('target_lun', 0)
87 94
         target_luns = connection_properties.get('target_luns')
88 95
         if target_luns:
@@ -116,8 +123,13 @@ class FibreChannelConnector(base.BaseLinuxConnector):
116 123
             wwpn_lun_map[wwpn] = lun
117 124
 
118 125
         # If there is an initiator_target_map we can update it too
119
-        if 'initiator_target_map' in connection_properties:
126
+        if connection_properties.get('initiator_target_map') is not None:
127
+            # Convert it to lower case
120 128
             itmap = connection_properties['initiator_target_map']
129
+            itmap = {k.lower(): [port.lower() for port in v]
130
+                     for k, v in itmap.items()}
131
+            connection_properties['initiator_target_map'] = itmap
132
+
121 133
             new_itmap = dict()
122 134
             for init_wwpn in itmap:
123 135
                 target_wwpns = itmap[init_wwpn]
@@ -125,7 +137,7 @@ class FibreChannelConnector(base.BaseLinuxConnector):
125 137
                 for target_wwpn in target_wwpns:
126 138
                     if target_wwpn in wwpn_lun_map:
127 139
                         init_targets.append((target_wwpn,
128
-                                            wwpn_lun_map[target_wwpn]))
140
+                                             wwpn_lun_map[target_wwpn]))
129 141
                 new_itmap[init_wwpn] = init_targets
130 142
             connection_properties['initiator_target_lun_map'] = new_itmap
131 143
 

+ 31
- 1
os_brick/tests/initiator/connectors/test_fibre_channel.py View File

@@ -611,7 +611,29 @@ class FibreChannelConnectorTestCase(test_connector.ConnectorTestCase):
611 611
                                      ('1234567890123457', 2)]
612 612
             }
613 613
         },
614
-
614
+        {
615
+            "target_info": {
616
+                "target_lun": 1,
617
+                "target_wwn": ['20320002AC01E166', '21420002AC01E166',
618
+                               '20410002AC01E166', '21410002AC01E166']
619
+            },
620
+            "expected_targets": [
621
+                ('20320002ac01e166', 1),
622
+                ('21420002ac01e166', 1),
623
+                ('20410002ac01e166', 1),
624
+                ('21410002ac01e166', 1)
625
+            ],
626
+            "itmap": {
627
+                '10001409DCD71FF6': ['20320002AC01E166', '21420002AC01E166'],
628
+                '10001409DCD71FF7': ['20410002AC01E166', '21410002AC01E166']
629
+            },
630
+            "expected_map": {
631
+                '10001409dcd71ff6': [('20320002ac01e166', 1),
632
+                                     ('21420002ac01e166', 1)],
633
+                '10001409dcd71ff7': [('20410002ac01e166', 1),
634
+                                     ('21410002ac01e166', 1)]
635
+            }
636
+        },
615 637
     )
616 638
     @ddt.unpack
617 639
     def test__add_targets_to_connection_properties(self, target_info,
@@ -631,6 +653,14 @@ class FibreChannelConnectorTestCase(test_connector.ConnectorTestCase):
631 653
         self.assertIn('targets', connection_info)
632 654
         self.assertEqual(expected_targets, connection_info['targets'])
633 655
 
656
+        # Check that we turn to lowercase target wwns
657
+        key = 'target_wwns' if 'target_wwns' in target_info else 'target_wwn'
658
+        wwns = target_info.get(key)
659
+        wwns = [wwns] if isinstance(wwns, six.string_types) else wwns
660
+        wwns = [w.lower() for w in wwns]
661
+        if wwns:
662
+            self.assertEqual(wwns, conn['data'][key])
663
+
634 664
         if itmap:
635 665
             self.assertIn('initiator_target_lun_map', connection_info)
636 666
             self.assertEqual(expected_map,

Loading…
Cancel
Save