From: Kurt Martin Date: Wed, 4 Sep 2013 22:08:51 +0000 (-0700) Subject: Validate VV Set exists in 3PAR drivers X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=3a2db8e03434c3132d47a7256b9bd085662c5ca2;p=openstack-build%2Fcinder-build.git Validate VV Set exists in 3PAR drivers The 3PAR drivers must first create a volume and then add that volume to a virtual volume set on the backend for QoS support. If that predefined virutal volume set does not exists the volume would not be associated with the correct QoS settings. This patch will now look to see if the virtaul volume set exists and if not will delete the volume and notify the user that the VV Set does not exists. Change-Id: I460f6dd7001362b850c49454c78673aecd4cfef0 Fixes: bug 1218554 --- diff --git a/cinder/volume/drivers/san/hp/hp_3par_common.py b/cinder/volume/drivers/san/hp/hp_3par_common.py index 6f8f147b7..9bf5a46ac 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_common.py +++ b/cinder/volume/drivers/san/hp/hp_3par_common.py @@ -79,7 +79,7 @@ hp3par_opts = [ default='', help="3PAR Super user password", secret=True), - #TODO(kmartin): Remove hp3par_domain during I release. + # TODO(kmartin): Remove hp3par_domain during I release. cfg.StrOpt('hp3par_domain', default=None, help="This option is DEPRECATED and no longer used. " @@ -117,10 +117,11 @@ class HP3PARCommon(object): Version history: 1.2.0 - Updated hp3parclient API use to 2.0.x + 1.2.1 - Check that the VVS exists """ - VERSION = "1.2.0" + VERSION = "1.2.1" stats = {} @@ -299,7 +300,6 @@ class HP3PARCommon(object): LOG.debug("SSH CMD = %s " % cmd) (stdout, stderr) = self._run_ssh(cmd, False) - # we have to strip out the input and exit lines tmp = stdout.split("\r\n") out = tmp[5:len(tmp) - 2] @@ -560,7 +560,12 @@ exit cpg, vvs_name, qos): if vvs_name is not None: # Admin has set a volume set name to add the volume to - self._cli_run(['createvvset', '-add', vvs_name, volume_name]) + out = self._cli_run(['createvvset', '-add', vvs_name, volume_name]) + if out and len(out) == 1: + if 'does not exist' in out[0]: + raise exception.InvalidInput(reason=_('VV Set %s does ' + 'not exist.') + % vvs_name) else: vvs_name = self._get_3par_vvs_name(volume['id']) domain = self.get_domain(cpg) @@ -716,11 +721,10 @@ exit try: self._add_volume_to_volume_set(volume, volume_name, cpg, vvs_name, qos) - except Exception as ex: + except exception.InvalidInput as ex: # Delete the volume if unable to add it to the volume set self.client.deleteVolume(volume_name) - LOG.error(str(ex)) - raise exception.CinderException(ex.get_description()) + raise exception.CinderException(str(ex)) except hpexceptions.HTTPConflict: raise exception.Duplicate(_("Volume (%s) already exists on array") % volume_name) @@ -730,6 +734,9 @@ exit except exception.InvalidInput as ex: LOG.error(str(ex)) raise ex + except exception.CinderException as ex: + LOG.error(str(ex)) + raise ex except Exception as ex: LOG.error(str(ex)) raise exception.CinderException(ex.get_description())