]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix 3PAR driver hiding existing host error
authorWalter A. Boring IV <walter.boring@hp.com>
Wed, 13 Mar 2013 21:35:16 +0000 (14:35 -0700)
committerWalter A. Boring IV <walter.boring@hp.com>
Thu, 14 Mar 2013 16:54:51 +0000 (09:54 -0700)
This fixes a problem with the 3par drivers where creating
a 3par host was failing but there was no message.  The driver
would fail to find the host after the creation failed and the
log entry would show that the host didn't exist.   The real
error was failing to create the host.

bug #1154700

Change-Id: I2267d958f10cc73c6c5f34d224ea3452a4402f18

cinder/exception.py
cinder/volume/drivers/san/hp/hp_3par_fc.py
cinder/volume/drivers/san/hp/hp_3par_iscsi.py

index c5dd7e61ad9867344755fa845e9ef5161bd48884..81ddac2796dc0e3d29d5491315c7b0526652856a 100644 (file)
@@ -465,6 +465,10 @@ class DuplicateSfVolumeNames(Duplicate):
     message = _("Detected more than one volume with name %(vol_name)s")
 
 
+class Duplicate3PARHost(CinderException):
+    message = _("3PAR Host already exists: %(err)s.  %(info)s")
+
+
 class VolumeTypeCreateFailed(CinderException):
     message = _("Cannot create volume_type with "
                 "name %(name)s and specs %(extra_specs)s")
index d48612fb7a35005df0656467d01b86762655c1ce..f469ef03f756248bb415c6ca522424a4e4dc1b22 100644 (file)
@@ -204,6 +204,11 @@ must be the same" % (cpg['domain'], self.configuration.hp3par_domain)
         out = self.common._cli_run('createhost -persona %s -domain %s %s %s'
                                    % (persona_id, domain,
                                       hostname, " ".join(wwn)), None)
+        if out and len(out) > 1:
+            if "already used by host" in out[1]:
+                err = out[1].strip()
+                info = _("The hostname must be called '%s'") % hostname
+                raise exception.Duplicate3PARHost(err=err, info=info)
 
     def _modify_3par_fibrechan_host(self, hostname, wwn):
         # when using -add, you can not send the persona or domain options
index dea8bf1ccff9fd59782bec52fa72d31c6b5346f9..b740a2f57d9428c63436446430c8812e584da072 100644 (file)
@@ -229,7 +229,12 @@ must be the same" % (cpg['domain'], self.configuration.hp3par_domain)
     def _create_3par_iscsi_host(self, hostname, iscsi_iqn, domain, persona_id):
         cmd = 'createhost -iscsi -persona %s -domain %s %s %s' % \
               (persona_id, domain, hostname, iscsi_iqn)
-        self.common._cli_run(cmd, None)
+        out = self.common._cli_run(cmd, None)
+        if out and len(out) > 1:
+            if "already used by host" in out[1]:
+                err = out[1].strip()
+                info = _("The hostname must be called '%s'") % hostname
+                raise exception.Duplicate3PARHost(err=err, info=info)
 
     def _modify_3par_iscsi_host(self, hostname, iscsi_iqn):
         # when using -add, you can not send the persona or domain options