Exception messages now passed through
Fixes JIRA:NCP-1592 Might fix JIRA:NCP-1631, JIRA:NCP-1630
This commit is contained in:
@@ -57,37 +57,39 @@ class IpAddressesController(wsgi.Controller):
|
|||||||
try:
|
try:
|
||||||
return {"ip_address":
|
return {"ip_address":
|
||||||
self._plugin.get_ip_address(context, id)}
|
self._plugin.get_ip_address(context, id)}
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound as e:
|
||||||
raise webob.exc.HTTPNotFound()
|
raise webob.exc.HTTPNotFound(e)
|
||||||
|
|
||||||
def create(self, request, body=None):
|
def create(self, request, body=None):
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
try:
|
try:
|
||||||
return {"ip_address": self._plugin.create_ip_address(
|
return {"ip_address": self._plugin.create_ip_address(
|
||||||
request.context, body)}
|
request.context, body)}
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound as e:
|
||||||
raise webob.exc.HTTPNotFound()
|
raise webob.exc.HTTPNotFound(e)
|
||||||
except exceptions.Conflict:
|
except exceptions.Conflict as e:
|
||||||
raise webob.exc.HTTPConflict()
|
raise webob.exc.HTTPConflict(e)
|
||||||
except exceptions.BadRequest:
|
except exceptions.BadRequest as e:
|
||||||
raise webob.exc.HTTPBadRequest()
|
raise webob.exc.HTTPBadRequest(e)
|
||||||
|
|
||||||
def update(self, request, id, body=None):
|
def update(self, request, id, body=None):
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
try:
|
try:
|
||||||
return {"ip_address": self._plugin.update_ip_address(
|
return {"ip_address": self._plugin.update_ip_address(
|
||||||
request.context, id, body)}
|
request.context, id, body)}
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound as e:
|
||||||
raise webob.exc.HTTPNotFound()
|
raise webob.exc.HTTPNotFound(e)
|
||||||
|
except exceptions.BadRequest as e:
|
||||||
|
raise webob.exc.HTTPBadRequest(e)
|
||||||
|
|
||||||
def delete(self, request, id):
|
def delete(self, request, id):
|
||||||
context = request.context
|
context = request.context
|
||||||
try:
|
try:
|
||||||
return self._plugin.delete_ip_address(context, id)
|
return self._plugin.delete_ip_address(context, id)
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound as e:
|
||||||
raise webob.exc.HTTPNotFound()
|
raise webob.exc.HTTPNotFound(e)
|
||||||
except exceptions.BadRequest:
|
except exceptions.BadRequest as e:
|
||||||
raise webob.exc.HTTPBadRequest()
|
raise webob.exc.HTTPBadRequest(e)
|
||||||
|
|
||||||
|
|
||||||
class IpAddressPortController(wsgi.Controller):
|
class IpAddressPortController(wsgi.Controller):
|
||||||
@@ -111,8 +113,8 @@ class IpAddressPortController(wsgi.Controller):
|
|||||||
try:
|
try:
|
||||||
ports = fx(context, ip_address_id, filters=filters, **request.GET)
|
ports = fx(context, ip_address_id, filters=filters, **request.GET)
|
||||||
return {"ports": ports}
|
return {"ports": ports}
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound as e:
|
||||||
raise webob.exc.HTTPNotFound()
|
raise webob.exc.HTTPNotFound(e)
|
||||||
|
|
||||||
def create(self, request, **kwargs):
|
def create(self, request, **kwargs):
|
||||||
raise webob.exc.HTTPNotImplemented()
|
raise webob.exc.HTTPNotImplemented()
|
||||||
@@ -124,8 +126,8 @@ class IpAddressPortController(wsgi.Controller):
|
|||||||
return {"port":
|
return {"port":
|
||||||
self._plugin.get_port_for_ip_address(context,
|
self._plugin.get_port_for_ip_address(context,
|
||||||
ip_address_id, id)}
|
ip_address_id, id)}
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound as e:
|
||||||
raise webob.exc.HTTPNotFound()
|
raise webob.exc.HTTPNotFound(e)
|
||||||
|
|
||||||
def update(self, ip_address_id, request, id, body=None):
|
def update(self, ip_address_id, request, id, body=None):
|
||||||
body = self._deserialize(request.body, request.get_content_type())
|
body = self._deserialize(request.body, request.get_content_type())
|
||||||
@@ -133,10 +135,10 @@ class IpAddressPortController(wsgi.Controller):
|
|||||||
return {"port": self._plugin.update_port_for_ip(request.context,
|
return {"port": self._plugin.update_port_for_ip(request.context,
|
||||||
ip_address_id,
|
ip_address_id,
|
||||||
id, body)}
|
id, body)}
|
||||||
except exceptions.NotFound:
|
except exceptions.NotFound as e:
|
||||||
raise webob.exc.HTTPNotFound()
|
raise webob.exc.HTTPNotFound(e)
|
||||||
except exceptions.BadRequest:
|
except exceptions.BadRequest as e:
|
||||||
raise webob.exc.HTTPBadRequest()
|
raise webob.exc.HTTPBadRequest(e)
|
||||||
|
|
||||||
def delete(self, request, id, **kwargs):
|
def delete(self, request, id, **kwargs):
|
||||||
raise webob.exc.HTTPNotImplemented()
|
raise webob.exc.HTTPNotImplemented()
|
||||||
|
|||||||
@@ -257,8 +257,7 @@ def update_ip_address(context, id, ip_address):
|
|||||||
LOG.info("update_ip_address %s for tenant %s" % (id, context.tenant_id))
|
LOG.info("update_ip_address %s for tenant %s" % (id, context.tenant_id))
|
||||||
ports = []
|
ports = []
|
||||||
with context.session.begin():
|
with context.session.begin():
|
||||||
address = db_api.ip_address_find(
|
address = db_api.ip_address_find(context, id=id, scope=db_api.ONE)
|
||||||
context, id=id, tenant_id=context.tenant_id, scope=db_api.ONE)
|
|
||||||
if not address:
|
if not address:
|
||||||
raise exceptions.NotFound(
|
raise exceptions.NotFound(
|
||||||
message="No IP address found with id=%s" % id)
|
message="No IP address found with id=%s" % id)
|
||||||
|
|||||||
Reference in New Issue
Block a user