diff options
| author | Joe Gordon <jogo@cloudscaling.com> | 2012-11-26 22:55:19 +0000 |
|---|---|---|
| committer | Joe Gordon <jogo@cloudscaling.com> | 2012-11-26 16:24:41 -0800 |
| commit | 4e43747037058522087e6eb71ef3bcce266d55cc (patch) | |
| tree | c83969e1c370f966d8fdaca7179a10574387ef3d | |
| parent | 0e4e6edb06951dc836651697c2dc6bd0a7d0f862 (diff) | |
| download | nova-4e43747037058522087e6eb71ef3bcce266d55cc.tar.gz nova-4e43747037058522087e6eb71ef3bcce266d55cc.tar.xz nova-4e43747037058522087e6eb71ef3bcce266d55cc.zip | |
Provide better error message for aggregate-create
For an InvalidAggregateAction exception:
Before: 'ERROR: There was a conflict when trying to complete your request (HTTP 409)'
After: 'ERROR: Cannot perform action 'create_aggregate' on aggregate 'N/A'. Reason: invalid zone. (HTTP 400)'
Fix bug 1083353
Change-Id: I26e30059fe5bbc30eecc52cccec4eba2a57d00db
| -rw-r--r-- | nova/api/openstack/compute/contrib/aggregates.py | 9 | ||||
| -rw-r--r-- | nova/tests/api/openstack/compute/contrib/test_aggregates.py | 8 |
2 files changed, 11 insertions, 6 deletions
diff --git a/nova/api/openstack/compute/contrib/aggregates.py b/nova/api/openstack/compute/contrib/aggregates.py index 9435f5980..ef9679f5a 100644 --- a/nova/api/openstack/compute/contrib/aggregates.py +++ b/nova/api/openstack/compute/contrib/aggregates.py @@ -71,11 +71,12 @@ class AggregateController(object): try: aggregate = self.api.create_aggregate(context, name, avail_zone) - except (exception.AggregateNameExists, - exception.InvalidAggregateAction): - LOG.info(_("Cannot create aggregate with name %(name)s and " - "availability zone %(avail_zone)s") % locals()) + except exception.AggregateNameExists as e: + LOG.info(e) raise exc.HTTPConflict + except exception.InvalidAggregateAction as e: + LOG.info(e) + raise return self._marshall_aggregate(aggregate) def show(self, req, id): diff --git a/nova/tests/api/openstack/compute/contrib/test_aggregates.py b/nova/tests/api/openstack/compute/contrib/test_aggregates.py index a209fdce8..41a87ac6a 100644 --- a/nova/tests/api/openstack/compute/contrib/test_aggregates.py +++ b/nova/tests/api/openstack/compute/contrib/test_aggregates.py @@ -89,11 +89,15 @@ class AggregateTestCase(test.TestCase): def test_create_with_incorrect_availability_zone(self): def stub_create_aggregate(context, name, availability_zone): - raise exception.InvalidAggregateAction + raise exception.InvalidAggregateAction(action='create_aggregate', + aggregate_id="'N/A'", + reason='invalid zone') + self.stubs.Set(self.controller.api, "create_aggregate", stub_create_aggregate) - self.assertRaises(exc.HTTPConflict, self.controller.create, + self.assertRaises(exception.InvalidAggregateAction, + self.controller.create, self.req, {"aggregate": {"name": "test", "availability_zone": "nova_bad"}}) |
