From 65c8ed3ed729b59ad44882b09d2aa47dda1275e7 Mon Sep 17 00:00:00 2001 From: Anthony Lee Date: Thu, 4 Dec 2014 15:46:53 -0800 Subject: [PATCH] Fix 3PAR driver attach error when host name missing In some cases an error was being thrown by the 3PAR driver when the 'name' property returned from queryHost was missing. This change adds a check so that the driver reacts properly when this occurs. Also removed an unneeded warning output that was still in the FC driver. This patch is related to this merged bug fix: https://review.openstack.org/#/c/138212/ Closes-Bug: 1398206 Change-Id: I6593dc68616f55496c42d625968adfc684f98032 --- cinder/volume/drivers/san/hp/hp_3par_fc.py | 10 ++++------ cinder/volume/drivers/san/hp/hp_3par_iscsi.py | 5 +++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/cinder/volume/drivers/san/hp/hp_3par_fc.py b/cinder/volume/drivers/san/hp/hp_3par_fc.py index 4eee2fc57..dcf9453b8 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_fc.py +++ b/cinder/volume/drivers/san/hp/hp_3par_fc.py @@ -34,10 +34,8 @@ try: except ImportError: hpexceptions = None -import pprint - from cinder import exception -from cinder.i18n import _, _LI, _LW +from cinder.i18n import _, _LI from cinder.openstack.common import log as logging import cinder.volume.driver from cinder.volume.drivers.san.hp import hp_3par_common as hpcommon @@ -75,10 +73,11 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver): 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 + 2.0.13 - Fix missing host name during attach bug #1398206 """ - VERSION = "2.0.12" + VERSION = "2.0.13" def __init__(self, *args, **kwargs): super(HP3PARFCDriver, self).__init__(*args, **kwargs) @@ -322,8 +321,7 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver): host_found = None hosts = common.client.queryHost(wwns=wwns) - LOG.warn(_LW("Found HOSTS %s") % pprint.pformat(hosts)) - if hosts and hosts['members']: + if hosts and hosts['members'] and 'name' in hosts['members'][0]: host_found = hosts['members'][0]['name'] if host_found is not None: diff --git a/cinder/volume/drivers/san/hp/hp_3par_iscsi.py b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py index 509c1cf9a..347a7f919 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_iscsi.py +++ b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py @@ -77,10 +77,11 @@ class HP3PARISCSIDriver(cinder.volume.driver.ISCSIDriver): 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 + 2.0.11 - Added missing host name during attach fix #1398206 """ - VERSION = "2.0.10" + VERSION = "2.0.11" def __init__(self, *args, **kwargs): super(HP3PARISCSIDriver, self).__init__(*args, **kwargs) @@ -356,7 +357,7 @@ class HP3PARISCSIDriver(cinder.volume.driver.ISCSIDriver): host_found = None hosts = common.client.queryHost(iqns=[iscsi_iqn]) - if hosts and hosts['members']: + if hosts and hosts['members'] and 'name' in hosts['members'][0]: host_found = hosts['members'][0]['name'] if host_found is not None: -- 2.45.2