Browse Source

Fix the sample and unittest params of v3 scheduler-hints

The API samples of scheduler-hints contains "hypervisor" and "near"
attributes, but the attributes do not exist in the scheduler-hints
parameter of "create a server" API. This patch changes them to the
existing "same_host" attribute.
This patch also changes the attributes of some unit tests of the v3
scheduler-hints by the same attribute.

This nonexistent attributes are found during bp/nova-api-validation-fw
works. The implementation needs this change because it will deny the
unexpected attributes, which are not defined with API schema, in API
parameters.

DocImpact
Closes-Bug: #1278279

Change-Id: I8542f44b325ba909fdff8b569146c0015b150291
tags/2014.1.b3
Ken'ichi Ohmichi 5 years ago
parent
commit
b699c703e0

+ 2
- 3
doc/v3/api_samples/os-scheduler-hints/scheduler-hints-post-req.json View File

@@ -4,8 +4,7 @@
4 4
         "image_ref" : "http://glance.openstack.example.com/openstack/images/70a599e0-31e7-49b7-b260-868f441e862b",
5 5
         "flavor_ref" : "http://openstack.example.com/openstack/flavors/1",
6 6
         "os-scheduler-hints:scheduler_hints": {
7
-            "hypervisor": "xen",
8
-            "near": "48e6a9f6-30af-47e0-bc04-acaed113bb4e"
7
+            "same_host": "48e6a9f6-30af-47e0-bc04-acaed113bb4e"
9 8
         }
10 9
     }
11
-}
10
+}

+ 5
- 4
nova/tests/api/openstack/compute/plugins/v3/test_scheduler_hints.py View File

@@ -75,9 +75,10 @@ class SchedulerHintsTestCase(test.TestCase):
75 75
         self.assertEqual(202, res.status_int)
76 76
 
77 77
     def test_create_server_with_hints(self):
78
+        hints = {'same_host': '48e6a9f6-30af-47e0-bc04-acaed113bb4e'}
78 79
 
79 80
         def fake_create(*args, **kwargs):
80
-            self.assertEqual(kwargs['scheduler_hints'], {'a': 'b'})
81
+            self.assertEqual(hints, kwargs['scheduler_hints'])
81 82
             return ([self.fake_instance], '')
82 83
 
83 84
         self.stubs.Set(nova.compute.api.API, 'create', fake_create)
@@ -90,7 +91,7 @@ class SchedulerHintsTestCase(test.TestCase):
90 91
                   'name': 'server_test',
91 92
                   'image_ref': 'cedef40a-ed67-4d10-800e-17455edce175',
92 93
                   'flavor_ref': '1',
93
-                  'os-scheduler-hints:scheduler_hints': {'a': 'b'},
94
+                  'os-scheduler-hints:scheduler_hints': hints,
94 95
             },
95 96
         }
96 97
 
@@ -227,7 +228,7 @@ class ServersControllerCreateTest(test.TestCase):
227 228
             server = self.controller.create(req, body).obj['server']
228 229
 
229 230
     def test_create_instance_with_scheduler_hints_disabled(self):
230
-        hints = {'a': 'b'}
231
+        hints = {'same_host': '48e6a9f6-30af-47e0-bc04-acaed113bb4e'}
231 232
         params = {'os-scheduler-hints:scheduler_hints': hints}
232 233
         old_create = compute_api.API.create
233 234
 
@@ -241,7 +242,7 @@ class ServersControllerCreateTest(test.TestCase):
241 242
                 override_controller=self.no_scheduler_hints_controller)
242 243
 
243 244
     def test_create_instance_with_scheduler_hints_enabled(self):
244
-        hints = {'a': 'b'}
245
+        hints = {'same_host': '48e6a9f6-30af-47e0-bc04-acaed113bb4e'}
245 246
         params = {'os-scheduler-hints:scheduler_hints': hints}
246 247
         old_create = compute_api.API.create
247 248
 

+ 1
- 2
nova/tests/integrated/v3/api_samples/os-scheduler-hints/scheduler-hints-post-req.json.tpl View File

@@ -4,8 +4,7 @@
4 4
         "image_ref" : "%(glance_host)s/openstack/images/%(image_id)s",
5 5
         "flavor_ref" : "%(host)s/openstack/flavors/1",
6 6
         "os-scheduler-hints:scheduler_hints": {
7
-            "hypervisor": "xen",
8
-            "near": "%(image_near)s"
7
+            "same_host": "%(uuid)s"
9 8
         }
10 9
     }
11 10
 }

Loading…
Cancel
Save