diff options
| author | Martin Packman <martin.packman@canonical.com> | 2012-06-08 15:08:48 +0100 |
|---|---|---|
| committer | Martin Packman <martin.packman@canonical.com> | 2012-06-18 18:10:25 +0100 |
| commit | 984435b1edc9ab0ec3d33e809babd04884e96ff1 (patch) | |
| tree | 55997fbecf571392f9ea684f9007507f75dd4cfb /nova/api | |
| parent | 6279e16ae1693cd3cae4f0b30e9412052ca356ab (diff) | |
| download | nova-984435b1edc9ab0ec3d33e809babd04884e96ff1.tar.gz nova-984435b1edc9ab0ec3d33e809babd04884e96ff1.tar.xz nova-984435b1edc9ab0ec3d33e809babd04884e96ff1.zip | |
Handle missing server when getting security groups
Fix bug 1010486.
Treat InstanceNotFound as a 404 when querying the security groups of server
that does not exist. Also removes old exception translation, ApiError no
longer exists and NotAuthorized shouldn't need handling at this level.
Includes tweak suggested by Mark McLoughlin in review.
Change-Id: Iaeada84dbadc232968f792c6f4855bf61cc5a5ae
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/compute/contrib/security_groups.py | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/nova/api/openstack/compute/contrib/security_groups.py b/nova/api/openstack/compute/contrib/security_groups.py index 5e81347ec..840813d68 100644 --- a/nova/api/openstack/compute/contrib/security_groups.py +++ b/nova/api/openstack/compute/contrib/security_groups.py @@ -385,12 +385,10 @@ class ServerSecurityGroupController(SecurityGroupControllerBase): try: instance = self.compute_api.get(context, server_id) - groups = db.security_group_get_by_instance(context, - instance['id']) - except exception.ApiError, e: - raise webob.exc.HTTPBadRequest(explanation=e.message) - except exception.NotAuthorized, e: - raise webob.exc.HTTPUnauthorized() + except exception.InstanceNotFound as exp: + raise exc.HTTPNotFound(explanation=unicode(exp)) + + groups = db.security_group_get_by_instance(context, instance['id']) result = [self._format_security_group(context, group) for group in groups] |
