From: Kurt Martin Date: Tue, 2 Dec 2014 00:13:18 +0000 (-0800) Subject: Fix 3PAR drivers attempt to locate existing host X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=1e83a22507238a2a2ff5ac4bb5497c984666105d;p=openstack-build%2Fcinder-build.git Fix 3PAR drivers attempt to locate existing host 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 --- diff --git a/cinder/tests/test_hp3par.py b/cinder/tests/test_hp3par.py index d9e090bbe..f944f67f9 100644 --- a/cinder/tests/test_hp3par.py +++ b/cinder/tests/test_hp3par.py @@ -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), diff --git a/cinder/volume/drivers/san/hp/hp_3par_fc.py b/cinder/volume/drivers/san/hp/hp_3par_fc.py index 66b808588..4eee2fc57 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_fc.py +++ b/cinder/volume/drivers/san/hp/hp_3par_fc.py @@ -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']: diff --git a/cinder/volume/drivers/san/hp/hp_3par_iscsi.py b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py index 376749d1b..509c1cf9a 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_iscsi.py +++ b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py @@ -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