]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add accept_transfer to solidfire driver
authorJohn Griffith <john.griffith@solidfire.com>
Fri, 16 Aug 2013 23:21:21 +0000 (17:21 -0600)
committerJohn Griffith <john.griffith@solidfire.com>
Tue, 20 Aug 2013 15:02:33 +0000 (09:02 -0600)
The SolidFire cluster is tenant aware and as such
needs to change account association on volume transfer.

We use the project_id to build this account, so read that
in here and create a new account if necessary and re-assign
the existing volume to the new tenant account.

Change-Id: I29879714c2d32a982918cd1305c8eb00718795fd

cinder/volume/driver.py
cinder/volume/drivers/solidfire.py
cinder/volume/manager.py

index 9953db4c9396e1f37ea90ef0ff0c2543abd70484..752462a4c5cdc4b0f0486131cd8124a102e3a4ee 100644 (file)
@@ -613,7 +613,7 @@ class ISCSIDriver(VolumeDriver):
         data['QoS_support'] = False
         self._stats = data
 
-    def accept_transfer(self, volume, new_user, new_project):
+    def accept_transfer(self, context, volume, new_user, new_project):
         pass
 
 
index b9e4e6f60acbfcd27fefd378849885a4f93574bd..b02a74a87cf32164f76dd4be4383812203ee17f2 100644 (file)
@@ -720,3 +720,27 @@ class SolidFireDriver(SanISCSIDriver):
 
         if 'result' not in data:
             raise exception.SolidFireAPIDataException(data=data)
+
+    def accept_transfer(self, context, volume,
+                        new_user, new_project):
+
+        sfaccount = self._get_sfaccount(volume['project_id'])
+        params = {'accountID': sfaccount['accountID']}
+        sf_vol = self._get_sf_volume(volume['id'], params)
+
+        if new_project != volume['project_id']:
+            # do a create_sfaccount here as this tenant
+            # may not exist on the cluster yet
+            sfaccount = self._create_sfaccount(new_project)
+
+        params = {
+            'volumeID': sf_vol['volumeID'],
+            'accountID': sfaccount['accountID']
+        }
+        data = self._issue_api_request('ModifyVolume',
+                                       params, version='5.0')
+
+        if 'result' not in data:
+            raise exception.SolidFireAPIDataException(data=data)
+
+        LOG.debug(_("Leaving SolidFire transfer volume"))
index f0bba49eddbe7b229943d689544ae4f99e347714..7fb85514c4d55082579da54c8491c6f61719e8b3 100644 (file)
@@ -38,13 +38,10 @@ intact.
 """
 
 
-import sys
 import time
-import traceback
 
 from oslo.config import cfg
 
-from cinder.brick.initiator import connector as initiator
 from cinder import context
 from cinder import exception
 from cinder.image import glance
@@ -531,7 +528,7 @@ class VolumeManager(manager.SchedulerDependentManager):
         # NOTE(jdg): need elevated context as we haven't "given" the vol
         # yet
         volume_ref = self.db.volume_get(context.elevated(), volume_id)
-        self.driver.accept_transfer(volume_ref, new_user, new_project)
+        self.driver.accept_transfer(context, volume_ref, new_user, new_project)
 
     def _migrate_volume_generic(self, ctxt, volume, host):
         rpcapi = volume_rpcapi.VolumeAPI()