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
This commit is contained in:
Ken'ichi Ohmichi 2014-02-10 23:21:38 +09:00
parent 609329fda5
commit b699c703e0
3 changed files with 8 additions and 9 deletions

View File

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

View File

@ -75,9 +75,10 @@ class SchedulerHintsTestCase(test.TestCase):
self.assertEqual(202, res.status_int)
def test_create_server_with_hints(self):
hints = {'same_host': '48e6a9f6-30af-47e0-bc04-acaed113bb4e'}
def fake_create(*args, **kwargs):
self.assertEqual(kwargs['scheduler_hints'], {'a': 'b'})
self.assertEqual(hints, kwargs['scheduler_hints'])
return ([self.fake_instance], '')
self.stubs.Set(nova.compute.api.API, 'create', fake_create)
@ -90,7 +91,7 @@ class SchedulerHintsTestCase(test.TestCase):
'name': 'server_test',
'image_ref': 'cedef40a-ed67-4d10-800e-17455edce175',
'flavor_ref': '1',
'os-scheduler-hints:scheduler_hints': {'a': 'b'},
'os-scheduler-hints:scheduler_hints': hints,
},
}
@ -227,7 +228,7 @@ class ServersControllerCreateTest(test.TestCase):
server = self.controller.create(req, body).obj['server']
def test_create_instance_with_scheduler_hints_disabled(self):
hints = {'a': 'b'}
hints = {'same_host': '48e6a9f6-30af-47e0-bc04-acaed113bb4e'}
params = {'os-scheduler-hints:scheduler_hints': hints}
old_create = compute_api.API.create
@ -241,7 +242,7 @@ class ServersControllerCreateTest(test.TestCase):
override_controller=self.no_scheduler_hints_controller)
def test_create_instance_with_scheduler_hints_enabled(self):
hints = {'a': 'b'}
hints = {'same_host': '48e6a9f6-30af-47e0-bc04-acaed113bb4e'}
params = {'os-scheduler-hints:scheduler_hints': hints}
old_create = compute_api.API.create

View File

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