]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix 3PAR drivers attempt to locate existing host
authorKurt Martin <kurt.f.martin@hp.com>
Tue, 2 Dec 2014 00:13:18 +0000 (16:13 -0800)
committerKurt Martin <kurt.f.martin@hp.com>
Tue, 2 Dec 2014 01:37:07 +0000 (17:37 -0800)
This patch fixes the current 3PAR drivers around attempting to locate
3PAR host that might already have volumes attached. The FC driver is
using the correct REST based queryHost but is not specifying the
parameters wwns=wwns when calling it. This was accidentally merged
during the removal on the local file locks.

The iSCSI driver was actually calling a SSH based findHost command
instead of the REST based queryHost based on iqns. The SSH based
command was failing with a session key error after a long idle time
between attaches.
Closes-Bug: 1398206

Change-Id: I5e0b1e5382c65176a74441bd4fe40d066317de48

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

index d9e090bbe01ec8ba89df7c7a6a5e6c5fc2c32560..f944f67f91e3d01a46321a49a64c8e48c4cd7321 100644 (file)
@@ -2684,7 +2684,8 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
                 mock.call.getVolume(self.VOLUME_3PAR_NAME),
                 mock.call.getCPG(HP3PAR_CPG),
                 mock.call.getHost(self.FAKE_HOST),
-                mock.ANY,
+                mock.call.queryHost(wwns=['123456789012345',
+                                          '123456789054321']),
                 mock.call.getHost(self.FAKE_HOST),
                 mock.call.getPorts(),
                 mock.call.createVLUN(
@@ -3049,7 +3050,8 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
                 mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'),
                 mock.call.getCPG(HP3PAR_CPG),
                 mock.call.getHost(self.FAKE_HOST),
-                mock.call.queryHost(['123456789012345', '123456789054321']),
+                mock.call.queryHost(wwns=['123456789012345',
+                                          '123456789054321']),
                 mock.call.createHost(
                     self.FAKE_HOST,
                     FCWwns=['123456789012345', '123456789054321'],
@@ -3091,7 +3093,8 @@ class TestHP3PARFCDriver(HP3PARBaseDriver, test.TestCase):
                 mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'),
                 mock.call.getCPG(HP3PAR_CPG),
                 mock.call.getHost('fakehost'),
-                mock.call.queryHost(['123456789012345', '123456789054321']),
+                mock.call.queryHost(wwns=['123456789012345',
+                                          '123456789054321']),
                 mock.call.getHost('fakehost.foo')]
 
             mock_client.assert_has_calls(expected)
@@ -3258,7 +3261,11 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
         mock_client.getHost.side_effect = [
             hpexceptions.HTTPNotFound('fake'),
             {'name': self.FAKE_HOST}]
-        mock_client.findHost.return_value = self.FAKE_HOST
+        mock_client.queryHost.return_value = {
+            'members': [{
+                'name': self.FAKE_HOST
+            }]
+        }
         mock_client.getHostVLUNs.return_value = [
             {'active': True,
              'volumeName': self.VOLUME_3PAR_NAME,
@@ -3281,7 +3288,7 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
                 mock.call.getVolume(self.VOLUME_3PAR_NAME),
                 mock.call.getCPG(HP3PAR_CPG),
                 mock.call.getHost(self.FAKE_HOST),
-                mock.call.findHost(iqn='iqn.1993-08.org.debian:01:222'),
+                mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']),
                 mock.call.getHost(self.FAKE_HOST),
                 mock.call.createVLUN(
                     self.VOLUME_3PAR_NAME,
@@ -3356,7 +3363,7 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
         mock_client.getHost.side_effect = [
             hpexceptions.HTTPNotFound('fake'),
             {'name': self.FAKE_HOST}]
-        mock_client.findHost.return_value = None
+        mock_client.queryHost.return_value = None
         mock_client.getVLUN.return_value = {'lun': self.TARGET_LUN}
 
         with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\
@@ -3369,7 +3376,7 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
                 mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'),
                 mock.call.getCPG(HP3PAR_CPG),
                 mock.call.getHost(self.FAKE_HOST),
-                mock.call.findHost(iqn='iqn.1993-08.org.debian:01:222'),
+                mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']),
                 mock.call.createHost(
                     self.FAKE_HOST,
                     optional={'domain': None, 'persona': 2},
@@ -3394,7 +3401,7 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
         mock_client.getHost.side_effect = [
             hpexceptions.HTTPNotFound('fake'),
             {'name': self.FAKE_HOST}]
-        mock_client.findHost.return_value = None
+        mock_client.queryHost.return_value = None
         mock_client.getVLUN.return_value = {'lun': self.TARGET_LUN}
 
         expected_mod_request = {
@@ -3428,7 +3435,7 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
                 mock.call.getVolumeMetaData(
                     'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_PASS_KEY),
                 mock.call.getHost(self.FAKE_HOST),
-                mock.call.findHost(iqn='iqn.1993-08.org.debian:01:222'),
+                mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']),
                 mock.call.createHost(
                     self.FAKE_HOST,
                     optional={'domain': None, 'persona': 2},
@@ -3454,7 +3461,11 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
         mock_client.getHost.side_effect = [
             hpexceptions.HTTPNotFound('Host not found.'),
             {'name': 'fakehost.foo'}]
-        mock_client.findHost.return_value = 'fakehost.foo'
+        mock_client.queryHost.return_value = {
+            'members': [{
+                'name': 'fakehost.foo'
+            }]
+        }
 
         with mock.patch.object(hpcommon.HP3PARCommon, '_create_client')\
                 as mock_create_client:
@@ -3467,7 +3478,7 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
                 mock.call.getVolume('osv-0DM4qZEVSKON-DXN-NwVpw'),
                 mock.call.getCPG(HP3PAR_CPG),
                 mock.call.getHost(self.FAKE_HOST),
-                mock.call.findHost(iqn='iqn.1993-08.org.debian:01:222'),
+                mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']),
                 mock.call.getHost('fakehost.foo')]
 
             mock_client.assert_has_calls(expected)
@@ -3488,7 +3499,11 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
         mock_client.getHost.side_effect = [
             hpexceptions.HTTPNotFound('Host not found.'),
             {'name': 'fakehost.foo'}]
-        mock_client.findHost.return_value = 'fakehost.foo'
+        mock_client.queryHost.return_value = {
+            'members': [{
+                'name': 'fakehost.foo'
+            }]
+        }
 
         def get_side_effect(*args):
             data = {'value': None}
@@ -3522,7 +3537,7 @@ class TestHP3PARISCSIDriver(HP3PARBaseDriver, test.TestCase):
                 mock.call.getVolumeMetaData(
                     'osv-0DM4qZEVSKON-DXN-NwVpw', CHAP_PASS_KEY),
                 mock.call.getHost(self.FAKE_HOST),
-                mock.call.findHost(iqn='iqn.1993-08.org.debian:01:222'),
+                mock.call.queryHost(iqns=['iqn.1993-08.org.debian:01:222']),
                 mock.call.modifyHost(
                     'fakehost.foo',
                     expected_mod_request),
index 66b80858828c1359e29f2c70370a21b48e2cbfa5..4eee2fc572dc923c36fc8d39dd91a5a7fa408a85 100644 (file)
@@ -74,10 +74,11 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver):
         2.0.9 - Add support for pools with model update
         2.0.10 - Migrate without losing type settings bug #1356608
         2.0.11 - Removing locks bug #1381190
+        2.0.12 - Fix queryHost call to specify wwns bug #1398206
 
     """
 
-    VERSION = "2.0.11"
+    VERSION = "2.0.12"
 
     def __init__(self, *args, **kwargs):
         super(HP3PARFCDriver, self).__init__(*args, **kwargs)
@@ -319,7 +320,7 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver):
         """
         # first search for an existing host
         host_found = None
-        hosts = common.client.queryHost(wwns)
+        hosts = common.client.queryHost(wwns=wwns)
 
         LOG.warn(_LW("Found HOSTS %s") % pprint.pformat(hosts))
         if hosts and hosts['members']:
index 376749d1b5a8659ac69b797abb063e05d8331332..509c1cf9ad51f170964fb09b85a30741658c3c5f 100644 (file)
@@ -76,10 +76,11 @@ class HP3PARISCSIDriver(cinder.volume.driver.ISCSIDriver):
         2.0.7 - Add support for pools with model update
         2.0.8 - Migrate without losing type settings bug #1356608
         2.0.9 - Removing locks bug #1381190
+        2.0.10 - Add call to queryHost instead SSH based findHost #1398206
 
     """
 
-    VERSION = "2.0.9"
+    VERSION = "2.0.10"
 
     def __init__(self, *args, **kwargs):
         super(HP3PARISCSIDriver, self).__init__(*args, **kwargs)
@@ -352,7 +353,12 @@ class HP3PARISCSIDriver(cinder.volume.driver.ISCSIDriver):
         used by 3PAR.
         """
         # first search for an existing host
-        host_found = common.client.findHost(iqn=iscsi_iqn)
+        host_found = None
+        hosts = common.client.queryHost(iqns=[iscsi_iqn])
+
+        if hosts and hosts['members']:
+            host_found = hosts['members'][0]['name']
+
         if host_found is not None:
             common.hosts_naming_dict[hostname] = host_found
             return host_found