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:
Ken'ichi Ohmichi 2015-01-20 23:32:27 +00:00 committed by Adam Gandelman
parent 8232b61828
commit 9595d09e05
3 changed files with 8 additions and 8 deletions

View File

@ -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,

View File

@ -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

View File

@ -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):