Add call to vol driver when accepting a transfer

Some back-ends have the notion of tenancy on volumes
and set ownership in the driver.  The update of the DB
alone when doing volume transfers isn't enough, we need
to be able to propogate the update info all the way
down to the driver level.

This patch introduces the volume api/manger/rpc calls
and implements a stub in the base driver that can
be over-ridden for those that need to take some action.

Change-Id: Ica6ae368084c44b32af5d08df14bb3745f3a37ee
This commit is contained in:
John Griffith 2013-06-04 13:02:37 -06:00
parent 7d1534c8f3
commit d03c94f2b0
6 changed files with 27 additions and 1 deletions

View File

@ -170,3 +170,9 @@ class VolumeRpcAPITestCase(test.TestCase):
volume=self.fake_volume,
connector='fake_connector',
force=False)
def test_accept_transfer(self):
self._test_volume_api('accept_transfer',
rpc_method='cast',
volume=self.fake_volume,
version='1.5')

View File

@ -36,7 +36,7 @@ volume_transfer_opts = [
help='The number of characters in the salt.'),
cfg.IntOpt('volume_transfer_key_length', default=16,
help='The number of characters in the '
'autogenerated auth key.'), ]
'autogenerated auth key.'), ]
FLAGS = flags.FLAGS
FLAGS.register_opts(volume_transfer_opts)
@ -178,6 +178,7 @@ class API(base.Base):
try:
# Transfer ownership of the volume now, must use an elevated
# context.
self.volume_api.accept_transfer(context, vol_ref)
self.db.transfer_accept(context.elevated(),
transfer_id,
context.user_id,

View File

@ -518,6 +518,10 @@ class API(base.Base):
connector,
force)
def accept_transfer(self, context, volume):
return self.volume_rpcapi.accept_transfer(context,
volume)
def _create_snapshot(self, context,
volume, name, description,
force=False, metadata=None):

View File

@ -480,6 +480,9 @@ class ISCSIDriver(VolumeDriver):
data['QoS_support'] = False
self._stats = data
def accept_transfer(self, volume):
pass
class FakeISCSIDriver(ISCSIDriver):
"""Logs calls instead of executing."""

View File

@ -701,6 +701,10 @@ class VolumeManager(manager.SchedulerDependentManager):
volume_ref = self.db.volume_get(context, volume_id)
self.driver.terminate_connection(volume_ref, connector, force=force)
def accept_transfer(self, context, volume_id):
volume_ref = self.db.volume_get(context, volume_id)
self.driver.accept_transfer(volume_ref)
@manager.periodic_task
def _report_driver_status(self, context):
LOG.info(_("Updating volume status"))

View File

@ -38,6 +38,7 @@ class VolumeAPI(cinder.openstack.common.rpc.proxy.RpcProxy):
1.3 - Pass all image metadata (not just ID) in copy_volume_to_image
1.4 - Add request_spec, filter_properties and
allow_reschedule arguments to create_volume().
1.5 - Add accept_transfer
'''
BASE_RPC_API_VERSION = '1.0'
@ -128,3 +129,10 @@ class VolumeAPI(cinder.openstack.common.rpc.proxy.RpcProxy):
def publish_service_capabilities(self, ctxt):
self.fanout_cast(ctxt, self.make_msg('publish_service_capabilities'),
version='1.2')
def accept_transfer(self, ctxt, volume):
self.cast(ctxt,
self.make_msg('accept_transfer',
volume_id=volume['id']),
topic=rpc.queue_get_for(ctxt, self.topic, volume['host']),
version='1.5')