Merge "Add API schema for v2.1 'removeFloatingIp'"
This commit is contained in:
commit
c46bfcfaeb
|
@ -247,19 +247,13 @@ class FloatingIPActionController(wsgi.Controller):
|
||||||
|
|
||||||
@extensions.expected_errors((400, 403, 404, 409))
|
@extensions.expected_errors((400, 403, 404, 409))
|
||||||
@wsgi.action('removeFloatingIp')
|
@wsgi.action('removeFloatingIp')
|
||||||
|
@validation.schema(floating_ips.remove_floating_ip)
|
||||||
def _remove_floating_ip(self, req, id, body):
|
def _remove_floating_ip(self, req, id, body):
|
||||||
"""Dissociate floating_ip from an instance."""
|
"""Dissociate floating_ip from an instance."""
|
||||||
context = req.environ['nova.context']
|
context = req.environ['nova.context']
|
||||||
authorize(context)
|
authorize(context)
|
||||||
|
|
||||||
try:
|
|
||||||
address = body['removeFloatingIp']['address']
|
address = body['removeFloatingIp']['address']
|
||||||
except TypeError:
|
|
||||||
msg = _("Missing parameter dict")
|
|
||||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
|
||||||
except KeyError:
|
|
||||||
msg = _("Address not specified")
|
|
||||||
raise webob.exc.HTTPBadRequest(explanation=msg)
|
|
||||||
|
|
||||||
# get the floating ip object
|
# get the floating ip object
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -32,3 +32,19 @@ add_floating_ip = {
|
||||||
'required': ['addFloatingIp'],
|
'required': ['addFloatingIp'],
|
||||||
'additionalProperties': False
|
'additionalProperties': False
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove_floating_ip = {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'removeFloatingIp': {
|
||||||
|
'type': 'object',
|
||||||
|
'properties': {
|
||||||
|
'address': parameter_types.ip_address
|
||||||
|
},
|
||||||
|
'required': ['address'],
|
||||||
|
'additionalProperties': False
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'required': ['removeFloatingIp'],
|
||||||
|
'additionalProperties': False
|
||||||
|
}
|
||||||
|
|
|
@ -553,7 +553,7 @@ class FloatingIpTestV21(test.TestCase):
|
||||||
body = dict(removeFloatingIp=dict(address='10.10.10.10'))
|
body = dict(removeFloatingIp=dict(address='10.10.10.10'))
|
||||||
|
|
||||||
rsp = self.manager._remove_floating_ip(self.fake_req, 'test_inst',
|
rsp = self.manager._remove_floating_ip(self.fake_req, 'test_inst',
|
||||||
body)
|
body=body)
|
||||||
self.assertEqual(202, rsp.status_int)
|
self.assertEqual(202, rsp.status_int)
|
||||||
|
|
||||||
def test_floating_ip_disassociate_missing(self):
|
def test_floating_ip_disassociate_missing(self):
|
||||||
|
@ -561,7 +561,7 @@ class FloatingIpTestV21(test.TestCase):
|
||||||
|
|
||||||
self.assertRaises(webob.exc.HTTPConflict,
|
self.assertRaises(webob.exc.HTTPConflict,
|
||||||
self.manager._remove_floating_ip,
|
self.manager._remove_floating_ip,
|
||||||
self.fake_req, 'test_inst', body)
|
self.fake_req, 'test_inst', body=body)
|
||||||
|
|
||||||
def test_floating_ip_associate_non_existent_ip(self):
|
def test_floating_ip_associate_non_existent_ip(self):
|
||||||
def fake_network_api_associate(self, context, instance,
|
def fake_network_api_associate(self, context, instance,
|
||||||
|
@ -594,7 +594,7 @@ class FloatingIpTestV21(test.TestCase):
|
||||||
body = dict(removeFloatingIp=dict(address='1.1.1.1'))
|
body = dict(removeFloatingIp=dict(address='1.1.1.1'))
|
||||||
self.assertRaises(webob.exc.HTTPNotFound,
|
self.assertRaises(webob.exc.HTTPNotFound,
|
||||||
self.manager._remove_floating_ip,
|
self.manager._remove_floating_ip,
|
||||||
self.fake_req, 'test_inst', body)
|
self.fake_req, 'test_inst', body=body)
|
||||||
|
|
||||||
def test_floating_ip_disassociate_wrong_instance_uuid(self):
|
def test_floating_ip_disassociate_wrong_instance_uuid(self):
|
||||||
def get_instance_by_floating_ip_addr(self, context, address):
|
def get_instance_by_floating_ip_addr(self, context, address):
|
||||||
|
@ -609,7 +609,7 @@ class FloatingIpTestV21(test.TestCase):
|
||||||
|
|
||||||
self.assertRaises(webob.exc.HTTPConflict,
|
self.assertRaises(webob.exc.HTTPConflict,
|
||||||
self.manager._remove_floating_ip,
|
self.manager._remove_floating_ip,
|
||||||
self.fake_req, wrong_uuid, body)
|
self.fake_req, wrong_uuid, body=body)
|
||||||
|
|
||||||
def test_floating_ip_disassociate_wrong_instance_id(self):
|
def test_floating_ip_disassociate_wrong_instance_id(self):
|
||||||
def get_instance_by_floating_ip_addr(self, context, address):
|
def get_instance_by_floating_ip_addr(self, context, address):
|
||||||
|
@ -623,7 +623,7 @@ class FloatingIpTestV21(test.TestCase):
|
||||||
|
|
||||||
self.assertRaises(webob.exc.HTTPConflict,
|
self.assertRaises(webob.exc.HTTPConflict,
|
||||||
self.manager._remove_floating_ip,
|
self.manager._remove_floating_ip,
|
||||||
self.fake_req, 'test_inst', body)
|
self.fake_req, 'test_inst', body=body)
|
||||||
|
|
||||||
def test_floating_ip_disassociate_auto_assigned(self):
|
def test_floating_ip_disassociate_auto_assigned(self):
|
||||||
def fake_get_floating_ip_addr_auto_assigned(self, context, address):
|
def fake_get_floating_ip_addr_auto_assigned(self, context, address):
|
||||||
|
@ -647,7 +647,7 @@ class FloatingIpTestV21(test.TestCase):
|
||||||
body = dict(removeFloatingIp=dict(address='10.10.10.10'))
|
body = dict(removeFloatingIp=dict(address='10.10.10.10'))
|
||||||
self.assertRaises(webob.exc.HTTPForbidden,
|
self.assertRaises(webob.exc.HTTPForbidden,
|
||||||
self.manager._remove_floating_ip,
|
self.manager._remove_floating_ip,
|
||||||
self.fake_req, 'test_inst', body)
|
self.fake_req, 'test_inst', body=body)
|
||||||
|
|
||||||
def test_floating_ip_disassociate_map_authorization_exc(self):
|
def test_floating_ip_disassociate_map_authorization_exc(self):
|
||||||
def fake_get_floating_ip_addr_auto_assigned(self, context, address):
|
def fake_get_floating_ip_addr_auto_assigned(self, context, address):
|
||||||
|
@ -670,23 +670,23 @@ class FloatingIpTestV21(test.TestCase):
|
||||||
body = dict(removeFloatingIp=dict(address='10.10.10.10'))
|
body = dict(removeFloatingIp=dict(address='10.10.10.10'))
|
||||||
self.assertRaises(webob.exc.HTTPForbidden,
|
self.assertRaises(webob.exc.HTTPForbidden,
|
||||||
self.manager._remove_floating_ip,
|
self.manager._remove_floating_ip,
|
||||||
self.fake_req, 'test_inst', body)
|
self.fake_req, 'test_inst', body=body)
|
||||||
|
|
||||||
# these are a few bad param tests
|
# these are a few bad param tests
|
||||||
|
|
||||||
def test_bad_address_param_in_remove_floating_ip(self):
|
def test_bad_address_param_in_remove_floating_ip(self):
|
||||||
body = dict(removeFloatingIp=dict(badparam='11.0.0.1'))
|
body = dict(removeFloatingIp=dict(badparam='11.0.0.1'))
|
||||||
|
|
||||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
self.assertRaises(self.validation_error,
|
||||||
self.manager._remove_floating_ip, self.fake_req,
|
self.manager._remove_floating_ip, self.fake_req,
|
||||||
'test_inst', body)
|
'test_inst', body=body)
|
||||||
|
|
||||||
def test_missing_dict_param_in_remove_floating_ip(self):
|
def test_missing_dict_param_in_remove_floating_ip(self):
|
||||||
body = dict(removeFloatingIp='11.0.0.1')
|
body = dict(removeFloatingIp='11.0.0.1')
|
||||||
|
|
||||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
self.assertRaises(self.validation_error,
|
||||||
self.manager._remove_floating_ip, self.fake_req,
|
self.manager._remove_floating_ip, self.fake_req,
|
||||||
'test_inst', body)
|
'test_inst', body=body)
|
||||||
|
|
||||||
def test_missing_dict_param_in_add_floating_ip(self):
|
def test_missing_dict_param_in_add_floating_ip(self):
|
||||||
body = dict(addFloatingIp='11.0.0.1')
|
body = dict(addFloatingIp='11.0.0.1')
|
||||||
|
|
Loading…
Reference in New Issue