From dfa3a93ba434a4c79f28f72570d6dddc864bf53e Mon Sep 17 00:00:00 2001 From: Stephen Ahn Date: Thu, 20 Feb 2014 13:27:38 +0900 Subject: [PATCH] Wrong hint key in volume create function Hint key has to be 'OS-SCH-HNT:scheduler_hints' not 'scheduler_hints' and scheduler_hints key has to be located in same level with volume. Change-Id: Ic5888545d4b7ee6bb58a22840928ef1fc86fedfa Closes-Bug: #1276088 --- .mailmap | 1 + cinderclient/tests/v2/test_volumes.py | 18 ++++++++++++++++++ cinderclient/v2/volumes.py | 5 ++++- 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/.mailmap b/.mailmap index f270bb6f5..f643222c8 100644 --- a/.mailmap +++ b/.mailmap @@ -13,3 +13,4 @@ Andy Smith termie Nikolay Sokolov Nokolay Sokolov Nikolay Sokolov Nokolay Sokolov + diff --git a/cinderclient/tests/v2/test_volumes.py b/cinderclient/tests/v2/test_volumes.py index 5e128123f..d2a0610c1 100644 --- a/cinderclient/tests/v2/test_volumes.py +++ b/cinderclient/tests/v2/test_volumes.py @@ -36,6 +36,24 @@ class VolumesTest(utils.TestCase): cs.volumes.create(1) cs.assert_called('POST', '/volumes') + def test_create_volume_with_hint(self): + cs.volumes.create(1, scheduler_hints='uuid') + expected = {'volume': {'status': 'creating', + 'description': None, + 'availability_zone': None, + 'source_volid': None, + 'snapshot_id': None, + 'size': 1, + 'user_id': None, + 'name': None, + 'imageRef': None, + 'attach_status': 'detached', + 'volume_type': None, + 'project_id': None, + 'metadata': {}}, + 'OS-SCH-HNT:scheduler_hints': 'uuid'} + cs.assert_called('POST', '/volumes', body=expected) + def test_attach(self): v = cs.volumes.get('1234') cs.volumes.attach(v, 1, '/dev/vdc', mode='ro') diff --git a/cinderclient/v2/volumes.py b/cinderclient/v2/volumes.py index 524456d6e..d03385eba 100644 --- a/cinderclient/v2/volumes.py +++ b/cinderclient/v2/volumes.py @@ -180,8 +180,11 @@ class VolumeManager(base.ManagerWithFind): 'metadata': volume_metadata, 'imageRef': imageRef, 'source_volid': source_volid, - 'scheduler_hints': scheduler_hints, }} + + if scheduler_hints: + body['OS-SCH-HNT:scheduler_hints'] = scheduler_hints + return self._create('/volumes', body, 'volume') def get(self, volume_id):