Fix server_groups schema on v2.1 API
The combination of 'not' and 'allOf' doesn't work fine, and nova v2.1 test fails now. This patch replaces the combination with a standard way. Change-Id: I5dbd764460ba757835d569e7613970b3e658e886 Closes-Bug: #1412973
This commit is contained in:
parent
8232b61828
commit
9595d09e05
@ -131,6 +131,12 @@ class ServerGroupController(wsgi.Controller):
|
||||
"""Creates a new server group."""
|
||||
context = _authorize_context(req)
|
||||
|
||||
policies = body['server_group']['policies']
|
||||
if ('anti-affinity' in policies and
|
||||
'affinity' in policies):
|
||||
msg = _("Conflicting policies configured!")
|
||||
raise exc.HTTPBadRequest(explanation=msg)
|
||||
|
||||
quotas = objects.Quotas()
|
||||
try:
|
||||
quotas.reserve(context, project_id=context.project_id,
|
||||
|
@ -30,13 +30,7 @@ create = {
|
||||
'policies': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'string', 'enum': SUPPORTED_POLICIES,
|
||||
'not': {'allOf': [
|
||||
# NOTE: Clients cannot specify both affinity and
|
||||
# anti-affinity in a single request.
|
||||
{'enum': 'affinity'},
|
||||
{'enum': 'anti-affinity'}
|
||||
]}
|
||||
'type': 'string', 'enum': SUPPORTED_POLICIES
|
||||
},
|
||||
'uniqueItems': True,
|
||||
'minItems': 1
|
||||
|
@ -208,7 +208,7 @@ class ServerGroupTestV21(test.TestCase):
|
||||
sgroup = server_group_template()
|
||||
policies = ['anti-affinity', 'affinity']
|
||||
sgroup['policies'] = policies
|
||||
self.assertRaises(self.validation_error, self.controller.create,
|
||||
self.assertRaises(webob.exc.HTTPBadRequest, self.controller.create,
|
||||
self.req, body={'server_group': sgroup})
|
||||
|
||||
def test_create_server_group_with_duplicate_policies(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user