From 5edbc4eb9a6b0d50612fffb6261850c80515b483 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Mon, 15 Jul 2013 15:16:25 -0600 Subject: [PATCH] Catch additional connect fail cases. When fixing bug/1195910, some other failure cases weren't considered (ie not authorized, unreachable dest etc). We should fix this up to handle the various connection error states accordingly and also add some hints to the log output to help determine where to look in case of failure. Fixes bug: 1201592 Change-Id: Ib099c7af705e7c49be4d0f723c8a20262c942e7f --- cinder/volume/drivers/solidfire.py | 46 ++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 15 deletions(-) diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index 512775b80..b35d37ac2 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -87,9 +87,7 @@ class SolidFire(SanISCSIDriver): self.configuration.append_config_values(sf_opts) try: self._update_cluster_status() - except Exception as ex: - LOG.error(_("Update SolidFire Cluster stats failed: %s"), - ex.strerror) + except exception.SolidFireAPIException: pass def _issue_api_request(self, method_name, params, version='1.0'): @@ -139,13 +137,28 @@ class SolidFire(SanISCSIDriver): api_endpoint = '/json-rpc/%s' % version connection = httplib.HTTPSConnection(host, port) - connection.request('POST', api_endpoint, payload, header) + try: + connection.request('POST', api_endpoint, payload, header) + except Exception as ex: + LOG.error(_('Failed to make httplib connection ' + 'SolidFire Cluster: %s (verify san_ip ' + 'settings)') % ex.message) + msg = _("Failed to make httplib connection: %s") % ex.message + raise exception.SolidFireAPIException(msg) response = connection.getresponse() data = {} if response.status != 200: connection.close() - raise exception.SolidFireAPIException(status=response.status) + LOG.error(_('Request to SolidFire cluster returned ' + 'bad status: %(status)s / %(reason)s (check ' + 'san_login/san_password settings)') % + {'status': response.status, + 'reason': response.reason}) + msg = (_("HTTP request failed, with status: %(status)s " + "and reason: %(reason)s") % + {'status': response.status, 'reason': response.reason}) + raise exception.SolidFireAPIException(msg) else: data = response.read() @@ -245,7 +258,8 @@ class SolidFire(SanISCSIDriver): params = {} data = self._issue_api_request('GetClusterInfo', params) if 'result' not in data: - raise exception.SolidFireAPIDataException(data=data) + msg = _("API response: %s") % data + raise exception.SolidFireAPIException(msg) return data['result'] @@ -298,7 +312,7 @@ class SolidFire(SanISCSIDriver): % (iscsi_portal, iqn, 0)) model_update['provider_auth'] = ('CHAP %s %s' % (sfaccount['username'], - chap_secret)) + chap_secret)) if not self.configuration.sf_emulate_512: model_update['provider_geometry'] = ('%s %s' % (4096, 4096)) @@ -333,7 +347,8 @@ class SolidFire(SanISCSIDriver): data = self._issue_api_request('CloneVolume', params) if (('result' not in data) or ('volumeID' not in data['result'])): - raise exception.SolidFireAPIDataException(data=data) + msg = _("API response: %s") % data + raise exception.SolidFireAPIException(msg) sf_volume_id = data['result']['volumeID'] if (self.configuration.sf_allow_tenant_qos and @@ -363,7 +378,7 @@ class SolidFire(SanISCSIDriver): model_update = self._get_model_info(sfaccount, sf_volume_id) if model_update is None: mesg = _('Failed to get model update from clone') - raise exception.SolidFireAPIDataException(mesg) + raise exception.SolidFireAPIException(mesg) return (data, sfaccount, model_update) @@ -374,7 +389,8 @@ class SolidFire(SanISCSIDriver): data = self._issue_api_request('CreateVolume', params) if (('result' not in data) or ('volumeID' not in data['result'])): - raise exception.SolidFireAPIDataException(data=data) + msg = _("Failed volume create: %s") % data + raise exception.SolidFireAPIException(msg) sf_volume_id = data['result']['volumeID'] return self._get_model_info(sfaccount, sf_volume_id) @@ -413,7 +429,8 @@ class SolidFire(SanISCSIDriver): def _get_sf_volume(self, uuid, params): data = self._issue_api_request('ListVolumesForAccount', params) if 'result' not in data: - raise exception.SolidFireAPIDataException(data=data) + msg = _("Failed to get SolidFire Volume: %s") % data + raise exception.SolidFireAPIException(msg) found_count = 0 sf_volref = None @@ -519,7 +536,8 @@ class SolidFire(SanISCSIDriver): data = self._issue_api_request('DeleteVolume', params) if 'result' not in data: - raise exception.SolidFireAPIDataException(data=data) + msg = _("Failed to delete SolidFire Volume: %s") % data + raise exception.SolidFireAPIException(msg) else: LOG.error(_("Volume ID %s was not found on " "the SolidFire Cluster!"), volume['id']) @@ -577,9 +595,7 @@ class SolidFire(SanISCSIDriver): if refresh: try: self._update_cluster_status() - except Exception as ex: - LOG.error(_("Update SolidFire Cluster stats failed: %s"), - ex.strerror) + except exception.SolidFireAPIException: pass return self.cluster_stats -- 2.45.2