]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Catch additional connect fail cases.
authorJohn Griffith <john.griffith@solidfire.com>
Mon, 15 Jul 2013 21:16:25 +0000 (15:16 -0600)
committerJohn Griffith <john.griffith@solidfire.com>
Tue, 16 Jul 2013 02:15:41 +0000 (20:15 -0600)
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

index 512775b800026e3f855c7e79abf66269879ea625..b35d37ac286e19f5e99f09b75fe98cfa8bc310d5 100644 (file)
@@ -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