From: Kurt Martin Date: Tue, 6 Aug 2013 20:25:36 +0000 (-0700) Subject: 3PAR volumes created from snaps failed to attach X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=4f622b2a88e1bcb5808540226608095db079ba9e;p=openstack-build%2Fcinder-build.git 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 --- diff --git a/cinder/tests/test_hp3par.py b/cinder/tests/test_hp3par.py index 38ce3de63..bfdf269aa 100644 --- a/cinder/tests/test_hp3par.py +++ b/cinder/tests/test_hp3par.py @@ -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 diff --git a/cinder/volume/drivers/san/hp/hp_3par_common.py b/cinder/volume/drivers/san/hp/hp_3par_common.py index 8f04efa91..9840d52e3 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_common.py +++ b/cinder/volume/drivers/san/hp/hp_3par_common.py @@ -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) diff --git a/cinder/volume/drivers/san/hp/hp_3par_fc.py b/cinder/volume/drivers/san/hp/hp_3par_fc.py index e627886d2..f9c46071b 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_fc.py +++ b/cinder/volume/drivers/san/hp/hp_3par_fc.py @@ -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) diff --git a/cinder/volume/drivers/san/hp/hp_3par_iscsi.py b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py index 656ef423a..c0d2f9c36 100644 --- a/cinder/volume/drivers/san/hp/hp_3par_iscsi.py +++ b/cinder/volume/drivers/san/hp/hp_3par_iscsi.py @@ -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)