Report proper error message in PLUMgrid Plugin

Change-Id: Ifc1bb55f6b025bba77cf9858ed392dbf170075a7
Closes-Bug: #1268460
Signed-off-by: Fawad Khaliq <fawad@plumgrid.com>
This commit is contained in:
Fawad Khaliq 2014-01-13 10:42:55 -08:00
parent 06a2684629
commit 5fae0fae21
2 changed files with 35 additions and 55 deletions

View File

@ -23,8 +23,7 @@ from neutron.common import exceptions as base_exec
class PLUMgridException(base_exec.NeutronException): class PLUMgridException(base_exec.NeutronException):
message = _("An unexpected error occurred in the PLUMgrid Plugin: " message = _("PLUMgrid Plugin Error: %(err_msg)s")
"%(err_msg)s")
class PLUMgridConnectionFailed(PLUMgridException): class PLUMgridConnectionFailed(PLUMgridException):

View File

@ -39,7 +39,6 @@ from neutron.plugins.plumgrid.plumgrid_plugin.plugin_ver import VERSION
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
PLUM_DRIVER = 'neutron.plugins.plumgrid.drivers.plumlib.Plumlib' PLUM_DRIVER = 'neutron.plugins.plumgrid.drivers.plumlib.Plumlib'
ERR_MESSAGE = _('PLUMgrid Director communication failed')
director_server_opts = [ director_server_opts = [
cfg.StrOpt('director_server', default='localhost', cfg.StrOpt('director_server', default='localhost',
@ -115,9 +114,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_('PLUMgrid Library: create_network() called')) LOG.debug(_('PLUMgrid Library: create_network() called'))
self._plumlib.create_network(tenant_id, net_db) self._plumlib.create_network(tenant_id, net_db)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
# Return created network # Return created network
return net_db return net_db
@ -142,9 +140,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("PLUMgrid Library: update_network() called")) LOG.debug(_("PLUMgrid Library: update_network() called"))
self._plumlib.update_network(tenant_id, net_id) self._plumlib.update_network(tenant_id, net_id)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
# Return updated network # Return updated network
return net_db return net_db
@ -168,9 +165,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("PLUMgrid Library: update_network() called")) LOG.debug(_("PLUMgrid Library: update_network() called"))
self._plumlib.delete_network(net_db, net_id) self._plumlib.delete_network(net_db, net_id)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
def create_port(self, context, port): def create_port(self, context, port):
"""Create Neutron port. """Create Neutron port.
@ -200,9 +196,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("PLUMgrid Library: create_port() called")) LOG.debug(_("PLUMgrid Library: create_port() called"))
self._plumlib.create_port(port_db, router_db) self._plumlib.create_port(port_db, router_db)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
# Plugin DB - Port Create and Return port # Plugin DB - Port Create and Return port
return self._port_viftype_binding(context, port_db) return self._port_viftype_binding(context, port_db)
@ -228,9 +223,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("PLUMgrid Library: create_port() called")) LOG.debug(_("PLUMgrid Library: create_port() called"))
self._plumlib.update_port(port_db, router_db) self._plumlib.update_port(port_db, router_db)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
# Plugin DB - Port Update # Plugin DB - Port Update
return self._port_viftype_binding(context, port_db) return self._port_viftype_binding(context, port_db)
@ -260,9 +254,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("PLUMgrid Library: delete_port() called")) LOG.debug(_("PLUMgrid Library: delete_port() called"))
self._plumlib.delete_port(port_db, router_db) self._plumlib.delete_port(port_db, router_db)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
def get_port(self, context, id, fields=None): def get_port(self, context, id, fields=None):
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
@ -313,9 +306,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
try: try:
LOG.debug(_("PLUMgrid Library: create_subnet() called")) LOG.debug(_("PLUMgrid Library: create_subnet() called"))
self._plumlib.create_subnet(sub_db, net_db, ipnet) self._plumlib.create_subnet(sub_db, net_db, ipnet)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
return sub_db return sub_db
@ -336,9 +328,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
try: try:
LOG.debug(_("PLUMgrid Library: delete_subnet() called")) LOG.debug(_("PLUMgrid Library: delete_subnet() called"))
self._plumlib.delete_subnet(tenant_id, net_db, net_id) self._plumlib.delete_subnet(tenant_id, net_db, net_id)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
def update_subnet(self, context, subnet_id, subnet): def update_subnet(self, context, subnet_id, subnet):
"""Update subnet core Neutron API.""" """Update subnet core Neutron API."""
@ -358,9 +349,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("PLUMgrid Library: update_network() called")) LOG.debug(_("PLUMgrid Library: update_network() called"))
self._plumlib.update_subnet(org_sub_db, new_sub_db, ipnet) self._plumlib.update_subnet(org_sub_db, new_sub_db, ipnet)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
return new_sub_db return new_sub_db
@ -382,9 +372,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
# Add Router to VND # Add Router to VND
LOG.debug(_("PLUMgrid Library: create_router() called")) LOG.debug(_("PLUMgrid Library: create_router() called"))
self._plumlib.create_router(tenant_id, router_db) self._plumlib.create_router(tenant_id, router_db)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
# Return created router # Return created router
return router_db return router_db
@ -399,9 +388,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
try: try:
LOG.debug(_("PLUMgrid Library: update_router() called")) LOG.debug(_("PLUMgrid Library: update_router() called"))
self._plumlib.update_router(router_db, router_id) self._plumlib.update_router(router_db, router_id)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
# Return updated router # Return updated router
return router_db return router_db
@ -420,9 +408,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("PLUMgrid Library: delete_router() called")) LOG.debug(_("PLUMgrid Library: delete_router() called"))
self._plumlib.delete_router(tenant_id, router_id) self._plumlib.delete_router(tenant_id, router_id)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
def add_router_interface(self, context, router_id, interface_info): def add_router_interface(self, context, router_id, interface_info):
@ -450,9 +437,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
self._plumlib.add_router_interface(tenant_id, router_id, self._plumlib.add_router_interface(tenant_id, router_id,
port_db, ipnet) port_db, ipnet)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
return int_router return int_router
@ -485,9 +471,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
self._plumlib.remove_router_interface(tenant_id, self._plumlib.remove_router_interface(tenant_id,
net_id, router_id) net_id, router_id)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
return del_int_router return del_int_router
@ -507,9 +492,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("PLUMgrid Library: create_floatingip() called")) LOG.debug(_("PLUMgrid Library: create_floatingip() called"))
self._plumlib.create_floatingip(net_db, floating_ip) self._plumlib.create_floatingip(net_db, floating_ip)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
return floating_ip return floating_ip
@ -530,9 +514,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("PLUMgrid Library: update_floatingip() called")) LOG.debug(_("PLUMgrid Library: update_floatingip() called"))
self._plumlib.update_floatingip(net_db, floating_ip, id) self._plumlib.update_floatingip(net_db, floating_ip, id)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
return floating_ip return floating_ip
@ -553,9 +536,8 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
LOG.debug(_("PLUMgrid Library: delete_floatingip() called")) LOG.debug(_("PLUMgrid Library: delete_floatingip() called"))
self._plumlib.delete_floatingip(net_db, floating_ip_org, id) self._plumlib.delete_floatingip(net_db, floating_ip_org, id)
except Exception: except Exception as err_message:
LOG.error(ERR_MESSAGE) raise plum_excep.PLUMgridException(err_msg=err_message)
raise plum_excep.PLUMgridException(err_msg=ERR_MESSAGE)
""" """
Internal PLUMgrid Fuctions Internal PLUMgrid Fuctions
@ -581,7 +563,6 @@ class NeutronPluginPLUMgridV2(db_base_plugin_v2.NeutronDbPluginV2,
"setting for network %s"), network_name) "setting for network %s"), network_name)
except Exception: except Exception:
err_message = _("Network Admin State Validation Falied: ") err_message = _("Network Admin State Validation Falied: ")
LOG.error(err_message)
raise plum_excep.PLUMgridException(err_msg=err_message) raise plum_excep.PLUMgridException(err_msg=err_message)
return network return network