Merge "Return HTTP 400 on boot for invalid availability zone"
This commit is contained in:
commit
8b162eb7be
@ -589,7 +589,11 @@ class ServersController(wsgi.Controller):
|
||||
# TODO(Shao He, Feng) move this policy check to os-availabilty-zone
|
||||
# extension after refactor it.
|
||||
parse_az = self.compute_api.parse_availability_zone
|
||||
availability_zone, host, node = parse_az(context, availability_zone)
|
||||
try:
|
||||
availability_zone, host, node = parse_az(context,
|
||||
availability_zone)
|
||||
except exception.InvalidInput as err:
|
||||
raise exc.HTTPBadRequest(explanation=six.text_type(err))
|
||||
if host or node:
|
||||
authorize(context, {}, 'create:forced_host')
|
||||
|
||||
|
@ -3321,6 +3321,12 @@ class ServersControllerCreateTest(test.TestCase):
|
||||
self.controller.create,
|
||||
self.req, body=self.body)
|
||||
|
||||
def test_create_instance_invalid_availability_zone(self):
|
||||
self.body['server']['availability_zone'] = 'invalid::::zone'
|
||||
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||
self.controller.create,
|
||||
self.req, body=self.body)
|
||||
|
||||
@mock.patch.object(compute_api.API, 'create',
|
||||
side_effect=exception.FixedIpNotFoundForAddress(
|
||||
address='dummy'))
|
||||
|
Loading…
Reference in New Issue
Block a user