diff --git a/nova/api/openstack/compute/schemas/security_groups.py b/nova/api/openstack/compute/schemas/security_groups.py index 6b762b259e..b376c600ae 100644 --- a/nova/api/openstack/compute/schemas/security_groups.py +++ b/nova/api/openstack/compute/schemas/security_groups.py @@ -111,11 +111,19 @@ server_sg_index_query = { add_security_group = { 'type': 'object', 'properties': { - 'name': { - 'type': 'string', - 'minLength': 1, - }, + 'addSecurityGroup': { + 'type': 'object', + 'properties': { + 'name': { + 'type': 'string', + 'minLength': 1, + }, + }, + 'required': ['name'], + 'additionalProperties': False + } }, + 'required': ['addSecurityGroup'], 'additionalProperties': True, } @@ -123,11 +131,19 @@ add_security_group = { remove_security_group = { 'type': 'object', 'properties': { - 'name': { - 'type': 'string', - 'minLength': 1, - }, + 'removeSecurityGroup': { + 'type': 'object', + 'properties': { + 'name': { + 'type': 'string', + 'minLength': 1, + }, + }, + 'required': ['name'], + 'additionalProperties': False + } }, + 'required': ['removeSecurityGroup'], 'additionalProperties': True, } diff --git a/nova/tests/unit/api/openstack/compute/test_security_groups.py b/nova/tests/unit/api/openstack/compute/test_security_groups.py index 4c9693703b..98342c6bb4 100644 --- a/nova/tests/unit/api/openstack/compute/test_security_groups.py +++ b/nova/tests/unit/api/openstack/compute/test_security_groups.py @@ -728,14 +728,14 @@ class TestSecurityGroupsV21(test.TestCase): body = dict(addSecurityGroup=None) self.assertRaises( - webob.exc.HTTPBadRequest, + exception.ValidationError, self.manager._addSecurityGroup, self.req, '1', body=body) def test_associate_no_security_group_name(self): body = dict(addSecurityGroup=dict()) self.assertRaises( - webob.exc.HTTPBadRequest, + exception.ValidationError, self.manager._addSecurityGroup, self.req, '1', body=body) def test_associate_security_group_name_with_whitespaces(self): @@ -846,14 +846,14 @@ class TestSecurityGroupsV21(test.TestCase): def test_disassociate_without_body(self): body = dict(removeSecurityGroup=None) - self.assertRaises(webob.exc.HTTPBadRequest, + self.assertRaises(exception.ValidationError, self.manager._removeSecurityGroup, self.req, '1', body=body) def test_disassociate_no_security_group_name(self): body = dict(removeSecurityGroup=dict()) - self.assertRaises(webob.exc.HTTPBadRequest, + self.assertRaises(exception.ValidationError, self.manager._removeSecurityGroup, self.req, '1', body=body)