]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Fix ownership transfer when cloning with SolidFire
authorMathieu Gagné <mgagne@iweb.com>
Thu, 23 May 2013 19:26:44 +0000 (15:26 -0400)
committerJohn Griffith <john.griffith@solidfire.com>
Sat, 25 May 2013 23:42:54 +0000 (17:42 -0600)
When cloning a volume with SolidFire driver, the owner of
the cloned volume is not set correctly in SolidFire when there is
a transfer of ownership.

This results in inconsistent states where the cloned volume
is owned by the new tenant in Cinder but SolidFire thinks it is still
owned by the original volume's tenant.

This patch adds the newAccountID parameter to all CloneVolume calls.

If the cloned volume is owned by the same tenant, newAccountID will
be set to the same value as the original SolidFire volume. There
will be no change of ownership done by the cloning process in SolidFire.

If the cloned volume should be owned by a different tenant, newAccountID
will be set to the appropriate SolidFire account corresponding
to the new tenant. If the SolidFire account does not exist already,
it will be created.

Fixes: bug #1183521
Change-Id: I622ca2962478298e3e0c5a26866e39919805075f
(cherry picked from commit af023fe0cce3b8ef2b90ec37f1bc49feb17eac83)

cinder/volume/drivers/solidfire.py

index 840cecce78d7875560f56174223074c21e9759e4..cc227d847f5039889819e0014652427e913ccfe2 100644 (file)
@@ -304,6 +304,9 @@ class SolidFire(SanISCSIDriver):
         if sf_vol is None:
             raise exception.VolumeNotFound(volume_id=uuid)
 
+        if src_project_id != v_ref['project_id']:
+            sfaccount = self._create_sfaccount(v_ref['project_id'])
+
         if 'qos' in sf_vol:
             qos = sf_vol['qos']
 
@@ -318,6 +321,7 @@ class SolidFire(SanISCSIDriver):
         params = {'volumeID': int(sf_vol['volumeID']),
                   'name': 'UUID-%s' % v_ref['id'],
                   'attributes': attributes,
+                  'newAccountID': sfaccount['accountID'],
                   'qos': qos}
 
         data = self._issue_api_request('CloneVolume', params)