Skip to content

Commit

Permalink
Validate VV Set exists in 3PAR drivers
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kumartin committed Sep 4, 2013
1 parent 7647ce8 commit 3a2db8e
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions cinder/volume/drivers/san/hp/hp_3par_common.py
Expand Up @@ -79,7 +79,7 @@
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. "
Expand Down Expand Up @@ -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 = {}

Expand Down Expand Up @@ -299,7 +300,6 @@ def _cli_run(self, cmd):
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]
Expand Down Expand Up @@ -560,7 +560,12 @@ def _add_volume_to_volume_set(self, volume, volume_name,
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)
Expand Down Expand Up @@ -716,11 +721,10 @@ def create_volume(self, volume):
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)
Expand All @@ -730,6 +734,9 @@ def create_volume(self, volume):
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())
Expand Down

0 comments on commit 3a2db8e

Please sign in to comment.