]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
3PAR volumes created from snaps failed to attach
authorKurt Martin <kurt.f.martin@hp.com>
Tue, 6 Aug 2013 20:25:36 +0000 (13:25 -0700)
committerKurt Martin <kurt.f.martin@hp.com>
Wed, 7 Aug 2013 14:53:40 +0000 (07:53 -0700)
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
cinder/tests/test_hp3par.py
cinder/volume/drivers/san/hp/hp_3par_common.py
cinder/volume/drivers/san/hp/hp_3par_fc.py
cinder/volume/drivers/san/hp/hp_3par_iscsi.py

index 38ce3de63a1fecfe1e125e4bcdad60a7f36279a1..bfdf269aabdf0d00a1785caa4f52bcbad3762f38 100644 (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
 
index 8f04efa911f1819cc8db8f413b68ad349112daa2..9840d52e3e6c0112ac5c037a7bf7975061672589 100644 (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)
index e627886d281b058ad7b67df15eed7add63b8a206..f9c46071b1befe496efe2b80645a619642ea262f 100644 (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)
index 656ef423a9ebba7801f205b8284486389be17dc7..c0d2f9c3661d2cf9527a87652fdde5a74caf7dd1 100644 (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)