]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Get the 'consumer' in a correct way for retyping with qos-specs
authorVincent Hou <sbhou@cn.ibm.com>
Tue, 25 Nov 2014 07:36:07 +0000 (23:36 -0800)
committerVincent Hou <sbhou@cn.ibm.com>
Wed, 26 Nov 2014 02:07:27 +0000 (02:07 +0000)
The qos specs returned from the database does not contain the
property "qos-specs". Intead, the property "consumer" can be accessed
directly.

Change-Id: I3fe57e5cc20a97d32c8b8c6089ab1e812257da45
closes-bug: #1389519

cinder/tests/api/contrib/test_volume_actions.py
cinder/volume/api.py

index a8c0cecd986e8ea968721a92bd4df226b8f5b721..a3e1113a4cd5bd639b1488be90b28169538ae8b0 100644 (file)
@@ -357,7 +357,8 @@ class VolumeRetypeActionsTest(VolumeActionsTest):
         # Test that the retype API works for both available and in-use
         self._retype_volume_exec(202)
         self.mock_volume_get.return_value['status'] = 'in-use'
-        specs = {'qos_specs': {'id': 'fakeqid1', 'consumer': 'back-end'}}
+        specs = {'id': 'fakeqid1', 'name': 'fake_name1',
+                 'consumer': 'back-end', 'specs': {'key1': 'value1'}}
         _mock_get_qspecs.return_value = specs
         self._retype_volume_exec(202)
 
@@ -408,9 +409,11 @@ class VolumeRetypeActionsTest(VolumeActionsTest):
     def _retype_volume_diff_qos(self, vol_status, consumer, expected_status,
                                 _mock_get_qspecs):
         def fake_get_qos(ctxt, qos_id):
-            d1 = {'qos_specs': {'id': 'fakeqid1', 'consumer': consumer}}
-            d2 = {'qos_specs': {'id': 'fakeqid2', 'consumer': consumer}}
-            return d1 if d1['qos_specs']['id'] == qos_id else d2
+            d1 = {'id': 'fakeqid1', 'name': 'fake_name1',
+                  'consumer': consumer, 'specs': {'key1': 'value1'}}
+            d2 = {'id': 'fakeqid2', 'name': 'fake_name2',
+                  'consumer': consumer, 'specs': {'key1': 'value1'}}
+            return d1 if d1['id'] == qos_id else d2
 
         self.mock_volume_get.return_value['status'] = vol_status
         _mock_get_qspecs.side_effect = fake_get_qos
index 1f2ab593cfdbe866688152d77a9ed069e2b245cd..237e07c3433b3aa900d3ac37a52900300bcf2639 100644 (file)
@@ -1202,7 +1202,7 @@ class API(base.Base):
             for qos_id in [old_vol_type_qos_id, vol_type_qos_id]:
                 if qos_id:
                     specs = qos_specs.get_qos_specs(context.elevated(), qos_id)
-                    if specs['qos_specs']['consumer'] != 'back-end':
+                    if specs['consumer'] != 'back-end':
                         msg = _('Retype cannot change front-end qos specs for '
                                 'in-use volumes')
                         raise exception.InvalidInput(reason=msg)