Make scheduler_hints schema allow list of id
Nova v2.0 API allows a list of server_id, and the corresponding
filter handles it. However, Nova v2.1 API doesn't do that now.
That is backward incompatibile issue.
This patch fixes this issue.
NOTE: Tempest patch Ib3365ac2783a0578c7a1a1e72d9b6c9cfea340f5
is for reproducing this problem on the gate.
After this fixing, the Tempest patch can be merged and
we will be able to block this problem.
Change-Id: I1de7d184c590e84ab1b38880c8d784d38c37b820
Closes-Bug: #1521928
(cherry picked from commit 2841dd3de9
)
This commit is contained in:
parent
aa80001314
commit
9d47930c8d
|
@ -28,9 +28,16 @@ _hints = {
|
||||||
# uuids where a new server is scheduled on a different host.
|
# uuids where a new server is scheduled on a different host.
|
||||||
# A user can specify one server as string parameter and should
|
# A user can specify one server as string parameter and should
|
||||||
# specify multiple servers as array parameter instead.
|
# specify multiple servers as array parameter instead.
|
||||||
'type': ['string', 'array'],
|
'oneOf': [
|
||||||
'format': 'uuid',
|
{
|
||||||
'items': parameter_types.server_id
|
'type': 'string',
|
||||||
|
'format': 'uuid'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'type': 'array',
|
||||||
|
'items': parameter_types.server_id
|
||||||
|
}
|
||||||
|
]
|
||||||
},
|
},
|
||||||
'same_host': {
|
'same_host': {
|
||||||
# NOTE: The value of 'different_host' is the set of server
|
# NOTE: The value of 'different_host' is the set of server
|
||||||
|
|
|
@ -73,10 +73,10 @@ class SchedulerHintsTestCaseV21(test.TestCase):
|
||||||
res = req.get_response(self.app)
|
res = req.get_response(self.app)
|
||||||
self.assertEqual(202, res.status_int)
|
self.assertEqual(202, res.status_int)
|
||||||
|
|
||||||
def test_create_server_with_hints(self):
|
def _test_create_server_with_hint(self, hint):
|
||||||
|
|
||||||
def fake_create(*args, **kwargs):
|
def fake_create(*args, **kwargs):
|
||||||
self.assertEqual(kwargs['scheduler_hints'], {'group': 'foo'})
|
self.assertEqual(kwargs['scheduler_hints'], hint)
|
||||||
return ([self.fake_instance], '')
|
return ([self.fake_instance], '')
|
||||||
|
|
||||||
self.stubs.Set(nova.compute.api.API, 'create', fake_create)
|
self.stubs.Set(nova.compute.api.API, 'create', fake_create)
|
||||||
|
@ -90,13 +90,24 @@ class SchedulerHintsTestCaseV21(test.TestCase):
|
||||||
'imageRef': 'cedef40a-ed67-4d10-800e-17455edce175',
|
'imageRef': 'cedef40a-ed67-4d10-800e-17455edce175',
|
||||||
'flavorRef': '1',
|
'flavorRef': '1',
|
||||||
},
|
},
|
||||||
'os:scheduler_hints': {'group': 'foo'},
|
'os:scheduler_hints': hint,
|
||||||
}
|
}
|
||||||
|
|
||||||
req.body = jsonutils.dumps(body)
|
req.body = jsonutils.dumps(body)
|
||||||
res = req.get_response(self.app)
|
res = req.get_response(self.app)
|
||||||
self.assertEqual(202, res.status_int)
|
self.assertEqual(202, res.status_int)
|
||||||
|
|
||||||
|
def test_create_server_with_group_hint(self):
|
||||||
|
self._test_create_server_with_hint({'group': 'foo'})
|
||||||
|
|
||||||
|
def test_create_server_with_different_host_hint(self):
|
||||||
|
self._test_create_server_with_hint(
|
||||||
|
{'different_host': '9c47bf55-e9d8-42da-94ab-7f9e80cd1857'})
|
||||||
|
|
||||||
|
self._test_create_server_with_hint(
|
||||||
|
{'different_host': ['9c47bf55-e9d8-42da-94ab-7f9e80cd1857',
|
||||||
|
'82412fa6-0365-43a9-95e4-d8b20e00c0de']})
|
||||||
|
|
||||||
def _create_server_with_scheduler_hints_bad_request(self, param):
|
def _create_server_with_scheduler_hints_bad_request(self, param):
|
||||||
req = self._get_request()
|
req = self._get_request()
|
||||||
req.method = 'POST'
|
req.method = 'POST'
|
||||||
|
@ -120,6 +131,13 @@ class SchedulerHintsTestCaseV21(test.TestCase):
|
||||||
param = {'group': 'a' * 256}
|
param = {'group': 'a' * 256}
|
||||||
self._create_server_with_scheduler_hints_bad_request(param)
|
self._create_server_with_scheduler_hints_bad_request(param)
|
||||||
|
|
||||||
|
def test_create_server_with_bad_different_host_hint(self):
|
||||||
|
param = {'different_host': 'non-server-id'}
|
||||||
|
self._create_server_with_scheduler_hints_bad_request(param)
|
||||||
|
|
||||||
|
param = {'different_host': ['non-server-id01', 'non-server-id02']}
|
||||||
|
self._create_server_with_scheduler_hints_bad_request(param)
|
||||||
|
|
||||||
|
|
||||||
class SchedulerHintsTestCaseV2(SchedulerHintsTestCaseV21):
|
class SchedulerHintsTestCaseV2(SchedulerHintsTestCaseV21):
|
||||||
|
|
||||||
|
@ -138,6 +156,11 @@ class SchedulerHintsTestCaseV2(SchedulerHintsTestCaseV21):
|
||||||
# We skip this test for v2.0.
|
# We skip this test for v2.0.
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def test_create_server_with_bad_different_host_hint(self):
|
||||||
|
# NOTE: v2.0 API cannot handle this bad request case now.
|
||||||
|
# We skip this test for v2.0.
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ServersControllerCreateTestV21(test.TestCase):
|
class ServersControllerCreateTestV21(test.TestCase):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue