From d5793e0c6289f011c67e6b18551066eb2cac38b5 Mon Sep 17 00:00:00 2001 From: John Griffith Date: Fri, 16 Aug 2013 17:21:21 -0600 Subject: [PATCH] Add accept_transfer to solidfire driver 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 | 2 +- cinder/volume/drivers/solidfire.py | 24 ++++++++++++++++++++++++ cinder/volume/manager.py | 5 +---- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/cinder/volume/driver.py b/cinder/volume/driver.py index 9953db4c9..752462a4c 100644 --- a/cinder/volume/driver.py +++ b/cinder/volume/driver.py @@ -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 diff --git a/cinder/volume/drivers/solidfire.py b/cinder/volume/drivers/solidfire.py index b9e4e6f60..b02a74a87 100644 --- a/cinder/volume/drivers/solidfire.py +++ b/cinder/volume/drivers/solidfire.py @@ -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")) diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index f0bba49ed..7fb85514c 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -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() -- 2.45.2