from neutron.common import constants
from neutron.common import exceptions
+from neutron.openstack.common.gettextutils import _LW
from neutron.openstack.common import log as logging
if max_limit == 0:
raise ValueError()
except ValueError:
- LOG.warn(_("Invalid value for pagination_max_limit: %s. It "
- "should be an integer greater to 0"),
+ LOG.warn(_LW("Invalid value for pagination_max_limit: %s. It "
+ "should be an integer greater to 0"),
cfg.CONF.pagination_max_limit)
return max_limit
from neutron.common import exceptions
import neutron.extensions
from neutron import manager
+from neutron.openstack.common.gettextutils import _LE, _LI, _LW
from neutron.openstack.common import log as logging
from neutron import policy
from neutron import wsgi
(resource.parent["collection_name"],
resource.parent["member_name"]))
- LOG.debug(_('Extended resource: %s'),
+ LOG.debug('Extended resource: %s',
resource.collection)
for action, method in resource.collection_actions.iteritems():
conditions = dict(method=[method])
action_controllers = self._action_ext_controllers(application,
self.ext_mgr, mapper)
for action in self.ext_mgr.get_actions():
- LOG.debug(_('Extended action: %s'), action.action_name)
+ LOG.debug('Extended action: %s', action.action_name)
controller = action_controllers[action.collection]
controller.add_action(action.action_name, action.handler)
req_controllers = self._request_ext_controllers(application,
self.ext_mgr, mapper)
for request_ext in self.ext_mgr.get_request_extensions():
- LOG.debug(_('Extended request: %s'), request_ext.key)
+ LOG.debug('Extended request: %s', request_ext.key)
controller = req_controllers[request_ext.key]
controller.add_handler(request_ext.handler)
"""
def __init__(self, path):
- LOG.info(_('Initializing extension manager.'))
+ LOG.info(_LI('Initializing extension manager.'))
self.path = path
self.extensions = {}
self._load_all_extensions()
else:
attr_map[resource] = resource_attrs
except AttributeError:
- LOG.exception(_("Error fetching extended attributes for "
- "extension '%s'"), ext.get_name())
+ LOG.exception(_LE("Error fetching extended attributes for "
+ "extension '%s'"), ext.get_name())
processed_exts.add(ext_name)
del exts_to_process[ext_name]
if len(processed_exts) == processed_ext_count:
break
if exts_to_process:
# NOTE(salv-orlando): Consider whether this error should be fatal
- LOG.error(_("It was impossible to process the following "
- "extensions: %s because of missing requirements."),
+ LOG.error(_LE("It was impossible to process the following "
+ "extensions: %s because of missing requirements."),
','.join(exts_to_process.keys()))
# Extending extensions' attributes map.
def _check_extension(self, extension):
"""Checks for required methods in extension objects."""
try:
- LOG.debug(_('Ext name: %s'), extension.get_name())
- LOG.debug(_('Ext alias: %s'), extension.get_alias())
- LOG.debug(_('Ext description: %s'), extension.get_description())
- LOG.debug(_('Ext namespace: %s'), extension.get_namespace())
- LOG.debug(_('Ext updated: %s'), extension.get_updated())
+ LOG.debug('Ext name: %s', extension.get_name())
+ LOG.debug('Ext alias: %s', extension.get_alias())
+ LOG.debug('Ext description: %s', extension.get_description())
+ LOG.debug('Ext namespace: %s', extension.get_namespace())
+ LOG.debug('Ext updated: %s', extension.get_updated())
except AttributeError as ex:
- LOG.exception(_("Exception loading extension: %s"), unicode(ex))
+ LOG.exception(_LE("Exception loading extension: %s"), unicode(ex))
return False
return True
if os.path.exists(path):
self._load_all_extensions_from_path(path)
else:
- LOG.error(_("Extension path '%s' doesn't exist!"), path)
+ LOG.error(_LE("Extension path '%s' doesn't exist!"), path)
def _load_all_extensions_from_path(self, path):
# Sorting the extension list makes the order in which they
# Neutron Servers
for f in sorted(os.listdir(path)):
try:
- LOG.debug(_('Loading extension file: %s'), f)
+ LOG.debug('Loading extension file: %s', f)
mod_name, file_ext = os.path.splitext(os.path.split(f)[-1])
ext_path = os.path.join(path, f)
if file_ext.lower() == '.py' and not mod_name.startswith('_'):
ext_name = mod_name[0].upper() + mod_name[1:]
new_ext_class = getattr(mod, ext_name, None)
if not new_ext_class:
- LOG.warn(_('Did not find expected name '
- '"%(ext_name)s" in %(file)s'),
+ LOG.warn(_LW('Did not find expected name '
+ '"%(ext_name)s" in %(file)s'),
{'ext_name': ext_name,
'file': ext_path})
continue
new_ext = new_ext_class()
self.add_extension(new_ext)
except Exception as exception:
- LOG.warn(_("Extension file %(f)s wasn't loaded due to "
- "%(exception)s"), {'f': f, 'exception': exception})
+ LOG.warn(_LW("Extension file %(f)s wasn't loaded due to "
+ "%(exception)s"),
+ {'f': f, 'exception': exception})
def add_extension(self, ext):
# Do nothing if the extension doesn't check out
return
alias = ext.get_alias()
- LOG.info(_('Loaded extension: %s'), alias)
+ LOG.info(_LI('Loaded extension: %s'), alias)
if alias in self.extensions:
raise exceptions.DuplicatedExtension(alias=alias)
alias in plugin.supported_extension_aliases)
for plugin in self.plugins.values())
if not supports_extension:
- LOG.warn(_("Extension %s not supported by any of loaded plugins"),
+ LOG.warn(_LW("Extension %s not supported by any of loaded "
+ "plugins"),
alias)
return supports_extension
for plugin in self.plugins.values():
if isinstance(plugin, extension.get_plugin_interface()):
return True
- LOG.warn(_("Loaded plugins do not implement extension %s interface"),
+ LOG.warn(_LW("Loaded plugins do not implement extension %s interface"),
extension.get_alias())
return False
from neutron.common import topics
from neutron.common import utils
from neutron import manager
+from neutron.openstack.common.gettextutils import _LE, _LW
from neutron.openstack.common import log as logging
context, 'network_create_end',
{'network': {'id': network['id']}}, agent['host'])
elif not existing_agents:
- LOG.warn(_('Unable to schedule network %s: no agents available; '
- 'will retry on subsequent port creation events.'),
+ LOG.warn(_LW('Unable to schedule network %s: no agents available; '
+ 'will retry on subsequent port creation events.'),
network['id'])
return new_agents + existing_agents
len_enabled_agents = len(enabled_agents)
len_active_agents = len(active_agents)
if len_active_agents < len_enabled_agents:
- LOG.warn(_("Only %(active)d of %(total)d DHCP agents associated "
- "with network '%(net_id)s' are marked as active, so "
- " notifications may be sent to inactive agents.")
- % {'active': len_active_agents,
- 'total': len_enabled_agents,
- 'net_id': network_id})
+ LOG.warn(_LW("Only %(active)d of %(total)d DHCP agents associated "
+ "with network '%(net_id)s' are marked as active, so "
+ "notifications may be sent to inactive agents."),
+ {'active': len_active_agents,
+ 'total': len_enabled_agents,
+ 'net_id': network_id})
if not enabled_agents:
num_ports = self.plugin.get_ports_count(
context, {'network_id': [network_id]})
notification_required = (
num_ports > 0 and len(network['subnets']) >= 1)
if notification_required:
- LOG.error(_("Will not send event %(method)s for network "
- "%(net_id)s: no agent available. Payload: "
- "%(payload)s")
- % {'method': method,
- 'net_id': network_id,
- 'payload': payload})
+ LOG.error(_LE("Will not send event %(method)s for network "
+ "%(net_id)s: no agent available. Payload: "
+ "%(payload)s"),
+ {'method': method,
+ 'net_id': network_id,
+ 'payload': payload})
return enabled_agents
def _is_reserved_dhcp_port(self, port):
from neutron.common import topics
from neutron.common import utils
from neutron import manager
+from neutron.openstack.common.gettextutils import _LE
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as service_constants
def _notification_host(self, context, method, payload, host):
"""Notify the agent that is hosting the router."""
- LOG.debug(_('Nofity agent at %(host)s the message '
- '%(method)s'), {'host': host,
- 'method': method})
+ LOG.debug('Nofity agent at %(host)s the message '
+ '%(method)s', {'host': host,
+ 'method': method})
self.cast(
context, self.make_msg(method,
payload=payload),
if shuffle_agents:
random.shuffle(l3_agents)
for l3_agent in l3_agents:
- LOG.debug(_('Notify agent at %(topic)s.%(host)s the message '
- '%(method)s'),
+ LOG.debug('Notify agent at %(topic)s.%(host)s the message '
+ '%(method)s',
{'topic': l3_agent.topic,
'host': l3_agent.host,
'method': method})
plugin = manager.NeutronManager.get_service_plugins().get(
service_constants.L3_ROUTER_NAT)
if not plugin:
- LOG.error(_('No plugin for L3 routing registered. Cannot notify '
- 'agents with the message %s'), method)
+ LOG.error(_LE('No plugin for L3 routing registered. Cannot notify '
+ 'agents with the message %s'), method)
return
if utils.is_extension_supported(
plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
def _notification_fanout(self, context, method, router_id):
"""Fanout the deleted router to all L3 agents."""
- LOG.debug(_('Fanout notify agent at %(topic)s the message '
- '%(method)s on router %(router_id)s'),
+ LOG.debug('Fanout notify agent at %(topic)s the message '
+ '%(method)s on router %(router_id)s',
{'topic': topics.L3_AGENT,
'method': method,
'router_id': router_id})
admin_state_up=True,
active=True)
for l3_agent in l3_agents:
- LOG.debug(_('Notify metering agent at %(topic)s.%(host)s '
- 'the message %(method)s'),
+ LOG.debug('Notify metering agent at %(topic)s.%(host)s '
+ 'the message %(method)s',
{'topic': self.topic,
'host': l3_agent.host,
'method': method})
topic='%s.%s' % (self.topic, host))
def _notification_fanout(self, context, method, router_id):
- LOG.debug(_('Fanout notify metering agent at %(topic)s the message '
- '%(method)s on router %(router_id)s'),
+ LOG.debug('Fanout notify metering agent at %(topic)s the message '
+ '%(method)s on router %(router_id)s',
{'topic': self.topic,
'method': method,
'router_id': router_id})
from neutron.extensions import portbindings
from neutron import manager
from neutron.openstack.common import excutils
+from neutron.openstack.common.gettextutils import _LW
from neutron.openstack.common import log as logging
else:
ctxt.reraise = True
net_id = port['port']['network_id']
- LOG.warn(_("Action %(action)s for network %(net_id)s "
- "could not complete successfully: %(reason)s")
- % {"action": action, "net_id": net_id, 'reason': e})
+ LOG.warn(_LW("Action %(action)s for network %(net_id)s "
+ "could not complete successfully: %(reason)s"),
+ {"action": action, "net_id": net_id, 'reason': e})
def get_active_networks(self, context, **kwargs):
"""Retrieve and return a list of the active network ids."""
# left so that neutron-dhcp-agents will still continue to work if
# neutron-server is upgraded and not the agent.
host = kwargs.get('host')
- LOG.debug(_('get_active_networks requested from %s'), host)
+ LOG.debug('get_active_networks requested from %s', host)
nets = self._get_active_networks(context, **kwargs)
return [net['id'] for net in nets]
def get_active_networks_info(self, context, **kwargs):
"""Returns all the networks/subnets/ports in system."""
host = kwargs.get('host')
- LOG.debug(_('get_active_networks_info from %s'), host)
+ LOG.debug('get_active_networks_info from %s', host)
networks = self._get_active_networks(context, **kwargs)
plugin = manager.NeutronManager.get_plugin()
filters = {'network_id': [network['id'] for network in networks]}
"""Retrieve and return a extended information about a network."""
network_id = kwargs.get('network_id')
host = kwargs.get('host')
- LOG.debug(_('Network %(network_id)s requested from '
- '%(host)s'), {'network_id': network_id,
- 'host': host})
+ LOG.debug('Network %(network_id)s requested from '
+ '%(host)s', {'network_id': network_id,
+ 'host': host})
plugin = manager.NeutronManager.get_plugin()
try:
network = plugin.get_network(context, network_id)
except n_exc.NetworkNotFound:
- LOG.warn(_("Network %s could not be found, it might have "
- "been deleted concurrently."), network_id)
+ LOG.warn(_LW("Network %s could not be found, it might have "
+ "been deleted concurrently."), network_id)
return
filters = dict(network_id=[network_id])
network['subnets'] = plugin.get_subnets(context, filters=filters)
# There could be more than one dhcp server per network, so create
# a device id that combines host and network ids
- LOG.debug(_('Port %(device_id)s for %(network_id)s requested from '
- '%(host)s'), {'device_id': device_id,
- 'network_id': network_id,
- 'host': host})
+ LOG.debug('Port %(device_id)s for %(network_id)s requested from '
+ '%(host)s', {'device_id': device_id,
+ 'network_id': network_id,
+ 'host': host})
plugin = manager.NeutronManager.get_plugin()
retval = None
if retval is None:
# No previous port exists, so create a new one.
- LOG.debug(_('DHCP port %(device_id)s on network %(network_id)s '
- 'does not exist on %(host)s'),
+ LOG.debug('DHCP port %(device_id)s on network %(network_id)s '
+ 'does not exist on %(host)s',
{'device_id': device_id,
'network_id': network_id,
'host': host})
try:
network = plugin.get_network(context, network_id)
except n_exc.NetworkNotFound:
- LOG.warn(_("Network %s could not be found, it might have "
- "been deleted concurrently."), network_id)
+ LOG.warn(_LW("Network %s could not be found, it might have "
+ "been deleted concurrently."), network_id)
return
port_dict = dict(
network_id = kwargs.get('network_id')
device_id = kwargs.get('device_id')
- LOG.debug(_('DHCP port deletion for %(network_id)s request from '
- '%(host)s'),
+ LOG.debug('DHCP port deletion for %(network_id)s request from '
+ '%(host)s',
{'network_id': network_id, 'host': host})
plugin = manager.NeutronManager.get_plugin()
plugin.delete_ports_by_device_id(context, device_id, network_id)
device_id = kwargs.get('device_id')
subnet_id = kwargs.get('subnet_id')
- LOG.debug(_('DHCP port remove fixed_ip for %(subnet_id)s request '
- 'from %(host)s'),
+ LOG.debug('DHCP port remove fixed_ip for %(subnet_id)s request '
+ 'from %(host)s',
{'subnet_id': subnet_id, 'host': host})
plugin = manager.NeutronManager.get_plugin()
filters = dict(network_id=[network_id], device_id=[device_id])
# neutron-server is upgraded and not the agent.
host = kwargs.get('host')
- LOG.warning(_('Updating lease expiration is now deprecated. Issued '
- 'from host %s.'), host)
+ LOG.warning(_LW('Updating lease expiration is now deprecated. Issued '
+ 'from host %s.'), host)
def create_dhcp_port(self, context, **kwargs):
"""Create and return dhcp port information.
"""
host = kwargs.get('host')
port = kwargs.get('port')
- LOG.debug(_('Create dhcp port %(port)s '
- 'from %(host)s.'),
+ LOG.debug('Create dhcp port %(port)s '
+ 'from %(host)s.',
{'port': port,
'host': host})
host = kwargs.get('host')
port = kwargs.get('port')
port['id'] = kwargs.get('port_id')
- LOG.debug(_('Update dhcp port %(port)s '
- 'from %(host)s.'),
+ LOG.debug('Update dhcp port %(port)s '
+ 'from %(host)s.',
{'port': port,
'host': host})
plugin = manager.NeutronManager.get_plugin()
from neutron.extensions import l3
from neutron.extensions import portbindings
from neutron import manager
+from neutron.openstack.common.gettextutils import _LE
from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as plugin_constants
context = neutron_context.get_admin_context()
if not self.l3plugin:
routers = {}
- LOG.error(_('No plugin for L3 routing registered! Will reply '
- 'to l3 agent with empty router dictionary.'))
+ LOG.error(_LE('No plugin for L3 routing registered! Will reply '
+ 'to l3 agent with empty router dictionary.'))
elif utils.is_extension_supported(
self.l3plugin, constants.L3_AGENT_SCHEDULER_EXT_ALIAS):
if cfg.CONF.router_auto_schedule:
if utils.is_extension_supported(
self.plugin, constants.PORT_BINDING_EXT_ALIAS):
self._ensure_host_set_on_ports(context, host, routers)
- LOG.debug(_("Routers returned to l3 agent:\n %s"),
+ LOG.debug("Routers returned to l3 agent:\n %s",
jsonutils.dumps(routers, indent=5))
return routers
def _ensure_host_set_on_ports(self, context, host, routers):
for router in routers:
- LOG.debug(_("Checking router: %(id)s for host: %(host)s"),
+ LOG.debug("Checking router: %(id)s for host: %(host)s",
{'id': router['id'], 'host': host})
if router.get('gw_port') and router.get('distributed'):
self._ensure_host_set_on_port(context,
"""
context = neutron_context.get_admin_context()
net_id = self.plugin.get_external_network_id(context)
- LOG.debug(_("External network ID returned to l3 agent: %s"),
+ LOG.debug("External network ID returned to l3 agent: %s",
net_id)
return net_id
"""Update operational status for a floating IP."""
with context.session.begin(subtransactions=True):
for (floatingip_id, status) in fip_statuses.iteritems():
- LOG.debug(_("New status for floating IP %(floatingip_id)s: "
- "%(status)s"), {'floatingip_id': floatingip_id,
- 'status': status})
+ LOG.debug("New status for floating IP %(floatingip_id)s: "
+ "%(status)s", {'floatingip_id': floatingip_id,
+ 'status': status})
try:
self.l3plugin.update_floatingip_status(context,
floatingip_id,
status)
except l3.FloatingIPNotFound:
- LOG.debug(_("Floating IP: %s no longer present."),
+ LOG.debug("Floating IP: %s no longer present.",
floatingip_id)
# Find all floating IPs known to have been the given router
# for which an update was not received. Set them DOWN mercilessly
from neutron.common import exceptions
from neutron.common import rpc as n_rpc
from neutron.openstack.common import excutils
+from neutron.openstack.common.gettextutils import _LE, _LI
from neutron.openstack.common import log as logging
from neutron.openstack.common import policy as common_policy
from neutron import policy
_("Native pagination depend on native sorting")
)
if not self._allow_sorting:
- LOG.info(_("Allow sorting is enabled because native "
- "pagination requires native sorting"))
+ LOG.info(_LI("Allow sorting is enabled because native "
+ "pagination requires native sorting"))
self._allow_sorting = True
if parent:
obj_deleter(request.context, obj['id'], **kwargs)
except Exception:
# broad catch as our only purpose is to log the exception
- LOG.exception(_("Unable to undo add for "
- "%(resource)s %(id)s"),
+ LOG.exception(_LE("Unable to undo add for "
+ "%(resource)s %(id)s"),
{'resource': self._resource,
'id': obj['id']})
# TODO(salvatore-orlando): The object being processed when the
if not body:
raise webob.exc.HTTPBadRequest(_("Resource body required"))
- LOG.debug(_("Request body: %(body)s"), {'body': body})
+ LOG.debug("Request body: %(body)s", {'body': body})
if collection in body:
if not allow_bulk:
raise webob.exc.HTTPBadRequest(_("Bulk operation "
from neutron.common import exceptions
from neutron.openstack.common import gettextutils
+from neutron.openstack.common.gettextutils import _LE, _LI
from neutron.openstack.common import log as logging
from neutron.openstack.common import policy as common_policy
from neutron import wsgi
else:
mapped_exc = webob.exc.HTTPInternalServerError
if 400 <= mapped_exc.code < 500:
- LOG.info(_('%(action)s failed (client error): %(exc)s'),
+ LOG.info(_LI('%(action)s failed (client error): %(exc)s'),
{'action': action, 'exc': e})
else:
- LOG.exception(_('%s failed'), action)
+ LOG.exception(_LE('%s failed'), action)
e = translate(e, language)
body = serializer.serialize(
{'NeutronError': get_exception_data(e)})
raise mapped_exc(**kwargs)
except webob.exc.HTTPException as e:
type_, value, tb = sys.exc_info()
- LOG.exception(_('%s failed'), action)
+ LOG.exception(_LE('%s failed'), action)
translate(e, language)
value.body = serializer.serialize(
{'NeutronError': get_exception_data(e)})
raise webob.exc.HTTPNotImplemented(**kwargs)
except Exception:
# NOTE(jkoelker) Everything else is 500
- LOG.exception(_('%s failed'), action)
+ LOG.exception(_LE('%s failed'), action)
# Do not expose details of 500 error to clients.
msg = _('Request Failed: internal server error while '
'processing your request.')
# do it on a directory by directory basis. The last patch of the
# series will remove this and the entire code base will be validated.
dirs = ["neutron/agent",
+ "neutron/api",
"neutron/cmd",
"neutron/db",
"neutron/extensions"]