Merge "Update i18n translation for NEC plugin log msg's"
This commit is contained in:
commit
6b1da897a9
@ -86,7 +86,7 @@ def _directory_to_check_translation(filename):
|
||||
"neutron/plugins/midonet",
|
||||
"neutron/plugins/ml2",
|
||||
"neutron/plugins/mlnx",
|
||||
#"neutron/plugins/nec",
|
||||
"neutron/plugins/nec",
|
||||
"neutron/plugins/nuage",
|
||||
#"neutron/plugins/ofagent",
|
||||
#"neutron/plugins/oneconvergence",
|
||||
|
@ -36,6 +36,7 @@ from neutron.common import rpc as n_rpc
|
||||
from neutron.common import topics
|
||||
from neutron import context as q_context
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.i18n import _LE, _LI
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.openstack.common import loopingcall
|
||||
from neutron.plugins.nec.common import config
|
||||
@ -49,8 +50,8 @@ class NECPluginApi(agent_rpc.PluginApi):
|
||||
def update_ports(self, context, agent_id, datapath_id,
|
||||
port_added, port_removed):
|
||||
"""RPC to update information of ports on Neutron Server."""
|
||||
LOG.info(_("Update ports: added=%(added)s, "
|
||||
"removed=%(removed)s"),
|
||||
LOG.info(_LI("Update ports: added=%(added)s, "
|
||||
"removed=%(removed)s"),
|
||||
{'added': port_added, 'removed': port_removed})
|
||||
cctxt = self.client.prepare()
|
||||
return cctxt.call(context, 'update_ports',
|
||||
@ -71,7 +72,7 @@ class NECAgentRpcCallback(object):
|
||||
self.sg_agent = sg_agent
|
||||
|
||||
def port_update(self, context, **kwargs):
|
||||
LOG.debug(_("port_update received: %s"), kwargs)
|
||||
LOG.debug("port_update received: %s", kwargs)
|
||||
port = kwargs.get('port')
|
||||
# Validate that port is on OVS
|
||||
vif_port = self.agent.int_br.get_vif_port_by_id(port['id'])
|
||||
@ -137,7 +138,7 @@ class NECNeutronAgent(object):
|
||||
def setup_rpc(self):
|
||||
self.host = socket.gethostname()
|
||||
self.agent_id = 'nec-q-agent.%s' % self.host
|
||||
LOG.info(_("RPC agent_id: %s"), self.agent_id)
|
||||
LOG.info(_LI("RPC agent_id: %s"), self.agent_id)
|
||||
|
||||
self.topic = topics.AGENT
|
||||
self.context = q_context.get_admin_context_without_session()
|
||||
@ -175,7 +176,7 @@ class NECNeutronAgent(object):
|
||||
self.agent_state)
|
||||
self.agent_state.pop('start_flag', None)
|
||||
except Exception:
|
||||
LOG.exception(_("Failed reporting state!"))
|
||||
LOG.exception(_LE("Failed reporting state!"))
|
||||
|
||||
def _vif_port_to_port_info(self, vif_port):
|
||||
return dict(id=vif_port.vif_id, port_no=vif_port.ofport,
|
||||
@ -213,12 +214,12 @@ class NECNeutronAgent(object):
|
||||
port_added, port_removed)
|
||||
self._process_security_group(port_added, port_removed)
|
||||
else:
|
||||
LOG.debug(_("No port changed."))
|
||||
LOG.debug("No port changed.")
|
||||
|
||||
self.cur_ports = new_ports
|
||||
self.need_sync = False
|
||||
except Exception:
|
||||
LOG.exception(_("Error in agent event loop"))
|
||||
LOG.exception(_LE("Error in agent event loop"))
|
||||
self.need_sync = True
|
||||
|
||||
def daemon_loop(self):
|
||||
|
@ -18,6 +18,7 @@ from oslo.serialization import jsonutils
|
||||
from oslo.utils import excutils
|
||||
import requests
|
||||
|
||||
from neutron.i18n import _LI, _LW
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.nec.common import config
|
||||
from neutron.plugins.nec.common import exceptions as nexc
|
||||
@ -74,8 +75,8 @@ class OFCClient(object):
|
||||
|
||||
def do_single_request(self, method, action, body=None):
|
||||
action = config.OFC.path_prefix + action
|
||||
LOG.debug(_("Client request: %(host)s:%(port)s "
|
||||
"%(method)s %(action)s [%(body)s]"),
|
||||
LOG.debug("Client request: %(host)s:%(port)s "
|
||||
"%(method)s %(action)s [%(body)s]",
|
||||
{'host': self.host, 'port': self.port,
|
||||
'method': method, 'action': action, 'body': body})
|
||||
if type(body) is dict:
|
||||
@ -83,7 +84,7 @@ class OFCClient(object):
|
||||
try:
|
||||
res = self._get_response(method, action, body)
|
||||
data = res.text
|
||||
LOG.debug(_("OFC returns [%(status)s:%(data)s]"),
|
||||
LOG.debug("OFC returns [%(status)s:%(data)s]",
|
||||
{'status': res.status_code,
|
||||
'data': data})
|
||||
|
||||
@ -100,16 +101,16 @@ class OFCClient(object):
|
||||
return data
|
||||
elif res.status_code == requests.codes.SERVICE_UNAVAILABLE:
|
||||
retry_after = res.headers.get('retry-after')
|
||||
LOG.warning(_("OFC returns ServiceUnavailable "
|
||||
"(retry-after=%s)"), retry_after)
|
||||
LOG.warning(_LW("OFC returns ServiceUnavailable "
|
||||
"(retry-after=%s)"), retry_after)
|
||||
raise nexc.OFCServiceUnavailable(retry_after=retry_after)
|
||||
elif res.status_code == requests.codes.NOT_FOUND:
|
||||
LOG.info(_("Specified resource %s does not exist on OFC "),
|
||||
LOG.info(_LI("Specified resource %s does not exist on OFC "),
|
||||
action)
|
||||
raise nexc.OFCResourceNotFound(resource=action)
|
||||
else:
|
||||
LOG.warning(_("Operation on OFC failed: "
|
||||
"status=%(status)s, detail=%(detail)s"),
|
||||
LOG.warning(_LW("Operation on OFC failed: "
|
||||
"status=%(status)s, detail=%(detail)s"),
|
||||
{'status': res.status_code, 'detail': data})
|
||||
params = {'reason': _("Operation on OFC failed"),
|
||||
'status': res.status_code}
|
||||
@ -136,8 +137,8 @@ class OFCClient(object):
|
||||
except (ValueError, TypeError):
|
||||
wait_time = None
|
||||
if i > 1 and wait_time:
|
||||
LOG.info(_("Waiting for %s seconds due to "
|
||||
"OFC Service_Unavailable."), wait_time)
|
||||
LOG.info(_LI("Waiting for %s seconds due to "
|
||||
"OFC Service_Unavailable."), wait_time)
|
||||
time.sleep(wait_time)
|
||||
ctxt.reraise = False
|
||||
continue
|
||||
|
@ -18,6 +18,7 @@ from neutron.db import api as db
|
||||
from neutron.db import models_v2
|
||||
from neutron.db import securitygroups_db as sg_db
|
||||
from neutron.extensions import securitygroup as ext_sg
|
||||
from neutron.i18n import _LW
|
||||
from neutron import manager
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.nec.common import config # noqa
|
||||
@ -99,7 +100,7 @@ def del_ofc_item(session, resource, neutron_id):
|
||||
session.delete(item)
|
||||
return True
|
||||
except sa.orm.exc.NoResultFound:
|
||||
LOG.warning(_("del_ofc_item(): NotFound item "
|
||||
LOG.warning(_LW("del_ofc_item(): NotFound item "
|
||||
"(resource=%(resource)s, id=%(id)s) "),
|
||||
{'resource': resource, 'id': neutron_id})
|
||||
return False
|
||||
@ -133,7 +134,7 @@ def del_portinfo(session, id):
|
||||
portinfo = session.query(nmodels.PortInfo).filter_by(id=id).one()
|
||||
session.delete(portinfo)
|
||||
except sa.orm.exc.NoResultFound:
|
||||
LOG.warning(_("del_portinfo(): NotFound portinfo for "
|
||||
LOG.warning(_LW("del_portinfo(): NotFound portinfo for "
|
||||
"port_id: %s"), id)
|
||||
|
||||
|
||||
@ -154,7 +155,7 @@ def get_active_ports_on_ofc(context, network_id, port_id=None):
|
||||
|
||||
def get_port_from_device(port_id):
|
||||
"""Get port from database."""
|
||||
LOG.debug(_("get_port_with_securitygroups() called:port_id=%s"), port_id)
|
||||
LOG.debug("get_port_with_securitygroups() called:port_id=%s", port_id)
|
||||
session = db.get_session()
|
||||
sg_binding_port = sg_db.SecurityGroupPortBinding.port_id
|
||||
|
||||
|
@ -82,8 +82,8 @@ def get_provider_by_router(session, router_id):
|
||||
|
||||
def add_router_provider_binding(session, provider, router_id):
|
||||
"""Add a router provider association."""
|
||||
LOG.debug(_("Add provider binding "
|
||||
"(router=%(router_id)s, provider=%(provider)s)"),
|
||||
LOG.debug("Add provider binding "
|
||||
"(router=%(router_id)s, provider=%(provider)s)",
|
||||
{'router_id': router_id, 'provider': provider})
|
||||
binding = RouterProvider(provider=provider, router_id=router_id)
|
||||
session.add(binding)
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
from oslo.utils import importutils
|
||||
|
||||
from neutron.i18n import _LI
|
||||
from neutron.openstack.common import log as logging
|
||||
|
||||
|
||||
@ -33,6 +34,6 @@ DRIVER_LIST = {
|
||||
|
||||
|
||||
def get_driver(driver_name):
|
||||
LOG.info(_("Loading OFC driver: %s"), driver_name)
|
||||
LOG.info(_LI("Loading OFC driver: %s"), driver_name)
|
||||
driver_klass = DRIVER_LIST.get(driver_name) or driver_name
|
||||
return importutils.import_class(driver_klass)
|
||||
|
@ -39,6 +39,7 @@ from neutron.db import quota_db # noqa
|
||||
from neutron.db import securitygroups_rpc_base as sg_db_rpc
|
||||
from neutron.extensions import allowedaddresspairs as addr_pair
|
||||
from neutron.extensions import portbindings
|
||||
from neutron.i18n import _LE, _LI, _LW
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.openstack.common import uuidutils
|
||||
from neutron.plugins.common import constants as svc_constants
|
||||
@ -205,11 +206,10 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
if self.ofc.exists_ofc_tenant(context, tenant_id):
|
||||
self.ofc.delete_ofc_tenant(context, tenant_id)
|
||||
else:
|
||||
LOG.debug(_('_cleanup_ofc_tenant: No OFC tenant for %s'),
|
||||
LOG.debug('_cleanup_ofc_tenant: No OFC tenant for %s',
|
||||
tenant_id)
|
||||
except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
|
||||
reason = _("delete_ofc_tenant() failed due to %s") % exc
|
||||
LOG.warn(reason)
|
||||
LOG.warn(_LW("delete_ofc_tenant() failed due to %s"), exc)
|
||||
|
||||
def activate_port_if_ready(self, context, port, network=None):
|
||||
"""Activate port by creating port on OFC if ready.
|
||||
@ -224,27 +224,27 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
port['network_id'])
|
||||
|
||||
if not port['admin_state_up']:
|
||||
LOG.debug(_("activate_port_if_ready(): skip, "
|
||||
"port.admin_state_up is False."))
|
||||
LOG.debug("activate_port_if_ready(): skip, "
|
||||
"port.admin_state_up is False.")
|
||||
return port
|
||||
elif not network['admin_state_up']:
|
||||
LOG.debug(_("activate_port_if_ready(): skip, "
|
||||
"network.admin_state_up is False."))
|
||||
LOG.debug("activate_port_if_ready(): skip, "
|
||||
"network.admin_state_up is False.")
|
||||
return port
|
||||
elif not ndb.get_portinfo(context.session, port['id']):
|
||||
LOG.debug(_("activate_port_if_ready(): skip, "
|
||||
"no portinfo for this port."))
|
||||
LOG.debug("activate_port_if_ready(): skip, "
|
||||
"no portinfo for this port.")
|
||||
return port
|
||||
elif self.ofc.exists_ofc_port(context, port['id']):
|
||||
LOG.debug(_("activate_port_if_ready(): skip, "
|
||||
"ofc_port already exists."))
|
||||
LOG.debug("activate_port_if_ready(): skip, "
|
||||
"ofc_port already exists.")
|
||||
return port
|
||||
|
||||
try:
|
||||
self.ofc.create_ofc_port(context, port['id'], port)
|
||||
port_status = const.PORT_STATUS_ACTIVE
|
||||
except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
|
||||
LOG.error(_("create_ofc_port() failed due to %s"), exc)
|
||||
LOG.error(_LE("create_ofc_port() failed due to %s"), exc)
|
||||
port_status = const.PORT_STATUS_ERROR
|
||||
|
||||
if port_status != port['status']:
|
||||
@ -257,8 +257,8 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
def deactivate_port(self, context, port, raise_exc=True):
|
||||
"""Deactivate port by deleting port from OFC if exists."""
|
||||
if not self.ofc.exists_ofc_port(context, port['id']):
|
||||
LOG.debug(_("deactivate_port(): skip, ofc_port for port=%s "
|
||||
"does not exist."), port['id'])
|
||||
LOG.debug("deactivate_port(): skip, ofc_port for port=%s "
|
||||
"does not exist.", port['id'])
|
||||
return port
|
||||
|
||||
try:
|
||||
@ -276,16 +276,16 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
# between exists_ofc_port and get_ofc_id in delete_ofc_port.
|
||||
# In this case OFCMappingNotFound is raised.
|
||||
# These two cases are valid situations.
|
||||
LOG.info(_("deactivate_port(): OFC port for port=%s is "
|
||||
"already removed."), port['id'])
|
||||
LOG.info(_LI("deactivate_port(): OFC port for port=%s is "
|
||||
"already removed."), port['id'])
|
||||
# The port is already removed, so there is no need
|
||||
# to update status in the database.
|
||||
port['status'] = const.PORT_STATUS_DOWN
|
||||
return port
|
||||
except nexc.OFCException as exc:
|
||||
with excutils.save_and_reraise_exception() as ctxt:
|
||||
LOG.error(_("Failed to delete port=%(port)s from OFC: "
|
||||
"%(exc)s"), {'port': port['id'], 'exc': exc})
|
||||
LOG.error(_LE("Failed to delete port=%(port)s from OFC: "
|
||||
"%(exc)s"), {'port': port['id'], 'exc': exc})
|
||||
self._update_resource_status_if_changed(
|
||||
context, "port", port, const.PORT_STATUS_ERROR)
|
||||
if not raise_exc:
|
||||
@ -303,8 +303,8 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
def create_network(self, context, network):
|
||||
"""Create a new network entry on DB, and create it on OFC."""
|
||||
LOG.debug(_("NECPluginV2.create_network() called, "
|
||||
"network=%s ."), network)
|
||||
LOG.debug("NECPluginV2.create_network() called, "
|
||||
"network=%s .", network)
|
||||
tenant_id = self._get_tenant_id_for_create(context, network['network'])
|
||||
net_name = network['network']['name']
|
||||
net_id = uuidutils.generate_uuid()
|
||||
@ -320,8 +320,8 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
self.ofc.create_ofc_tenant(context, tenant_id)
|
||||
self.ofc.create_ofc_network(context, tenant_id, net_id, net_name)
|
||||
except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
|
||||
LOG.error(_("Failed to create network id=%(id)s on "
|
||||
"OFC: %(exc)s"), {'id': net_id, 'exc': exc})
|
||||
LOG.error(_LE("Failed to create network id=%(id)s on "
|
||||
"OFC: %(exc)s"), {'id': net_id, 'exc': exc})
|
||||
network['network']['status'] = const.NET_STATUS_ERROR
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
@ -336,8 +336,8 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
Update network entry on DB. If 'admin_state_up' was changed, activate
|
||||
or deactivate ports and packetfilters associated with the network.
|
||||
"""
|
||||
LOG.debug(_("NECPluginV2.update_network() called, "
|
||||
"id=%(id)s network=%(network)s ."),
|
||||
LOG.debug("NECPluginV2.update_network() called, "
|
||||
"id=%(id)s network=%(network)s .",
|
||||
{'id': id, 'network': network})
|
||||
|
||||
if 'admin_state_up' in network['network']:
|
||||
@ -380,7 +380,7 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
associated with the network. If the network is the last resource
|
||||
of the tenant, delete unnessary ofc_tenant.
|
||||
"""
|
||||
LOG.debug(_("NECPluginV2.delete_network() called, id=%s ."), id)
|
||||
LOG.debug("NECPluginV2.delete_network() called, id=%s .", id)
|
||||
net_db = self._get_network(context, id)
|
||||
tenant_id = net_db['tenant_id']
|
||||
ports = self.get_ports(context, filters={'network_id': [id]})
|
||||
@ -414,8 +414,7 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
self.ofc.delete_ofc_network(context, id, net_db)
|
||||
except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
|
||||
with excutils.save_and_reraise_exception():
|
||||
reason = _("delete_network() failed due to %s") % exc
|
||||
LOG.error(reason)
|
||||
LOG.error(_LE("delete_network() failed due to %s"), exc)
|
||||
self._update_resource_status(
|
||||
context, "network", net_db['id'],
|
||||
const.NET_STATUS_ERROR)
|
||||
@ -551,7 +550,7 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
def create_port(self, context, port):
|
||||
"""Create a new port entry on DB, then try to activate it."""
|
||||
LOG.debug(_("NECPluginV2.create_port() called, port=%s ."), port)
|
||||
LOG.debug("NECPluginV2.create_port() called, port=%s .", port)
|
||||
|
||||
port['port']['status'] = const.PORT_STATUS_DOWN
|
||||
|
||||
@ -615,8 +614,8 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
Update network entry on DB. If admin_state_up was changed, activate
|
||||
or deactivate the port and packetfilters associated with it.
|
||||
"""
|
||||
LOG.debug(_("NECPluginV2.update_port() called, "
|
||||
"id=%(id)s port=%(port)s ."),
|
||||
LOG.debug("NECPluginV2.update_port() called, "
|
||||
"id=%(id)s port=%(port)s .",
|
||||
{'id': id, 'port': port})
|
||||
need_port_update_notify = False
|
||||
with context.session.begin(subtransactions=True):
|
||||
@ -643,7 +642,7 @@ class NECPluginV2(db_base_plugin_v2.NeutronDbPluginV2,
|
||||
|
||||
def delete_port(self, context, id, l3_port_check=True):
|
||||
"""Delete port and packet_filters associated with the port."""
|
||||
LOG.debug(_("NECPluginV2.delete_port() called, id=%s ."), id)
|
||||
LOG.debug("NECPluginV2.delete_port() called, id=%s .", id)
|
||||
# ext_sg.SECURITYGROUPS attribute for the port is required
|
||||
# since notifier.security_groups_member_updated() need the attribute.
|
||||
# Thus we need to call self.get_port() instead of super().get_port()
|
||||
@ -706,8 +705,8 @@ class NECPluginV2RPCCallbacks(object):
|
||||
'port_added': [<new PortInfo>,...],
|
||||
'port_removed': [<removed Port ID>,...]}
|
||||
"""
|
||||
LOG.debug(_("NECPluginV2RPCCallbacks.update_ports() called, "
|
||||
"kwargs=%s ."), kwargs)
|
||||
LOG.debug("NECPluginV2RPCCallbacks.update_ports() called, "
|
||||
"kwargs=%s .", kwargs)
|
||||
datapath_id = kwargs['datapath_id']
|
||||
session = rpc_context.session
|
||||
for p in kwargs.get('port_added', []):
|
||||
@ -716,8 +715,8 @@ class NECPluginV2RPCCallbacks(object):
|
||||
if portinfo:
|
||||
if (necutils.cmp_dpid(portinfo.datapath_id, datapath_id) and
|
||||
portinfo.port_no == p['port_no']):
|
||||
LOG.debug(_("update_ports(): ignore unchanged portinfo in "
|
||||
"port_added message (port_id=%s)."), id)
|
||||
LOG.debug("update_ports(): ignore unchanged portinfo in "
|
||||
"port_added message (port_id=%s).", id)
|
||||
continue
|
||||
ndb.del_portinfo(session, id)
|
||||
port = self._get_port(rpc_context, id)
|
||||
@ -736,15 +735,15 @@ class NECPluginV2RPCCallbacks(object):
|
||||
for id in kwargs.get('port_removed', []):
|
||||
portinfo = ndb.get_portinfo(session, id)
|
||||
if not portinfo:
|
||||
LOG.debug(_("update_ports(): ignore port_removed message "
|
||||
"due to portinfo for port_id=%s was not "
|
||||
"registered"), id)
|
||||
LOG.debug("update_ports(): ignore port_removed message "
|
||||
"due to portinfo for port_id=%s was not "
|
||||
"registered", id)
|
||||
continue
|
||||
if not necutils.cmp_dpid(portinfo.datapath_id, datapath_id):
|
||||
LOG.debug(_("update_ports(): ignore port_removed message "
|
||||
"received from different host "
|
||||
"(registered_datapath_id=%(registered)s, "
|
||||
"received_datapath_id=%(received)s)."),
|
||||
LOG.debug("update_ports(): ignore port_removed message "
|
||||
"received from different host "
|
||||
"(registered_datapath_id=%(registered)s, "
|
||||
"received_datapath_id=%(received)s).",
|
||||
{'registered': portinfo.datapath_id,
|
||||
'received': datapath_id})
|
||||
continue
|
||||
|
@ -25,6 +25,7 @@ from neutron.db import l3_db
|
||||
from neutron.db import l3_gwmode_db
|
||||
from neutron.db import models_v2
|
||||
from neutron.extensions import l3
|
||||
from neutron.i18n import _LE, _LI, _LW
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.nec.common import config
|
||||
from neutron.plugins.nec.common import constants as nconst
|
||||
@ -54,8 +55,8 @@ class RouterMixin(extraroute_db.ExtraRoute_db_mixin,
|
||||
|
||||
def create_router(self, context, router):
|
||||
"""Create a new router entry on DB, and create it on OFC."""
|
||||
LOG.debug(_("RouterMixin.create_router() called, "
|
||||
"router=%s ."), router)
|
||||
LOG.debug("RouterMixin.create_router() called, "
|
||||
"router=%s .", router)
|
||||
tenant_id = self._get_tenant_id_for_create(context, router['router'])
|
||||
|
||||
provider = get_provider_with_default(
|
||||
@ -80,8 +81,8 @@ class RouterMixin(extraroute_db.ExtraRoute_db_mixin,
|
||||
new_router['id'])
|
||||
|
||||
def update_router(self, context, router_id, router):
|
||||
LOG.debug(_("RouterMixin.update_router() called, "
|
||||
"id=%(id)s, router=%(router)s ."),
|
||||
LOG.debug("RouterMixin.update_router() called, "
|
||||
"id=%(id)s, router=%(router)s .",
|
||||
{'id': router_id, 'router': router})
|
||||
|
||||
with context.session.begin(subtransactions=True):
|
||||
@ -98,7 +99,7 @@ class RouterMixin(extraroute_db.ExtraRoute_db_mixin,
|
||||
return new_rtr
|
||||
|
||||
def delete_router(self, context, router_id):
|
||||
LOG.debug(_("RouterMixin.delete_router() called, id=%s."), router_id)
|
||||
LOG.debug("RouterMixin.delete_router() called, id=%s.", router_id)
|
||||
|
||||
router = super(RouterMixin, self).get_router(context, router_id)
|
||||
tenant_id = router['tenant_id']
|
||||
@ -117,15 +118,15 @@ class RouterMixin(extraroute_db.ExtraRoute_db_mixin,
|
||||
self._cleanup_ofc_tenant(context, tenant_id)
|
||||
|
||||
def add_router_interface(self, context, router_id, interface_info):
|
||||
LOG.debug(_("RouterMixin.add_router_interface() called, "
|
||||
"id=%(id)s, interface=%(interface)s."),
|
||||
LOG.debug("RouterMixin.add_router_interface() called, "
|
||||
"id=%(id)s, interface=%(interface)s.",
|
||||
{'id': router_id, 'interface': interface_info})
|
||||
return super(RouterMixin, self).add_router_interface(
|
||||
context, router_id, interface_info)
|
||||
|
||||
def remove_router_interface(self, context, router_id, interface_info):
|
||||
LOG.debug(_("RouterMixin.remove_router_interface() called, "
|
||||
"id=%(id)s, interface=%(interface)s."),
|
||||
LOG.debug("RouterMixin.remove_router_interface() called, "
|
||||
"id=%(id)s, interface=%(interface)s.",
|
||||
{'id': router_id, 'interface': interface_info})
|
||||
return super(RouterMixin, self).remove_router_interface(
|
||||
context, router_id, interface_info)
|
||||
@ -308,7 +309,7 @@ def load_driver(plugin, ofc_manager):
|
||||
if (PROVIDER_OPENFLOW in ROUTER_DRIVER_MAP and
|
||||
not ofc_manager.driver.router_supported):
|
||||
LOG.warning(
|
||||
_('OFC does not support router with provider=%(provider)s, '
|
||||
_LW('OFC does not support router with provider=%(provider)s, '
|
||||
'so removed it from supported provider '
|
||||
'(new router driver map=%(driver_map)s)'),
|
||||
{'provider': PROVIDER_OPENFLOW,
|
||||
@ -316,7 +317,7 @@ def load_driver(plugin, ofc_manager):
|
||||
del ROUTER_DRIVER_MAP[PROVIDER_OPENFLOW]
|
||||
|
||||
if config.PROVIDER.default_router_provider not in ROUTER_DRIVER_MAP:
|
||||
LOG.error(_('default_router_provider %(default)s is supported! '
|
||||
LOG.error(_LE('default_router_provider %(default)s is supported! '
|
||||
'Please specify one of %(supported)s'),
|
||||
{'default': config.PROVIDER.default_router_provider,
|
||||
'supported': ROUTER_DRIVER_MAP.keys()})
|
||||
@ -330,11 +331,12 @@ def load_driver(plugin, ofc_manager):
|
||||
driver_klass = importutils.import_class(ROUTER_DRIVER_MAP[driver])
|
||||
ROUTER_DRIVERS[driver] = driver_klass(plugin, ofc_manager)
|
||||
|
||||
LOG.info(_('Enabled router drivers: %s'), ROUTER_DRIVERS.keys())
|
||||
LOG.info(_LI('Enabled router drivers: %s'), ROUTER_DRIVERS.keys())
|
||||
|
||||
if not ROUTER_DRIVERS:
|
||||
LOG.error(_('No router provider is enabled. neutron-server terminated!'
|
||||
' (supported=%(supported)s, configured=%(config)s)'),
|
||||
LOG.error(_LE('No router provider is enabled. neutron-server '
|
||||
'terminated! (supported=%(supported)s, '
|
||||
'configured=%(config)s)'),
|
||||
{'supported': ROUTER_DRIVER_MAP.keys(),
|
||||
'config': config.PROVIDER.router_providers})
|
||||
raise SystemExit(1)
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
from oslo.utils import excutils
|
||||
|
||||
from neutron.i18n import _LE
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.nec.common import config
|
||||
from neutron.plugins.nec.common import exceptions as nexc
|
||||
@ -36,12 +37,12 @@ class PacketFilterMixin(pf_db.PacketFilterDbMixin):
|
||||
|
||||
def remove_packet_filter_extension_if_disabled(self, aliases):
|
||||
if not self.packet_filter_enabled:
|
||||
LOG.debug(_('Disabled packet-filter extension.'))
|
||||
LOG.debug('Disabled packet-filter extension.')
|
||||
aliases.remove('packet-filter')
|
||||
|
||||
def create_packet_filter(self, context, packet_filter):
|
||||
"""Create a new packet_filter entry on DB, then try to activate it."""
|
||||
LOG.debug(_("create_packet_filter() called, packet_filter=%s ."),
|
||||
LOG.debug("create_packet_filter() called, packet_filter=%s .",
|
||||
packet_filter)
|
||||
|
||||
if hasattr(self.ofc.driver, 'validate_filter_create'):
|
||||
@ -57,8 +58,8 @@ class PacketFilterMixin(pf_db.PacketFilterDbMixin):
|
||||
|
||||
If any rule of the packet_filter was changed, recreate it on OFC.
|
||||
"""
|
||||
LOG.debug(_("update_packet_filter() called, "
|
||||
"id=%(id)s packet_filter=%(packet_filter)s ."),
|
||||
LOG.debug("update_packet_filter() called, "
|
||||
"id=%(id)s packet_filter=%(packet_filter)s .",
|
||||
{'id': id, 'packet_filter': packet_filter})
|
||||
|
||||
pf_data = packet_filter['packet_filter']
|
||||
@ -130,8 +131,8 @@ class PacketFilterMixin(pf_db.PacketFilterDbMixin):
|
||||
with excutils.save_and_reraise_exception():
|
||||
if (isinstance(exc, nexc.OFCException) or
|
||||
isinstance(exc, nexc.OFCConsistencyBroken)):
|
||||
LOG.error(_("Failed to create packet_filter id=%(id)s on "
|
||||
"OFC: %(exc)s"),
|
||||
LOG.error(_LE("Failed to create packet_filter id=%(id)s "
|
||||
"on OFC: %(exc)s"),
|
||||
{'id': pf_id, 'exc': exc})
|
||||
new_status = pf_db.PF_STATUS_ERROR
|
||||
if new_status != prev_status:
|
||||
@ -140,7 +141,7 @@ class PacketFilterMixin(pf_db.PacketFilterDbMixin):
|
||||
|
||||
def delete_packet_filter(self, context, id):
|
||||
"""Deactivate and delete packet_filter."""
|
||||
LOG.debug(_("delete_packet_filter() called, id=%s ."), id)
|
||||
LOG.debug("delete_packet_filter() called, id=%s .", id)
|
||||
|
||||
# validate ownership
|
||||
pf = self.get_packet_filter(context, id)
|
||||
@ -158,32 +159,32 @@ class PacketFilterMixin(pf_db.PacketFilterDbMixin):
|
||||
* packet_filter admin_state is UP
|
||||
* (if 'in_port' is specified) portinfo is available
|
||||
"""
|
||||
LOG.debug(_("activate_packet_filter_if_ready() called, "
|
||||
"packet_filter=%s."), packet_filter)
|
||||
LOG.debug("activate_packet_filter_if_ready() called, "
|
||||
"packet_filter=%s.", packet_filter)
|
||||
|
||||
pf_id = packet_filter['id']
|
||||
current = packet_filter['status']
|
||||
|
||||
pf_status = current
|
||||
if not packet_filter['admin_state_up']:
|
||||
LOG.debug(_("activate_packet_filter_if_ready(): skip pf_id=%s, "
|
||||
"packet_filter.admin_state_up is False."), pf_id)
|
||||
LOG.debug("activate_packet_filter_if_ready(): skip pf_id=%s, "
|
||||
"packet_filter.admin_state_up is False.", pf_id)
|
||||
elif self.ofc.exists_ofc_packet_filter(context, packet_filter['id']):
|
||||
LOG.debug(_("_activate_packet_filter_if_ready(): skip, "
|
||||
"ofc_packet_filter already exists."))
|
||||
LOG.debug("_activate_packet_filter_if_ready(): skip, "
|
||||
"ofc_packet_filter already exists.")
|
||||
else:
|
||||
LOG.debug(_("activate_packet_filter_if_ready(): create "
|
||||
"packet_filter id=%s on OFC."), pf_id)
|
||||
LOG.debug("activate_packet_filter_if_ready(): create "
|
||||
"packet_filter id=%s on OFC.", pf_id)
|
||||
try:
|
||||
self.ofc.create_ofc_packet_filter(context, pf_id,
|
||||
packet_filter)
|
||||
pf_status = pf_db.PF_STATUS_ACTIVE
|
||||
except nexc.PortInfoNotFound:
|
||||
LOG.debug(_("Skipped to create a packet filter pf_id=%s "
|
||||
"on OFC, no portinfo for the in_port."), pf_id)
|
||||
LOG.debug("Skipped to create a packet filter pf_id=%s "
|
||||
"on OFC, no portinfo for the in_port.", pf_id)
|
||||
except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
|
||||
LOG.error(_("Failed to create packet_filter id=%(id)s on "
|
||||
"OFC: %(exc)s"), {'id': pf_id, 'exc': exc})
|
||||
LOG.error(_LE("Failed to create packet_filter id=%(id)s on "
|
||||
"OFC: %(exc)s"), {'id': pf_id, 'exc': exc})
|
||||
pf_status = pf_db.PF_STATUS_ERROR
|
||||
|
||||
if pf_status != current:
|
||||
@ -195,18 +196,18 @@ class PacketFilterMixin(pf_db.PacketFilterDbMixin):
|
||||
|
||||
def deactivate_packet_filter(self, context, packet_filter):
|
||||
"""Deactivate packet_filter by deleting filter from OFC if exixts."""
|
||||
LOG.debug(_("deactivate_packet_filter_if_ready() called, "
|
||||
"packet_filter=%s."), packet_filter)
|
||||
LOG.debug("deactivate_packet_filter_if_ready() called, "
|
||||
"packet_filter=%s.", packet_filter)
|
||||
pf_id = packet_filter['id']
|
||||
|
||||
if not self.ofc.exists_ofc_packet_filter(context, pf_id):
|
||||
LOG.debug(_("deactivate_packet_filter(): skip, "
|
||||
"Not found OFC Mapping for packet_filter id=%s."),
|
||||
LOG.debug("deactivate_packet_filter(): skip, "
|
||||
"Not found OFC Mapping for packet_filter id=%s.",
|
||||
pf_id)
|
||||
return packet_filter
|
||||
|
||||
LOG.debug(_("deactivate_packet_filter(): "
|
||||
"deleting packet_filter id=%s from OFC."), pf_id)
|
||||
LOG.debug("deactivate_packet_filter(): "
|
||||
"deleting packet_filter id=%s from OFC.", pf_id)
|
||||
try:
|
||||
self.ofc.delete_ofc_packet_filter(context, pf_id)
|
||||
self._update_resource_status_if_changed(
|
||||
@ -214,8 +215,8 @@ class PacketFilterMixin(pf_db.PacketFilterDbMixin):
|
||||
return packet_filter
|
||||
except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error(_("Failed to delete packet_filter id=%(id)s "
|
||||
"from OFC: %(exc)s"),
|
||||
LOG.error(_LE("Failed to delete packet_filter id=%(id)s "
|
||||
"from OFC: %(exc)s"),
|
||||
{'id': pf_id, 'exc': str(exc)})
|
||||
self._update_resource_status_if_changed(
|
||||
context, "packet_filter", packet_filter,
|
||||
|
@ -20,6 +20,7 @@ import six
|
||||
|
||||
from neutron.common import log as call_log
|
||||
from neutron.common import utils
|
||||
from neutron.i18n import _LE, _LW
|
||||
from neutron.openstack.common import log as logging
|
||||
from neutron.plugins.nec.common import constants as nconst
|
||||
from neutron.plugins.nec.common import exceptions as nexc
|
||||
@ -120,8 +121,7 @@ class RouterOpenFlowDriver(RouterDriverBase):
|
||||
if (isinstance(exc, nexc.OFCException) and
|
||||
exc.status == httplib.CONFLICT):
|
||||
raise nexc.RouterOverLimit(provider=PROVIDER_OPENFLOW)
|
||||
reason = _("create_router() failed due to %s") % exc
|
||||
LOG.error(reason)
|
||||
LOG.error(_LE("create_router() failed due to %s"), exc)
|
||||
new_status = nconst.ROUTER_STATUS_ERROR
|
||||
self._update_resource_status(context, "router",
|
||||
router['id'],
|
||||
@ -149,8 +149,8 @@ class RouterOpenFlowDriver(RouterDriverBase):
|
||||
new_router['status'] = new_status
|
||||
except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
|
||||
with excutils.save_and_reraise_exception():
|
||||
reason = _("_update_ofc_routes() failed due to %s") % exc
|
||||
LOG.error(reason)
|
||||
LOG.error(_LE("_update_ofc_routes() failed due to %s"),
|
||||
exc)
|
||||
new_status = nconst.ROUTER_STATUS_ERROR
|
||||
self.plugin._update_resource_status(
|
||||
context, "router", router_id, new_status)
|
||||
@ -164,7 +164,7 @@ class RouterOpenFlowDriver(RouterDriverBase):
|
||||
self.ofc.delete_ofc_router(context, router_id, router)
|
||||
except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.error(_("delete_router() failed due to %s"), exc)
|
||||
LOG.error(_LE("delete_router() failed due to %s"), exc)
|
||||
self.plugin._update_resource_status(
|
||||
context, "router", router_id, nconst.ROUTER_STATUS_ERROR)
|
||||
|
||||
@ -175,10 +175,11 @@ class RouterOpenFlowDriver(RouterDriverBase):
|
||||
# Such port is invalid for a router port and we don't create a port
|
||||
# on OFC. The port is removed in l3_db._create_router_gw_port.
|
||||
if not port['fixed_ips']:
|
||||
msg = _('RouterOpenFlowDriver.add_interface(): the requested port '
|
||||
'has no subnet. add_interface() is skipped. '
|
||||
'router_id=%(id)s, port=%(port)s)')
|
||||
LOG.warning(msg, {'id': router_id, 'port': port})
|
||||
LOG.warning(_LW('RouterOpenFlowDriver.add_interface(): the '
|
||||
'requested port '
|
||||
'has no subnet. add_interface() is skipped. '
|
||||
'router_id=%(id)s, port=%(port)s)'),
|
||||
{'id': router_id, 'port': port})
|
||||
return port
|
||||
fixed_ip = port['fixed_ips'][0]
|
||||
subnet = self.plugin._get_subnet(context, fixed_ip['subnet_id'])
|
||||
@ -195,8 +196,7 @@ class RouterOpenFlowDriver(RouterDriverBase):
|
||||
return port
|
||||
except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
|
||||
with excutils.save_and_reraise_exception():
|
||||
reason = _("add_router_interface() failed due to %s") % exc
|
||||
LOG.error(reason)
|
||||
LOG.error(_LE("add_router_interface() failed due to %s"), exc)
|
||||
new_status = nconst.ROUTER_STATUS_ERROR
|
||||
self.plugin._update_resource_status(
|
||||
context, "port", port_id, new_status)
|
||||
@ -213,8 +213,8 @@ class RouterOpenFlowDriver(RouterDriverBase):
|
||||
return port
|
||||
except (nexc.OFCException, nexc.OFCMappingNotFound) as exc:
|
||||
with excutils.save_and_reraise_exception():
|
||||
reason = _("delete_router_interface() failed due to %s") % exc
|
||||
LOG.error(reason)
|
||||
LOG.error(_LE("delete_router_interface() failed due to %s"),
|
||||
exc)
|
||||
new_status = nconst.ROUTER_STATUS_ERROR
|
||||
self.plugin._update_resource_status(context, "port", port_id,
|
||||
new_status)
|
||||
|
Loading…
x
Reference in New Issue
Block a user