]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Add call to vol driver when accepting a transfer
authorJohn Griffith <john.griffith@solidfire.com>
Tue, 4 Jun 2013 19:02:37 +0000 (13:02 -0600)
committerJohn Griffith <john.griffith@solidfire.com>
Tue, 4 Jun 2013 19:06:20 +0000 (13:06 -0600)
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

cinder/tests/test_volume_rpcapi.py
cinder/transfer/api.py
cinder/volume/api.py
cinder/volume/driver.py
cinder/volume/manager.py
cinder/volume/rpcapi.py

index 7a75224b8191136a59641beb896d171a5ed27a37..70735243d7136a5295ceec64178d541e640620f3 100644 (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')
index e139951a2287cef21e41b050688df6af71d09507..0ae5d2325f00e63f193068caeb0e389467625308 100644 (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,
index d24e8a0e766d292f72a5065da1e026b04e5aadd8..05c22388c40ad701015b39e9a4a37ba820503aba 100644 (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):
index 275ced42fd288db933ce289849071ec9db344444..7240ad2f6befa28be114d200176b27ef5c3392ed 100644 (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."""
index f465e53ba1780c942afab50f082fbbaa440f95d3..8effaf1b6a62d230d87b357371240cebda26d174 100644 (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"))
index 1788873d5df69e4279092c3ebf1d71c4149fb289..adb9e4d0fc8209bc259c6ff66cb198ad79221c07 100644 (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')