]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Added 3par initiator target map for FCZM
authorWalter A. Boring IV <walter.boring@hp.com>
Mon, 24 Feb 2014 19:35:32 +0000 (11:35 -0800)
committerWalter A. Boring IV <walter.boring@hp.com>
Mon, 24 Feb 2014 19:35:32 +0000 (11:35 -0800)
This patch adds the required initiator target map
for the Fibre Channel Zone Manager.   The
FCZM looks for the initiator_target_map to try and
automatically zone up the endpoints.

Change-Id: I61aaf31752f8a5eebb672887c9a943584df66995
Closes-Bug: #1284275

cinder/tests/test_hp3par.py
cinder/volume/drivers/san/hp/hp_3par_fc.py

index 36d2ae6241a604a67d63089d0bca48e3547f39dc..ebce2f58d39fe9dbf067d9f6ed2cb398c9539f78 100644 (file)
@@ -794,7 +794,12 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
         'data': {
             'target_lun': 90,
             'target_wwn': ['0987654321234', '123456789000987'],
-            'target_discovered': True}}
+            'target_discovered': True,
+            'initiator_target_map': {'123456789012345':
+                                     ['0987654321234', '123456789000987'],
+                                     '123456789054321':
+                                     ['0987654321234', '123456789000987'],
+                                     }}}
 
     def setUp(self):
         super(TestHP3PARFCDriver, self).setUp()
@@ -876,6 +881,32 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
 
         self.assertDictMatch(result, self.properties)
 
+    def test_terminate_connection(self):
+        # setup_mock_client drive with default configuration
+        # and return the mock HTTP 3PAR client
+        mock_client = self.setup_driver()
+        mock_client.getVLUN.return_value = {'lun': None, 'type': 0}
+        mock_client.getPorts.return_value = {
+            'members': self.FAKE_FC_PORTS + [self.FAKE_ISCSI_PORT]}
+
+        self.driver.terminate_connection(
+            self.volume,
+            self.connector,
+            force=True)
+
+        expected = [
+            mock.call.login(HP3PAR_USER_NAME, HP3PAR_USER_PASS),
+            mock.call.getVLUN(self.VOLUME_3PAR_NAME),
+            mock.call.deleteVLUN(
+                self.VOLUME_3PAR_NAME,
+                None,
+                self.FAKE_HOST),
+            mock.call.deleteHost(self.FAKE_HOST),
+            mock.call.getPorts(),
+            mock.call.logout()]
+
+        mock_client.assert_has_calls(expected)
+
     def test_get_volume_stats(self):
         # setup_mock_client drive with default configuration
         # and return the mock HTTP 3PAR client
index f1e7712756040bbcec2a3d4d43a16aaad7366458..e48051224e890f1cafdf2e9b6db3071089b3c577 100644 (file)
@@ -57,10 +57,11 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver):
         1.3.0 - Removed all SSH code.  We rely on the hp3parclient now.
         2.0.0 - Update hp3parclient API uses 3.0.x
         2.0.2 - Add back-end assisted volume migrate
+        2.0.3 - Added initiator-target map for FC Zone Manager
 
     """
 
-    VERSION = "2.0.2"
+    VERSION = "2.0.3"
 
     def __init__(self, *args, **kwargs):
         super(HP3PARFCDriver, self).__init__(*args, **kwargs)
@@ -203,16 +204,14 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver):
             # now that we have a host, create the VLUN
             vlun = self.common.create_vlun(volume, host)
 
-            fc_ports = self.common.get_active_fc_target_ports()
-            wwns = []
-
-            for port in fc_ports:
-                wwns.append(port['portWWN'])
+            target_wwns, init_targ_map = self._build_initiator_target_map(
+                connector)
 
             info = {'driver_volume_type': 'fibre_channel',
                     'data': {'target_lun': vlun['lun'],
                              'target_discovered': True,
-                             'target_wwn': wwns}}
+                             'target_wwn': target_wwns,
+                             'initiator_target_map': init_targ_map}}
             return info
         finally:
             self.common.client_logout()
@@ -225,9 +224,35 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver):
             hostname = self.common._safe_hostname(connector['host'])
             self.common.terminate_connection(volume, hostname,
                                              wwn=connector['wwpns'])
+
+            target_wwns, init_targ_map = self._build_initiator_target_map(
+                connector)
+
+            info = {'driver_volume_type': 'fibre_channel',
+                    'data': {'target_wwn': target_wwns,
+                             'initiator_target_map': init_targ_map}}
+            return info
+
         finally:
             self.common.client_logout()
 
+    def _build_initiator_target_map(self, connector):
+        """Build the target_wwns and the initiator target map."""
+
+        fc_ports = self.common.get_active_fc_target_ports()
+        target_wwns = []
+
+        for port in fc_ports:
+            target_wwns.append(port['portWWN'])
+
+        initiator_wwns = connector['wwpns']
+
+        init_targ_map = {}
+        for initiator in initiator_wwns:
+            init_targ_map[initiator] = target_wwns
+
+        return target_wwns, init_targ_map
+
     def _create_3par_fibrechan_host(self, hostname, wwns, domain, persona_id):
         """Create a 3PAR host.