From 72a1c5dfa2a0ddd650f720cc36ae9b61b5972a19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Dulko?= Date: Fri, 9 Sep 2016 16:01:27 +0200 Subject: [PATCH] Fix creating typeless volumes with Mitaka's c-sch In Mitaka as a workaround for creating volumes without volume type c-api was sending an empty dictionary as request_spec['volume_type'] in create_volume() RPC cast to scheduler. This changed in Newton and we're handling this situation directly in scheduler, but when running Newton's c-api with Mitaka's c-sch we should mimic older behavior. This patch implements that. Change-Id: I3dbb1934f3d8e68fef49f56155cbf59bc5fadc3a Closes-Bug: 1619008 (cherry picked from commit 91bdf9de4c1e0726892384605704d87b318e7a69) --- cinder/scheduler/rpcapi.py | 4 ++++ cinder/tests/unit/scheduler/test_rpcapi.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cinder/scheduler/rpcapi.py b/cinder/scheduler/rpcapi.py index 772a413dc..103a892ad 100644 --- a/cinder/scheduler/rpcapi.py +++ b/cinder/scheduler/rpcapi.py @@ -123,6 +123,10 @@ class SchedulerAPI(rpc.RPCAPI): if version == '2.0': # Send request_spec as dict msg_args['request_spec'] = jsonutils.to_primitive(request_spec) + # NOTE(dulek): This is to keep supporting Mitaka's scheduler which + # expects a dictionary when creating a typeless volume. + if msg_args['request_spec'].get('volume_type') is None: + msg_args['request_spec']['volume_type'] = {} cctxt = self.client.prepare(version=version) return cctxt.cast(ctxt, 'create_volume', **msg_args) diff --git a/cinder/tests/unit/scheduler/test_rpcapi.py b/cinder/tests/unit/scheduler/test_rpcapi.py index d61b2c142..3014aa36e 100644 --- a/cinder/tests/unit/scheduler/test_rpcapi.py +++ b/cinder/tests/unit/scheduler/test_rpcapi.py @@ -116,7 +116,7 @@ class SchedulerRpcAPITestCase(test.TestCase): volume_id=self.volume_id, snapshot_id='snapshot_id', image_id='image_id', - request_spec='fake_request_spec', + request_spec={'volume_type': {}}, filter_properties='filter_properties', volume=fake_volume.fake_volume_obj( self.context),