Skip to content

Commit

Permalink
Correct exception handling when create aggregate
Browse files Browse the repository at this point in the history
when create an aggregate, InvalidAggregateAction might be raised,
this patch translates the InvalidAggregateAction to HTTPBadRequest.
Also, 2 unnecessary logs was removed becuase log is not output in
most BadRequest.

Change-Id: I3dac808d8edab6118e347eb5d78b96f96b9d40ca
  • Loading branch information
jichenjc committed May 27, 2014
1 parent e239791 commit 0e57a4c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions nova/api/openstack/compute/contrib/aggregates.py
Expand Up @@ -81,11 +81,9 @@ def create(self, req, body):
try:
aggregate = self.api.create_aggregate(context, name, avail_zone)
except exception.AggregateNameExists as e:
LOG.info(e)
raise exc.HTTPConflict()
raise exc.HTTPConflict(explanation=e.format_message())
except exception.InvalidAggregateAction as e:
LOG.info(e)
raise
raise exc.HTTPBadRequest(explanation=e.format_message())
return self._marshall_aggregate(aggregate)

def show(self, req, id):
Expand Down
Expand Up @@ -108,7 +108,7 @@ def stub_create_aggregate(context, name, availability_zone):
self.stubs.Set(self.controller.api, "create_aggregate",
stub_create_aggregate)

self.assertRaises(exception.InvalidAggregateAction,
self.assertRaises(exc.HTTPBadRequest,
self.controller.create,
self.req, {"aggregate":
{"name": "test",
Expand Down

0 comments on commit 0e57a4c

Please sign in to comment.