diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-05-30 21:22:11 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-05-30 21:22:11 +0000 |
| commit | ca2ee634fe4e527e378ccf8df6e5157009be79ce (patch) | |
| tree | 3e971cd3d16a7e0e3aee6e007e143813b3eba21d | |
| parent | 19cd435558df55f9b9e15d7bedc258ade123a018 (diff) | |
| parent | f7bad6d8ae52ccdc51a766242372362c616f6e81 (diff) | |
| download | nova-ca2ee634fe4e527e378ccf8df6e5157009be79ce.tar.gz nova-ca2ee634fe4e527e378ccf8df6e5157009be79ce.tar.xz nova-ca2ee634fe4e527e378ccf8df6e5157009be79ce.zip | |
Merge "Raise exception instances not exception classes"
| -rw-r--r-- | nova/api/openstack/__init__.py | 2 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/aggregates.py | 38 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/attach_interfaces.py | 2 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/baremetal_nodes.py | 8 |
4 files changed, 25 insertions, 25 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index 553bdbfaf..51a8785e2 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -257,7 +257,7 @@ class APIRouterV3(base_wsgi.Router): @property def loaded_extension_info(self): - raise NotImplementedError + raise NotImplementedError() def _register_extension(self, ext): raise NotImplementedError() diff --git a/nova/api/openstack/compute/contrib/aggregates.py b/nova/api/openstack/compute/contrib/aggregates.py index b6b9f3561..af04c9b14 100644 --- a/nova/api/openstack/compute/contrib/aggregates.py +++ b/nova/api/openstack/compute/contrib/aggregates.py @@ -36,7 +36,7 @@ def get_host_from_body(fn): if len(body) == 1 and "host" in body: host = body['host'] else: - raise exc.HTTPBadRequest + raise exc.HTTPBadRequest() return fn(self, req, id, host, *args, **kwargs) return wrapped @@ -59,21 +59,21 @@ class AggregateController(object): authorize(context) if len(body) != 1: - raise exc.HTTPBadRequest + raise exc.HTTPBadRequest() try: host_aggregate = body["aggregate"] name = host_aggregate["name"] avail_zone = host_aggregate["availability_zone"] except KeyError: - raise exc.HTTPBadRequest + raise exc.HTTPBadRequest() if len(host_aggregate) != 2: - raise exc.HTTPBadRequest + raise exc.HTTPBadRequest() try: aggregate = self.api.create_aggregate(context, name, avail_zone) except exception.AggregateNameExists as e: LOG.info(e) - raise exc.HTTPConflict + raise exc.HTTPConflict() except exception.InvalidAggregateAction as e: LOG.info(e) raise @@ -87,7 +87,7 @@ class AggregateController(object): aggregate = self.api.get_aggregate(context, id) except exception.AggregateNotFound: LOG.info(_("Cannot show aggregate: %s"), id) - raise exc.HTTPNotFound + raise exc.HTTPNotFound() return self._marshall_aggregate(aggregate) def update(self, req, id, body): @@ -96,24 +96,24 @@ class AggregateController(object): authorize(context) if len(body) != 1: - raise exc.HTTPBadRequest + raise exc.HTTPBadRequest() try: updates = body["aggregate"] except KeyError: - raise exc.HTTPBadRequest + raise exc.HTTPBadRequest() if len(updates) < 1: - raise exc.HTTPBadRequest + raise exc.HTTPBadRequest() for key in updates.keys(): if key not in ["name", "availability_zone"]: - raise exc.HTTPBadRequest + raise exc.HTTPBadRequest() try: aggregate = self.api.update_aggregate(context, id, updates) except exception.AggregateNotFound: LOG.info(_('Cannot update aggregate: %s'), id) - raise exc.HTTPNotFound + raise exc.HTTPNotFound() return self._marshall_aggregate(aggregate) @@ -125,7 +125,7 @@ class AggregateController(object): self.api.delete_aggregate(context, id) except exception.AggregateNotFound: LOG.info(_('Cannot delete aggregate: %s'), id) - raise exc.HTTPNotFound + raise exc.HTTPNotFound() def action(self, req, id, body): _actions = { @@ -152,12 +152,12 @@ class AggregateController(object): except (exception.AggregateNotFound, exception.ComputeHostNotFound): LOG.info(_('Cannot add host %(host)s in aggregate %(id)s'), {'host': host, 'id': id}) - raise exc.HTTPNotFound + raise exc.HTTPNotFound() except (exception.AggregateHostExists, exception.InvalidAggregateAction): LOG.info(_('Cannot add host %(host)s in aggregate %(id)s'), {'host': host, 'id': id}) - raise exc.HTTPConflict + raise exc.HTTPConflict() return self._marshall_aggregate(aggregate) @get_host_from_body @@ -171,11 +171,11 @@ class AggregateController(object): exception.ComputeHostNotFound): LOG.info(_('Cannot remove host %(host)s in aggregate %(id)s'), {'host': host, 'id': id}) - raise exc.HTTPNotFound + raise exc.HTTPNotFound() except exception.InvalidAggregateAction: LOG.info(_('Cannot remove host %(host)s in aggregate %(id)s'), {'host': host, 'id': id}) - raise exc.HTTPConflict + raise exc.HTTPConflict() return self._marshall_aggregate(aggregate) def _set_metadata(self, req, id, body): @@ -184,18 +184,18 @@ class AggregateController(object): authorize(context) if len(body) != 1: - raise exc.HTTPBadRequest + raise exc.HTTPBadRequest() try: metadata = body["metadata"] except KeyError: - raise exc.HTTPBadRequest + raise exc.HTTPBadRequest() try: aggregate = self.api.update_aggregate_metadata(context, id, metadata) except exception.AggregateNotFound: LOG.info(_('Cannot set metadata %(metadata)s in aggregate %(id)s'), {'metadata': metadata, 'id': id}) - raise exc.HTTPNotFound + raise exc.HTTPNotFound() return self._marshall_aggregate(aggregate) diff --git a/nova/api/openstack/compute/contrib/attach_interfaces.py b/nova/api/openstack/compute/contrib/attach_interfaces.py index a838354d0..dfaa284fa 100644 --- a/nova/api/openstack/compute/contrib/attach_interfaces.py +++ b/nova/api/openstack/compute/contrib/attach_interfaces.py @@ -137,7 +137,7 @@ class InterfaceAttachmentController(object): self.compute_api.detach_interface(context, instance, port_id=port_id) except exception.PortNotFound: - raise exc.HTTPNotFound + raise exc.HTTPNotFound() except NotImplementedError: msg = _("Network driver does not support this function.") raise webob.exc.HTTPNotImplemented(explanation=msg) diff --git a/nova/api/openstack/compute/contrib/baremetal_nodes.py b/nova/api/openstack/compute/contrib/baremetal_nodes.py index 1c442d2fa..2f2ddc35b 100644 --- a/nova/api/openstack/compute/contrib/baremetal_nodes.py +++ b/nova/api/openstack/compute/contrib/baremetal_nodes.py @@ -116,7 +116,7 @@ class BareMetalNodeController(wsgi.Controller): try: node = db.bm_node_get(context, id) except exception.NodeNotFound: - raise webob.exc.HTTPNotFound + raise webob.exc.HTTPNotFound() try: ifs = db.bm_interface_get_all_by_bm_node_id(context, id) except exception.NodeNotFound: @@ -151,14 +151,14 @@ class BareMetalNodeController(wsgi.Controller): try: db.bm_node_destroy(context, id) except exception.NodeNotFound: - raise webob.exc.HTTPNotFound + raise webob.exc.HTTPNotFound() return webob.Response(status_int=202) def _check_node_exists(self, context, node_id): try: db.bm_node_get(context, node_id) except exception.NodeNotFound: - raise webob.exc.HTTPNotFound + raise webob.exc.HTTPNotFound() @wsgi.serializers(xml=InterfaceTemplate) @wsgi.action('add_interface') @@ -198,7 +198,7 @@ class BareMetalNodeController(wsgi.Controller): continue db.bm_interface_destroy(context, i['id']) return webob.Response(status_int=202) - raise webob.exc.HTTPNotFound + raise webob.exc.HTTPNotFound() class Baremetal_nodes(extensions.ExtensionDescriptor): |
