Skip to content

Commit

Permalink
Fixes bug 942549
Browse files Browse the repository at this point in the history
Ensure a more meaninful error is reported when an aggregate is created in a
non-exsistent availability zone.

Change-Id: I15ea6c884bb6f326df1d88019ee0ecf070196d1e
  • Loading branch information
John Garbutt committed Feb 28, 2012
1 parent 85f844c commit 9f7595a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion nova/api/openstack/compute/contrib/aggregates.py
Expand Up @@ -72,7 +72,8 @@ def create(self, req, body):

try:
aggregate = self.api.create_aggregate(context, name, avail_zone)
except exception.AggregateNameExists:
except (exception.AggregateNameExists,
exception.InvalidAggregateAction):
LOG.exception(_("Cannot create aggregate with name %(name)s and "
"availability zone %(avail_zone)s") % locals())
raise exc.HTTPConflict
Expand Down
11 changes: 11 additions & 0 deletions nova/tests/api/openstack/compute/contrib/test_aggregates.py
Expand Up @@ -87,6 +87,17 @@ def stub_create_aggregate(context, name, availability_zone):
{"name": "test",
"availability_zone": "nova1"}})

def test_create_with_incorrect_availability_zone(self):
def stub_create_aggregate(context, name, availability_zone):
raise exception.InvalidAggregateAction
self.stubs.Set(self.controller.api, "create_aggregate",
stub_create_aggregate)

self.assertRaises(exc.HTTPConflict, self.controller.create,
self.req, {"aggregate":
{"name": "test",
"availability_zone": "nova_bad"}})

def test_create_with_no_aggregate(self):
self.assertRaises(exc.HTTPBadRequest, self.controller.create,
self.req, {"foo":
Expand Down

0 comments on commit 9f7595a

Please sign in to comment.