"neutron/plugins/midonet",
"neutron/plugins/ml2",
"neutron/plugins/mlnx",
- #"neutron/plugins/nec",
+ "neutron/plugins/nec",
"neutron/plugins/nuage",
#"neutron/plugins/ofagent",
#"neutron/plugins/oneconvergence",
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
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',
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'])
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()
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,
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):
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
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:
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})
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}
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
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
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
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)
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
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)
from oslo.utils import importutils
+from neutron.i18n import _LI
from neutron.openstack.common import log as logging
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)
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
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.
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']:
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:
# 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:
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()
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):
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']:
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]})
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)
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
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):
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()
'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', []):
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)
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
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
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(
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):
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']
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)
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,
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()})
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)
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
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'):
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']
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:
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)
* 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:
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(
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,
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
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'],
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)
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)
# 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'])
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)
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)