3PAR volumes created from snaps failed to attach

An error would occur if you attempted to attach a volume that
was created from a snapshot. The 3PAR backends does not have a
'userCPG' entry in the volume data on the backend, it instead
has a 'snapCPG' field. This patch will now look for the 'snapCPG'
entry and use that CPG when attaching the volume created from a
snapshot.

Change-Id: Ic7dab730a68339edb4273e4fbb6f8e45e37808b3
Fixes: bug 1207913
This commit is contained in:
Kurt Martin 2013-08-06 13:25:36 -07:00
parent f2c91c9a3c
commit 4f622b2a88
4 changed files with 11 additions and 7 deletions

View File

@ -398,12 +398,12 @@ class HP3PARBaseDriver():
def fake_create_client(self):
return FakeHP3ParClient(self.driver.configuration.hp3par_api_url)
def fake_get_cpg(self, volume, allowSnap=False):
return HP3PAR_CPG
def fake_set_connections(self):
return
def fake_get_cpg(self, volume):
return HP3PAR_CPG
def fake_get_domain(self, cpg):
return HP3PAR_DOMAIN

View File

@ -662,10 +662,14 @@ exit
def _remove_volume_from_volume_set(self, volume_name, vvs_name):
self._cli_run('removevvset -f %s %s' % (vvs_name, volume_name), None)
def get_cpg(self, volume):
def get_cpg(self, volume, allowSnap=False):
volume_name = self._get_3par_vol_name(volume['id'])
vol = self.client.getVolume(volume_name)
return vol['userCPG']
if 'userCPG' in vol:
return vol['userCPG']
elif allowSnap:
return vol['snapCPG']
return None
def _get_3par_vol_comment(self, volume_name):
vol = self.client.getVolume(volume_name)

View File

@ -220,7 +220,7 @@ class HP3PARFCDriver(cinder.volume.driver.FibreChannelDriver):
"""Creates or modifies existing 3PAR host."""
host = None
hostname = self.common._safe_hostname(connector['host'])
cpg = self.common.get_cpg(volume)
cpg = self.common.get_cpg(volume, allowSnap=True)
domain = self.common.get_domain(cpg)
try:
host = self.common._get_3par_host(hostname)

View File

@ -278,7 +278,7 @@ class HP3PARISCSIDriver(cinder.volume.driver.ISCSIDriver):
# make sure we don't have the host already
host = None
hostname = self.common._safe_hostname(connector['host'])
cpg = self.common.get_cpg(volume)
cpg = self.common.get_cpg(volume, allowSnap=True)
domain = self.common.get_domain(cpg)
try:
host = self.common._get_3par_host(hostname)