From 91bdf9de4c1e0726892384605704d87b318e7a69 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 --- 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 2b128bdc9..602c11097 100644 --- a/cinder/scheduler/rpcapi.py +++ b/cinder/scheduler/rpcapi.py @@ -112,6 +112,10 @@ class SchedulerAPI(rpc.RPCAPI): # Send request_spec as dict version = '2.0' 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 040d70cf4..dc73da7d2 100644 --- a/cinder/tests/unit/scheduler/test_rpcapi.py +++ b/cinder/tests/unit/scheduler/test_rpcapi.py @@ -109,7 +109,7 @@ class SchedulerRpcAPITestCase(test.TestCase): volume_id='volume_id', snapshot_id='snapshot_id', image_id='image_id', - request_spec='fake_request_spec', + request_spec={'volume_type': {}}, filter_properties='filter_properties', volume='volume', version='2.0')