Update i18n translation for neutron.db log msg's

Validate that hacking rules apply to directory neutron/db
Partial-bug: #1320867

Change-Id: Iffdaa28bf5d5d503623f1f6dec4a8003f48974d8
This commit is contained in:
Gary Kotton 2014-11-10 07:29:58 -08:00
parent 99cd58ae45
commit 069aa9d1ed
12 changed files with 95 additions and 82 deletions

View File

@ -28,6 +28,7 @@ from neutron.db import models_v2
from neutron.extensions import agent as ext_agent from neutron.extensions import agent as ext_agent
from neutron import manager from neutron import manager
from neutron.openstack.common import excutils from neutron.openstack.common import excutils
from neutron.openstack.common.gettextutils import _LW
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.openstack.common import timeutils from neutron.openstack.common import timeutils
@ -95,8 +96,8 @@ class AgentDbMixin(ext_agent.AgentPluginBase):
'%(host)s' % {'agent_type': agent_type, 'host': host}) '%(host)s' % {'agent_type': agent_type, 'host': host})
return return
if self.is_agent_down(agent.heartbeat_timestamp): if self.is_agent_down(agent.heartbeat_timestamp):
LOG.warn(_('%(agent_type)s agent %(agent_id)s is not active') LOG.warn(_LW('%(agent_type)s agent %(agent_id)s is not active'),
% {'agent_type': agent_type, 'agent_id': agent.id}) {'agent_type': agent_type, 'agent_id': agent.id})
return agent return agent
@classmethod @classmethod
@ -108,8 +109,8 @@ class AgentDbMixin(ext_agent.AgentPluginBase):
try: try:
conf = jsonutils.loads(agent_db.configurations) conf = jsonutils.loads(agent_db.configurations)
except Exception: except Exception:
msg = _('Configuration for agent %(agent_type)s on host %(host)s' msg = _LW('Configuration for agent %(agent_type)s on host %(host)s'
' is invalid.') ' is invalid.')
LOG.warn(msg, {'agent_type': agent_db.agent_type, LOG.warn(msg, {'agent_type': agent_db.agent_type,
'host': agent_db.host}) 'host': agent_db.host})
conf = {} conf = {}
@ -229,7 +230,7 @@ class AgentExtRpcCallback(n_rpc.RpcCallback):
time = kwargs['time'] time = kwargs['time']
time = timeutils.parse_strtime(time) time = timeutils.parse_strtime(time)
if self.START_TIME > time: if self.START_TIME > time:
LOG.debug(_("Message with invalid timestamp received")) LOG.debug("Message with invalid timestamp received")
return return
agent_state = kwargs['agent_state']['agent_state'] agent_state = kwargs['agent_state']['agent_state']
if not self.plugin: if not self.plugin:

View File

@ -34,6 +34,7 @@ from neutron.extensions import l3
from neutron import manager from neutron import manager
from neutron import neutron_plugin_base_v2 from neutron import neutron_plugin_base_v2
from neutron.openstack.common import excutils 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 log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants as service_constants from neutron.plugins.common import constants as service_constants
@ -138,17 +139,17 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
mac_address = ':'.join(map(lambda x: "%02x" % x, mac)) mac_address = ':'.join(map(lambda x: "%02x" % x, mac))
if NeutronDbPluginV2._check_unique_mac(context, network_id, if NeutronDbPluginV2._check_unique_mac(context, network_id,
mac_address): mac_address):
LOG.debug(_("Generated mac for network %(network_id)s " LOG.debug("Generated mac for network %(network_id)s "
"is %(mac_address)s"), "is %(mac_address)s",
{'network_id': network_id, {'network_id': network_id,
'mac_address': mac_address}) 'mac_address': mac_address})
return mac_address return mac_address
else: else:
LOG.debug(_("Generated mac %(mac_address)s exists. Remaining " LOG.debug("Generated mac %(mac_address)s exists. Remaining "
"attempts %(max_retries)s."), "attempts %(max_retries)s.",
{'mac_address': mac_address, {'mac_address': mac_address,
'max_retries': max_retries - (i + 1)}) 'max_retries': max_retries - (i + 1)})
LOG.error(_("Unable to generate mac address after %s attempts"), LOG.error(_LE("Unable to generate mac address after %s attempts"),
max_retries) max_retries)
raise n_exc.MacAddressGenerationFailure(net_id=network_id) raise n_exc.MacAddressGenerationFailure(net_id=network_id)
@ -166,8 +167,8 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
def _delete_ip_allocation(context, network_id, subnet_id, ip_address): def _delete_ip_allocation(context, network_id, subnet_id, ip_address):
# Delete the IP address from the IPAllocate table # Delete the IP address from the IPAllocate table
LOG.debug(_("Delete allocated IP %(ip_address)s " LOG.debug("Delete allocated IP %(ip_address)s "
"(%(network_id)s/%(subnet_id)s)"), "(%(network_id)s/%(subnet_id)s)",
{'ip_address': ip_address, {'ip_address': ip_address,
'network_id': network_id, 'network_id': network_id,
'subnet_id': subnet_id}) 'subnet_id': subnet_id})
@ -257,8 +258,8 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
models_v2.IPAllocationPool).options( models_v2.IPAllocationPool).options(
orm.noload('available_ranges')).with_lockmode('update') orm.noload('available_ranges')).with_lockmode('update')
for subnet in sorted(subnets): for subnet in sorted(subnets):
LOG.debug(_("Rebuilding availability ranges for subnet %s") LOG.debug("Rebuilding availability ranges for subnet %s",
% subnet) subnet)
# Create a set of all currently allocated addresses # Create a set of all currently allocated addresses
ip_qry_results = ip_qry.filter_by(subnet_id=subnet['id']) ip_qry_results = ip_qry.filter_by(subnet_id=subnet['id'])
@ -517,14 +518,14 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
to_add = self._test_fixed_ips_for_port(context, network_id, new_ips, to_add = self._test_fixed_ips_for_port(context, network_id, new_ips,
device_owner) device_owner)
for ip in original_ips: for ip in original_ips:
LOG.debug(_("Port update. Hold %s"), ip) LOG.debug("Port update. Hold %s", ip)
NeutronDbPluginV2._delete_ip_allocation(context, NeutronDbPluginV2._delete_ip_allocation(context,
network_id, network_id,
ip['subnet_id'], ip['subnet_id'],
ip['ip_address']) ip['ip_address'])
if to_add: if to_add:
LOG.debug(_("Port update. Adding %s"), to_add) LOG.debug("Port update. Adding %s", to_add)
ips = self._allocate_fixed_ips(context, to_add, mac_address) ips = self._allocate_fixed_ips(context, to_add, mac_address)
return ips, prev_ips return ips, prev_ips
@ -615,9 +616,9 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
"subnet") % "subnet") %
{'cidr': new_subnet_cidr, {'cidr': new_subnet_cidr,
'network_id': network.id}) 'network_id': network.id})
LOG.info(_("Validation for CIDR: %(new_cidr)s failed - " LOG.info(_LI("Validation for CIDR: %(new_cidr)s failed - "
"overlaps with subnet %(subnet_id)s " "overlaps with subnet %(subnet_id)s "
"(CIDR: %(cidr)s)"), "(CIDR: %(cidr)s)"),
{'new_cidr': new_subnet_cidr, {'new_cidr': new_subnet_cidr,
'subnet_id': subnet.id, 'subnet_id': subnet.id,
'cidr': subnet.cidr}) 'cidr': subnet.cidr})
@ -635,31 +636,31 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
subnet_first_ip = netaddr.IPAddress(subnet.first + 1) subnet_first_ip = netaddr.IPAddress(subnet.first + 1)
subnet_last_ip = netaddr.IPAddress(subnet.last - 1) subnet_last_ip = netaddr.IPAddress(subnet.last - 1)
LOG.debug(_("Performing IP validity checks on allocation pools")) LOG.debug("Performing IP validity checks on allocation pools")
ip_sets = [] ip_sets = []
for ip_pool in ip_pools: for ip_pool in ip_pools:
try: try:
start_ip = netaddr.IPAddress(ip_pool['start']) start_ip = netaddr.IPAddress(ip_pool['start'])
end_ip = netaddr.IPAddress(ip_pool['end']) end_ip = netaddr.IPAddress(ip_pool['end'])
except netaddr.AddrFormatError: except netaddr.AddrFormatError:
LOG.info(_("Found invalid IP address in pool: " LOG.info(_LI("Found invalid IP address in pool: "
"%(start)s - %(end)s:"), "%(start)s - %(end)s:"),
{'start': ip_pool['start'], {'start': ip_pool['start'],
'end': ip_pool['end']}) 'end': ip_pool['end']})
raise n_exc.InvalidAllocationPool(pool=ip_pool) raise n_exc.InvalidAllocationPool(pool=ip_pool)
if (start_ip.version != subnet.version or if (start_ip.version != subnet.version or
end_ip.version != subnet.version): end_ip.version != subnet.version):
LOG.info(_("Specified IP addresses do not match " LOG.info(_LI("Specified IP addresses do not match "
"the subnet IP version")) "the subnet IP version"))
raise n_exc.InvalidAllocationPool(pool=ip_pool) raise n_exc.InvalidAllocationPool(pool=ip_pool)
if end_ip < start_ip: if end_ip < start_ip:
LOG.info(_("Start IP (%(start)s) is greater than end IP " LOG.info(_LI("Start IP (%(start)s) is greater than end IP "
"(%(end)s)"), "(%(end)s)"),
{'start': ip_pool['start'], 'end': ip_pool['end']}) {'start': ip_pool['start'], 'end': ip_pool['end']})
raise n_exc.InvalidAllocationPool(pool=ip_pool) raise n_exc.InvalidAllocationPool(pool=ip_pool)
if start_ip < subnet_first_ip or end_ip > subnet_last_ip: if start_ip < subnet_first_ip or end_ip > subnet_last_ip:
LOG.info(_("Found pool larger than subnet " LOG.info(_LI("Found pool larger than subnet "
"CIDR:%(start)s - %(end)s"), "CIDR:%(start)s - %(end)s"),
{'start': ip_pool['start'], {'start': ip_pool['start'],
'end': ip_pool['end']}) 'end': ip_pool['end']})
raise n_exc.OutOfBoundsAllocationPool( raise n_exc.OutOfBoundsAllocationPool(
@ -671,8 +672,8 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
ip_pool['start'], ip_pool['start'],
ip_pool['end']).cidrs())) ip_pool['end']).cidrs()))
LOG.debug(_("Checking for overlaps among allocation pools " LOG.debug("Checking for overlaps among allocation pools "
"and gateway ip")) "and gateway ip")
ip_ranges = ip_pools[:] ip_ranges = ip_pools[:]
# Use integer cursors as an efficient way for implementing # Use integer cursors as an efficient way for implementing
@ -682,8 +683,8 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
if ip_sets[l_cursor] & ip_sets[r_cursor]: if ip_sets[l_cursor] & ip_sets[r_cursor]:
l_range = ip_ranges[l_cursor] l_range = ip_ranges[l_cursor]
r_range = ip_ranges[r_cursor] r_range = ip_ranges[r_cursor]
LOG.info(_("Found overlapping ranges: %(l_range)s and " LOG.info(_LI("Found overlapping ranges: %(l_range)s and "
"%(r_range)s"), "%(r_range)s"),
{'l_range': l_range, 'r_range': r_range}) {'l_range': l_range, 'r_range': r_range})
raise n_exc.OverlappingAllocationPools( raise n_exc.OverlappingAllocationPools(
pool_1=l_range, pool_1=l_range,
@ -891,8 +892,8 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
except Exception: except Exception:
context.session.rollback() context.session.rollback()
with excutils.save_and_reraise_exception(): with excutils.save_and_reraise_exception():
LOG.error(_("An exception occurred while creating " LOG.error(_LE("An exception occurred while creating "
"the %(resource)s:%(item)s"), "the %(resource)s:%(item)s"),
{'resource': resource, 'item': item}) {'resource': resource, 'item': item})
return objects return objects
@ -1431,8 +1432,8 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
self.delete_port(context, port_id) self.delete_port(context, port_id)
except n_exc.PortNotFound: except n_exc.PortNotFound:
# Don't raise if something else concurrently deleted the port # Don't raise if something else concurrently deleted the port
LOG.debug(_("Ignoring PortNotFound when deleting port '%s'. " LOG.debug("Ignoring PortNotFound when deleting port '%s'. "
"The port has already been deleted."), "The port has already been deleted.",
port_id) port_id)
def _delete_port(self, context, id): def _delete_port(self, context, id):

View File

@ -24,6 +24,7 @@ from neutron.db import model_base
from neutron.extensions import dvr as ext_dvr from neutron.extensions import dvr as ext_dvr
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron import manager from neutron import manager
from neutron.openstack.common.gettextutils import _LE
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from oslo.config import cfg from oslo.config import cfg
from sqlalchemy.orm import exc from sqlalchemy.orm import exc
@ -93,7 +94,7 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
LOG.debug("Generated DVR mac %(mac)s exists." LOG.debug("Generated DVR mac %(mac)s exists."
" Remaining attempts %(attempts_left)s.", " Remaining attempts %(attempts_left)s.",
{'mac': mac_address, 'attempts_left': attempt}) {'mac': mac_address, 'attempts_left': attempt})
LOG.error(_("MAC generation error after %s attempts"), max_retries) LOG.error(_LE("MAC generation error after %s attempts"), max_retries)
raise ext_dvr.MacAddressGenerationFailure(host=host) raise ext_dvr.MacAddressGenerationFailure(host=host)
def delete_dvr_mac_address(self, context, host): def delete_dvr_mac_address(self, context, host):
@ -165,8 +166,8 @@ class DVRDbMixin(ext_dvr.DVRMacAddressPluginBase):
internal_gateway_ports = self.plugin.get_ports( internal_gateway_ports = self.plugin.get_ports(
context, filters=filter) context, filters=filter)
if not internal_gateway_ports: if not internal_gateway_ports:
LOG.error(_("Could not retrieve gateway port " LOG.error(_LE("Could not retrieve gateway port "
"for subnet %s"), subnet_info) "for subnet %s"), subnet_info)
return {} return {}
internal_port = internal_gateway_ports[0] internal_port = internal_gateway_ports[0]
subnet_info['gateway_mac'] = internal_port['mac_address'] subnet_info['gateway_mac'] = internal_port['mac_address']

View File

@ -122,7 +122,7 @@ class ExtraRoute_dbonly_mixin(l3_db.L3_NAT_dbonly_mixin):
context, router['id']) context, router['id'])
added, removed = utils.diff_list_of_dict(old_routes, added, removed = utils.diff_list_of_dict(old_routes,
routes) routes)
LOG.debug(_('Added routes are %s'), added) LOG.debug('Added routes are %s', added)
for route in added: for route in added:
router_routes = RouterRoute( router_routes = RouterRoute(
router_id=router['id'], router_id=router['id'],
@ -130,7 +130,7 @@ class ExtraRoute_dbonly_mixin(l3_db.L3_NAT_dbonly_mixin):
nexthop=route['nexthop']) nexthop=route['nexthop'])
context.session.add(router_routes) context.session.add(router_routes)
LOG.debug(_('Removed routes are %s'), removed) LOG.debug('Removed routes are %s', removed)
for route in removed: for route in removed:
context.session.delete( context.session.delete(
routes_dict[(route['destination'], route['nexthop'])]) routes_dict[(route['destination'], route['nexthop'])])

View File

@ -264,7 +264,7 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
param="Source, destination port") param="Source, destination port")
def create_firewall(self, context, firewall): def create_firewall(self, context, firewall):
LOG.debug(_("create_firewall() called")) LOG.debug("create_firewall() called")
fw = firewall['firewall'] fw = firewall['firewall']
tenant_id = self._get_tenant_id_for_create(context, fw) tenant_id = self._get_tenant_id_for_create(context, fw)
# distributed routers may required a more complex state machine; # distributed routers may required a more complex state machine;
@ -285,7 +285,7 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
return self._make_firewall_dict(firewall_db) return self._make_firewall_dict(firewall_db)
def update_firewall(self, context, id, firewall): def update_firewall(self, context, id, firewall):
LOG.debug(_("update_firewall() called")) LOG.debug("update_firewall() called")
fw = firewall['firewall'] fw = firewall['firewall']
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
count = context.session.query(Firewall).filter_by(id=id).update(fw) count = context.session.query(Firewall).filter_by(id=id).update(fw)
@ -294,7 +294,7 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
return self.get_firewall(context, id) return self.get_firewall(context, id)
def delete_firewall(self, context, id): def delete_firewall(self, context, id):
LOG.debug(_("delete_firewall() called")) LOG.debug("delete_firewall() called")
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
# Note: Plugin should ensure that it's okay to delete if the # Note: Plugin should ensure that it's okay to delete if the
# firewall is active # firewall is active
@ -303,23 +303,23 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
raise firewall.FirewallNotFound(firewall_id=id) raise firewall.FirewallNotFound(firewall_id=id)
def get_firewall(self, context, id, fields=None): def get_firewall(self, context, id, fields=None):
LOG.debug(_("get_firewall() called")) LOG.debug("get_firewall() called")
fw = self._get_firewall(context, id) fw = self._get_firewall(context, id)
return self._make_firewall_dict(fw, fields) return self._make_firewall_dict(fw, fields)
def get_firewalls(self, context, filters=None, fields=None): def get_firewalls(self, context, filters=None, fields=None):
LOG.debug(_("get_firewalls() called")) LOG.debug("get_firewalls() called")
return self._get_collection(context, Firewall, return self._get_collection(context, Firewall,
self._make_firewall_dict, self._make_firewall_dict,
filters=filters, fields=fields) filters=filters, fields=fields)
def get_firewalls_count(self, context, filters=None): def get_firewalls_count(self, context, filters=None):
LOG.debug(_("get_firewalls_count() called")) LOG.debug("get_firewalls_count() called")
return self._get_collection_count(context, Firewall, return self._get_collection_count(context, Firewall,
filters=filters) filters=filters)
def create_firewall_policy(self, context, firewall_policy): def create_firewall_policy(self, context, firewall_policy):
LOG.debug(_("create_firewall_policy() called")) LOG.debug("create_firewall_policy() called")
fwp = firewall_policy['firewall_policy'] fwp = firewall_policy['firewall_policy']
tenant_id = self._get_tenant_id_for_create(context, fwp) tenant_id = self._get_tenant_id_for_create(context, fwp)
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
@ -334,7 +334,7 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
return self._make_firewall_policy_dict(fwp_db) return self._make_firewall_policy_dict(fwp_db)
def update_firewall_policy(self, context, id, firewall_policy): def update_firewall_policy(self, context, id, firewall_policy):
LOG.debug(_("update_firewall_policy() called")) LOG.debug("update_firewall_policy() called")
fwp = firewall_policy['firewall_policy'] fwp = firewall_policy['firewall_policy']
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
fwp_db = self._get_firewall_policy(context, id) fwp_db = self._get_firewall_policy(context, id)
@ -356,7 +356,7 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
return self._make_firewall_policy_dict(fwp_db) return self._make_firewall_policy_dict(fwp_db)
def delete_firewall_policy(self, context, id): def delete_firewall_policy(self, context, id):
LOG.debug(_("delete_firewall_policy() called")) LOG.debug("delete_firewall_policy() called")
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
fwp = self._get_firewall_policy(context, id) fwp = self._get_firewall_policy(context, id)
# Ensure that the firewall_policy is not # Ensure that the firewall_policy is not
@ -368,23 +368,23 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
context.session.delete(fwp) context.session.delete(fwp)
def get_firewall_policy(self, context, id, fields=None): def get_firewall_policy(self, context, id, fields=None):
LOG.debug(_("get_firewall_policy() called")) LOG.debug("get_firewall_policy() called")
fwp = self._get_firewall_policy(context, id) fwp = self._get_firewall_policy(context, id)
return self._make_firewall_policy_dict(fwp, fields) return self._make_firewall_policy_dict(fwp, fields)
def get_firewall_policies(self, context, filters=None, fields=None): def get_firewall_policies(self, context, filters=None, fields=None):
LOG.debug(_("get_firewall_policies() called")) LOG.debug("get_firewall_policies() called")
return self._get_collection(context, FirewallPolicy, return self._get_collection(context, FirewallPolicy,
self._make_firewall_policy_dict, self._make_firewall_policy_dict,
filters=filters, fields=fields) filters=filters, fields=fields)
def get_firewalls_policies_count(self, context, filters=None): def get_firewalls_policies_count(self, context, filters=None):
LOG.debug(_("get_firewall_policies_count() called")) LOG.debug("get_firewall_policies_count() called")
return self._get_collection_count(context, FirewallPolicy, return self._get_collection_count(context, FirewallPolicy,
filters=filters) filters=filters)
def create_firewall_rule(self, context, firewall_rule): def create_firewall_rule(self, context, firewall_rule):
LOG.debug(_("create_firewall_rule() called")) LOG.debug("create_firewall_rule() called")
fwr = firewall_rule['firewall_rule'] fwr = firewall_rule['firewall_rule']
self._validate_fwr_protocol_parameters(fwr) self._validate_fwr_protocol_parameters(fwr)
tenant_id = self._get_tenant_id_for_create(context, fwr) tenant_id = self._get_tenant_id_for_create(context, fwr)
@ -416,7 +416,7 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
return self._make_firewall_rule_dict(fwr_db) return self._make_firewall_rule_dict(fwr_db)
def update_firewall_rule(self, context, id, firewall_rule): def update_firewall_rule(self, context, id, firewall_rule):
LOG.debug(_("update_firewall_rule() called")) LOG.debug("update_firewall_rule() called")
fwr = firewall_rule['firewall_rule'] fwr = firewall_rule['firewall_rule']
fwr_db = self._get_firewall_rule(context, id) fwr_db = self._get_firewall_rule(context, id)
if fwr_db.firewall_policy_id: if fwr_db.firewall_policy_id:
@ -452,7 +452,7 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
return self._make_firewall_rule_dict(fwr_db) return self._make_firewall_rule_dict(fwr_db)
def delete_firewall_rule(self, context, id): def delete_firewall_rule(self, context, id):
LOG.debug(_("delete_firewall_rule() called")) LOG.debug("delete_firewall_rule() called")
with context.session.begin(subtransactions=True): with context.session.begin(subtransactions=True):
fwr = self._get_firewall_rule(context, id) fwr = self._get_firewall_rule(context, id)
if fwr.firewall_policy_id: if fwr.firewall_policy_id:
@ -460,18 +460,18 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
context.session.delete(fwr) context.session.delete(fwr)
def get_firewall_rule(self, context, id, fields=None): def get_firewall_rule(self, context, id, fields=None):
LOG.debug(_("get_firewall_rule() called")) LOG.debug("get_firewall_rule() called")
fwr = self._get_firewall_rule(context, id) fwr = self._get_firewall_rule(context, id)
return self._make_firewall_rule_dict(fwr, fields) return self._make_firewall_rule_dict(fwr, fields)
def get_firewall_rules(self, context, filters=None, fields=None): def get_firewall_rules(self, context, filters=None, fields=None):
LOG.debug(_("get_firewall_rules() called")) LOG.debug("get_firewall_rules() called")
return self._get_collection(context, FirewallRule, return self._get_collection(context, FirewallRule,
self._make_firewall_rule_dict, self._make_firewall_rule_dict,
filters=filters, fields=fields) filters=filters, fields=fields)
def get_firewalls_rules_count(self, context, filters=None): def get_firewalls_rules_count(self, context, filters=None):
LOG.debug(_("get_firewall_rules_count() called")) LOG.debug("get_firewall_rules_count() called")
return self._get_collection_count(context, FirewallRule, return self._get_collection_count(context, FirewallRule,
filters=filters) filters=filters)
@ -480,7 +480,7 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
raise firewall.FirewallRuleInfoMissing() raise firewall.FirewallRuleInfoMissing()
def insert_rule(self, context, id, rule_info): def insert_rule(self, context, id, rule_info):
LOG.debug(_("insert_rule() called")) LOG.debug("insert_rule() called")
self._validate_insert_remove_rule_request(id, rule_info) self._validate_insert_remove_rule_request(id, rule_info)
firewall_rule_id = rule_info['firewall_rule_id'] firewall_rule_id = rule_info['firewall_rule_id']
insert_before = True insert_before = True
@ -526,7 +526,7 @@ class Firewall_db_mixin(firewall.FirewallPluginBase, base_db.CommonDbMixin):
position) position)
def remove_rule(self, context, id, rule_info): def remove_rule(self, context, id, rule_info):
LOG.debug(_("remove_rule() called")) LOG.debug("remove_rule() called")
self._validate_insert_remove_rule_request(id, rule_info) self._validate_insert_remove_rule_request(id, rule_info)
firewall_rule_id = rule_info['firewall_rule_id'] firewall_rule_id = rule_info['firewall_rule_id']
if not firewall_rule_id: if not firewall_rule_id:

View File

@ -29,6 +29,7 @@ from neutron.db import models_v2
from neutron.extensions import external_net from neutron.extensions import external_net
from neutron.extensions import l3 from neutron.extensions import l3
from neutron import manager from neutron import manager
from neutron.openstack.common.gettextutils import _LI
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.openstack.common import uuidutils from neutron.openstack.common import uuidutils
from neutron.plugins.common import constants from neutron.plugins.common import constants
@ -903,8 +904,8 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase):
raise l3.L3PortInUse(port_id=port_id, raise l3.L3PortInUse(port_id=port_id,
device_owner=port_db['device_owner']) device_owner=port_db['device_owner'])
else: else:
LOG.debug(_("Port %(port_id)s has owner %(port_owner)s, but " LOG.debug("Port %(port_id)s has owner %(port_owner)s, but "
"no IP address, so it can be deleted"), "no IP address, so it can be deleted",
{'port_id': port_db['id'], {'port_id': port_db['id'],
'port_owner': port_db['device_owner']}) 'port_owner': port_db['device_owner']})
@ -1018,13 +1019,14 @@ class L3_NAT_dbonly_mixin(l3.RouterPluginBase):
for port in ports: for port in ports:
fixed_ips = port.get('fixed_ips', []) fixed_ips = port.get('fixed_ips', [])
if len(fixed_ips) > 1: if len(fixed_ips) > 1:
LOG.info(_("Ignoring multiple IPs on router port %s"), LOG.info(_LI("Ignoring multiple IPs on router port %s"),
port['id']) port['id'])
continue continue
elif not fixed_ips: elif not fixed_ips:
# Skip ports without IPs, which can occur if a subnet # Skip ports without IPs, which can occur if a subnet
# attached to a router is deleted # attached to a router is deleted
LOG.info(_("Skipping port %s as no IP is configure on it"), LOG.info(_LI("Skipping port %s as no IP is configure on "
"it"),
port['id']) port['id'])
continue continue
yield (port, fixed_ips[0]) yield (port, fixed_ips[0])

View File

@ -24,6 +24,7 @@ from neutron.db import l3_dvrscheduler_db as l3_dvrsched_db
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.extensions import l3 from neutron.extensions import l3
from neutron.extensions import portbindings from neutron.extensions import portbindings
from neutron.openstack.common.gettextutils import _LI
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
@ -73,8 +74,8 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
"""Allow centralized -> distributed state transition only.""" """Allow centralized -> distributed state transition only."""
if (router_db.extra_attributes.distributed and if (router_db.extra_attributes.distributed and
router_res.get('distributed') is False): router_res.get('distributed') is False):
LOG.info(_("Centralizing distributed router %s " LOG.info(_LI("Centralizing distributed router %s "
"is not supported"), router_db['id']) "is not supported"), router_db['id'])
raise NotImplementedError() raise NotImplementedError()
def _update_distributed_attr( def _update_distributed_attr(
@ -438,8 +439,8 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
f_port = self.get_agent_gw_ports_exist_for_network( f_port = self.get_agent_gw_ports_exist_for_network(
context, network_id, host, l3_agent_db['id']) context, network_id, host, l3_agent_db['id'])
if not f_port: if not f_port:
LOG.info(_('Agent Gateway port does not exist,' LOG.info(_LI('Agent Gateway port does not exist,'
' so create one: %s'), f_port) ' so create one: %s'), f_port)
agent_port = self._core_plugin.create_port( agent_port = self._core_plugin.create_port(
context, context,
{'port': {'tenant_id': '', {'port': {'tenant_id': '',
@ -521,8 +522,8 @@ class L3_NAT_with_dvr_db_mixin(l3_db.L3_NAT_db_mixin,
port_type=DEVICE_OWNER_DVR_INTERFACE port_type=DEVICE_OWNER_DVR_INTERFACE
) )
) )
LOG.info(_('SNAT interface port list does not exist,' LOG.info(_LI('SNAT interface port list does not exist,'
' so create one: %s'), port_list) ' so create one: %s'), port_list)
for intf in int_ports: for intf in int_ports:
if intf.fixed_ips: if intf.fixed_ips:
# Passing the subnet for the port to make sure the IP's # Passing the subnet for the port to make sure the IP's

View File

@ -26,6 +26,7 @@ from neutron.db import agents_db
from neutron.db import l3_agentschedulers_db as l3agent_sch_db from neutron.db import l3_agentschedulers_db as l3agent_sch_db
from neutron.db import model_base from neutron.db import model_base
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.openstack.common.gettextutils import _LW
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.ml2 import db as ml2_db from neutron.plugins.ml2 import db as ml2_db
@ -293,7 +294,7 @@ class L3_DVRsch_db_mixin(l3agent_sch_db.L3AgentSchedulerDbMixin):
"""Schedule the snat router on l3 service agent.""" """Schedule the snat router on l3 service agent."""
active_l3_agents = self.get_l3_agents(context, active=True) active_l3_agents = self.get_l3_agents(context, active=True)
if not active_l3_agents: if not active_l3_agents:
LOG.warn(_('No active L3 agents found for SNAT')) LOG.warn(_LW('No active L3 agents found for SNAT'))
return return
snat_candidates = self.get_snat_candidates(sync_router, snat_candidates = self.get_snat_candidates(sync_router,
active_l3_agents) active_l3_agents)

View File

@ -15,6 +15,7 @@
from neutron.common import constants as consts from neutron.common import constants as consts
from neutron.common import utils from neutron.common import utils
from neutron import manager from neutron import manager
from neutron.openstack.common.gettextutils import _LE
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
from neutron.plugins.common import constants as service_constants from neutron.plugins.common import constants as service_constants
@ -41,7 +42,7 @@ class MeteringRpcCallbacks(object):
else: else:
agents = l3_plugin.get_l3_agents(context, filters={'host': [host]}) agents = l3_plugin.get_l3_agents(context, filters={'host': [host]})
if not agents: if not agents:
LOG.error(_('Unable to find agent %s.'), host) LOG.error(_LE('Unable to find agent %s.'), host)
return return
routers = l3_plugin.list_routers_on_l3_agent(context, agents[0].id) routers = l3_plugin.list_routers_on_l3_agent(context, agents[0].id)

View File

@ -27,6 +27,7 @@ from sqlalchemy.sql import text
from sqlalchemy import types from sqlalchemy import types
from neutron.db.migration.models import frozen as frozen_models from neutron.db.migration.models import frozen as frozen_models
from neutron.openstack.common.gettextutils import _LI
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -225,13 +226,15 @@ def check_foreign_keys(metadata):
fk_models_set = set(fk_models.keys()) fk_models_set = set(fk_models.keys())
for key in (fk_db_set - fk_models_set): for key in (fk_db_set - fk_models_set):
dropped_fks.append(('drop_key', fk_db[key], table)) dropped_fks.append(('drop_key', fk_db[key], table))
LOG.info(_("Detected removed foreign key %(fk)r on " LOG.info(_LI("Detected removed foreign key %(fk)r on "
"table %(table)r"), {'fk': fk_db[key], 'table': table}) "table %(table)r"),
{'fk': fk_db[key], 'table': table})
for key in (fk_models_set - fk_db_set): for key in (fk_models_set - fk_db_set):
added_fks.append(('add_key', fk_models[key])) added_fks.append(('add_key', fk_models[key]))
LOG.info(_("Detected added foreign key for column %(fk)r on table " LOG.info(_LI("Detected added foreign key for column %(fk)r on "
"%(table)r"), {'fk': fk_models[key].column.name, "table %(table)r"),
'table': table}) {'fk': fk_models[key].column.name,
'table': table})
return (added_fks, dropped_fks) return (added_fks, dropped_fks)
@ -250,7 +253,7 @@ def rename(table):
if table in frozen_models.renamed_tables: if table in frozen_models.renamed_tables:
if check_if_table_exists(frozen_models.renamed_tables[table]): if check_if_table_exists(frozen_models.renamed_tables[table]):
op.rename_table(frozen_models.renamed_tables[table], table) op.rename_table(frozen_models.renamed_tables[table], table)
LOG.info(_("Table %(old_t)r was renamed to %(new_t)r"), { LOG.info(_LI("Table %(old_t)r was renamed to %(new_t)r"), {
'old_t': table, 'new_t': frozen_models.renamed_tables[table]}) 'old_t': table, 'new_t': frozen_models.renamed_tables[table]})
return True return True
return False return False

View File

@ -23,6 +23,7 @@ from neutron.db import allowedaddresspairs_db as addr_pair
from neutron.db import models_v2 from neutron.db import models_v2
from neutron.db import securitygroups_db as sg_db from neutron.db import securitygroups_db as sg_db
from neutron.extensions import securitygroup as ext_sg from neutron.extensions import securitygroup as ext_sg
from neutron.openstack.common.gettextutils import _LW
from neutron.openstack.common import log as logging from neutron.openstack.common import log as logging
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
@ -355,8 +356,8 @@ class SecurityGroupServerRpcMixin(sg_db.SecurityGroupDbMixin):
try: try:
mac_address = query.one()[0] mac_address = query.one()[0]
except (exc.NoResultFound, exc.MultipleResultsFound): except (exc.NoResultFound, exc.MultipleResultsFound):
LOG.warn(_('No valid gateway port on subnet %s is ' LOG.warn(_LW('No valid gateway port on subnet %s is '
'found for IPv6 RA'), subnet['id']) 'found for IPv6 RA'), subnet['id'])
return return
lla_ip = str(ipv6.get_ipv6_addr_by_EUI64( lla_ip = str(ipv6.get_ipv6_addr_by_EUI64(
q_const.IPV6_LLA_PREFIX, q_const.IPV6_LLA_PREFIX,

View File

@ -45,7 +45,8 @@ def _directory_to_check_translation(filename):
# do it on a directory by directory basis. The last patch of the # 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. # series will remove this and the entire code base will be validated.
dirs = ["neutron/agent", dirs = ["neutron/agent",
"neutron/cmd"] "neutron/cmd",
"neutron/db"]
return any([dir in filename for dir in dirs]) return any([dir in filename for dir in dirs])