Catch FixedIpNotFoundForAddress when create server

FixedIpNotFoundForAddress is not catched during server creation,
so 500 error is reported to client side.

Change-Id: I3cd45cd63c962225d6a893ad0fdeb01ecb94e784
Closes-Bug: 1522349
This commit is contained in:
jichenjc 2015-11-24 01:54:40 +08:00
parent c087e5fcd0
commit e1cd13f862
2 changed files with 10 additions and 0 deletions

View File

@ -627,6 +627,7 @@ class ServersController(wsgi.Controller):
raise exc.HTTPBadRequest(explanation=msg)
except (exception.ImageNotActive,
exception.ImageBadRequest,
exception.FixedIpNotFoundForAddress,
exception.FlavorDiskTooSmall,
exception.FlavorMemoryTooSmall,
exception.InvalidMetadata,

View File

@ -2983,6 +2983,15 @@ class ServersControllerCreateTest(test.TestCase):
self.controller.create,
self.req, body=self.body)
@mock.patch.object(compute_api.API, 'create',
side_effect=exception.FixedIpNotFoundForAddress(
address='dummy'))
def test_create_instance_raise_fixed_ip_not_found_bad_request(self,
mock_create):
self.assertRaises(webob.exc.HTTPBadRequest,
self.controller.create,
self.req, body=self.body)
@mock.patch.object(compute_api.API, 'create')
def test_create_instance_invalid_personality(self, mock_create):
codec = 'utf8'