Replacement _ on _LW in all LOG.warning part 2

oslo.i18n uses different marker functions to separate the
translatable messages into different catalogs, which the translation
teams can prioritize translating. For details, please refer to:
http://docs.openstack.org/developer/oslo.i18n/guidelines.html#guidelines-for-use-in-openstack

There were not marker fuctions some places in directory network.
This commit makes changes:
* Add missing marker functions
* Use ',' instead of '%' while adding variables to log messages

Change-Id: I5ab13610d3e10a68ae49f9fd7fac151aa66ea98d
This commit is contained in:
Mike Durnosvistov
2014-11-19 17:55:18 +02:00
parent e8c0b822f0
commit b4ee0d16ae
20 changed files with 154 additions and 146 deletions

View File

@@ -70,7 +70,7 @@ def pipeline_factory(loader, global_conf, **local_conf):
# If the configuration file still contains 'ratelimit_v3', just ignore it. # If the configuration file still contains 'ratelimit_v3', just ignore it.
# We will remove this code at next release (J) # We will remove this code at next release (J)
if 'ratelimit_v3' in pipeline: if 'ratelimit_v3' in pipeline:
LOG.warn(_LW('ratelimit_v3 is removed from v3 api.')) LOG.warning(_LW('ratelimit_v3 is removed from v3 api.'))
pipeline.remove('ratelimit_v3') pipeline.remove('ratelimit_v3')
return _load_pipeline(loader, pipeline) return _load_pipeline(loader, pipeline)
@@ -161,6 +161,6 @@ class NovaKeystoneContext(wsgi.Middleware):
# Fallback to deprecated role header: # Fallback to deprecated role header:
roles = req.headers.get('X_ROLE', '') roles = req.headers.get('X_ROLE', '')
if roles: if roles:
LOG.warn(_LW("Sourcing roles from deprecated X-Role HTTP " LOG.warning(_LW("Sourcing roles from deprecated X-Role HTTP "
"header")) "header"))
return [r.strip() for r in roles.split(',')] return [r.strip() for r in roles.split(',')]

View File

@@ -87,7 +87,7 @@ class FaultWrapper(wsgi.Middleware):
try: try:
return req.get_response(self.application) return req.get_response(self.application)
except Exception as ex: except Exception as ex:
LOG.exception(_("FaultWrapper: %s"), ex) LOG.exception(_LE("FaultWrapper: %s"), ex)
return faults.Fault(webob.exc.HTTPInternalServerError()) return faults.Fault(webob.exc.HTTPInternalServerError())
@@ -167,12 +167,13 @@ class Lockout(wsgi.Middleware):
# NOTE(vish): To use incr, failures has to be a string. # NOTE(vish): To use incr, failures has to be a string.
self.mc.set(failures_key, '1', time=CONF.lockout_window * 60) self.mc.set(failures_key, '1', time=CONF.lockout_window * 60)
elif failures >= CONF.lockout_attempts: elif failures >= CONF.lockout_attempts:
LOG.warn(_LW('Access key %(access_key)s has had %(failures)d ' LOG.warning(_LW('Access key %(access_key)s has had '
'failed authentications and will be locked out ' '%(failures)d failed authentications and '
'for %(lock_mins)d minutes.'), 'will be locked out for %(lock_mins)d '
{'access_key': access_key, 'minutes.'),
'failures': failures, {'access_key': access_key,
'lock_mins': CONF.lockout_minutes}) 'failures': failures,
'lock_mins': CONF.lockout_minutes})
self.mc.set(failures_key, str(failures), self.mc.set(failures_key, str(failures),
time=CONF.lockout_minutes * 60) time=CONF.lockout_minutes * 60)
return res return res

View File

@@ -1308,8 +1308,8 @@ class CloudController(object):
# changed to support specifying a particular fixed_ip if # changed to support specifying a particular fixed_ip if
# multiple exist but this may not apply to ec2.. # multiple exist but this may not apply to ec2..
if len(fixed_ips) > 1: if len(fixed_ips) > 1:
LOG.warn(_LW('multiple fixed_ips exist, using the first: %s'), LOG.warning(_LW('multiple fixed_ips exist, using the first: %s'),
fixed_ips[0]) fixed_ips[0])
self.network_api.associate_floating_ip(context, instance, self.network_api.associate_floating_ip(context, instance,
floating_address=public_ip, floating_address=public_ip,

View File

@@ -110,7 +110,7 @@ class MetadataRequestHandler(wsgi.Application):
meta_data = self._handle_instance_id_request(req) meta_data = self._handle_instance_id_request(req)
else: else:
if req.headers.get('X-Instance-ID'): if req.headers.get('X-Instance-ID'):
LOG.warn( LOG.warning(
_LW("X-Instance-ID present in request headers. The " _LW("X-Instance-ID present in request headers. The "
"'service_metadata_proxy' option must be " "'service_metadata_proxy' option must be "
"enabled to process this header.")) "enabled to process this header."))
@@ -144,7 +144,7 @@ class MetadataRequestHandler(wsgi.Application):
try: try:
meta_data = self.get_metadata_by_remote_address(remote_address) meta_data = self.get_metadata_by_remote_address(remote_address)
except Exception: except Exception:
LOG.exception(_('Failed to get metadata for ip: %s'), LOG.exception(_LE('Failed to get metadata for ip: %s'),
remote_address) remote_address)
msg = _('An unknown error has occurred. ' msg = _('An unknown error has occurred. '
'Please try your request again.') 'Please try your request again.')
@@ -186,14 +186,15 @@ class MetadataRequestHandler(wsgi.Application):
if not utils.constant_time_compare(expected_signature, signature): if not utils.constant_time_compare(expected_signature, signature):
if instance_id: if instance_id:
LOG.warn(_LW('X-Instance-ID-Signature: %(signature)s does ' LOG.warning(_LW('X-Instance-ID-Signature: %(signature)s does '
'not match the expected value: ' 'not match the expected value: '
'%(expected_signature)s for id: %(instance_id)s.' '%(expected_signature)s for id: '
' Request From: %(remote_address)s'), '%(instance_id)s. Request From: '
{'signature': signature, '%(remote_address)s'),
'expected_signature': expected_signature, {'signature': signature,
'instance_id': instance_id, 'expected_signature': expected_signature,
'remote_address': remote_address}) 'instance_id': instance_id,
'remote_address': remote_address})
msg = _('Invalid proxy request signature.') msg = _('Invalid proxy request signature.')
raise webob.exc.HTTPForbidden(explanation=msg) raise webob.exc.HTTPForbidden(explanation=msg)
@@ -202,7 +203,7 @@ class MetadataRequestHandler(wsgi.Application):
meta_data = self.get_metadata_by_instance_id(instance_id, meta_data = self.get_metadata_by_instance_id(instance_id,
remote_address) remote_address)
except Exception: except Exception:
LOG.exception(_('Failed to get metadata for instance id: %s'), LOG.exception(_LE('Failed to get metadata for instance id: %s'),
instance_id) instance_id)
msg = _('An unknown error has occurred. ' msg = _('An unknown error has occurred. '
'Please try your request again.') 'Please try your request again.')
@@ -213,9 +214,9 @@ class MetadataRequestHandler(wsgi.Application):
LOG.error(_LE('Failed to get metadata for instance id: %s'), LOG.error(_LE('Failed to get metadata for instance id: %s'),
instance_id) instance_id)
elif meta_data.instance['project_id'] != tenant_id: elif meta_data.instance['project_id'] != tenant_id:
LOG.warn(_LW("Tenant_id %(tenant_id)s does not match tenant_id " LOG.warning(_LW("Tenant_id %(tenant_id)s does not match tenant_id "
"of instance %(instance_id)s."), "of instance %(instance_id)s."),
{'tenant_id': tenant_id, 'instance_id': instance_id}) {'tenant_id': tenant_id, 'instance_id': instance_id})
# causes a 404 to be raised # causes a 404 to be raised
meta_data = None meta_data = None

View File

@@ -44,15 +44,15 @@ class JsonFileVendorData(base.VendorDataDriver):
data = jsonutils.load(fp) data = jsonutils.load(fp)
except IOError as e: except IOError as e:
if e.errno == errno.ENOENT: if e.errno == errno.ENOENT:
LOG.warn(_LW("%(logprefix)sfile does not exist"), LOG.warning(_LW("%(logprefix)sfile does not exist"),
{'logprefix': logprefix}) {'logprefix': logprefix})
else: else:
LOG.warn(_LW("%(logprefix)unexpected IOError when " LOG.warning(_LW("%(logprefix)unexpected IOError when "
"reading"), {'logprefix': logprefix}) "reading"), {'logprefix': logprefix})
raise e raise e
except ValueError: except ValueError:
LOG.warn(_LW("%(logprefix)sfailed to load json"), LOG.warning(_LW("%(logprefix)sfailed to load json"),
{'logprefix': logprefix}) {'logprefix': logprefix})
raise raise
self._data = data self._data = data

View File

@@ -29,6 +29,7 @@ from nova.api.openstack import wsgi
from nova import exception from nova import exception
from nova.i18n import _ from nova.i18n import _
from nova.i18n import _LC from nova.i18n import _LC
from nova.i18n import _LE
from nova.i18n import _LI from nova.i18n import _LI
from nova.i18n import _LW from nova.i18n import _LW
from nova.i18n import translate from nova.i18n import translate
@@ -89,7 +90,7 @@ class FaultWrapper(base_wsgi.Middleware):
status, webob.exc.HTTPInternalServerError)() status, webob.exc.HTTPInternalServerError)()
def _error(self, inner, req): def _error(self, inner, req):
LOG.exception(_("Caught error: %s"), unicode(inner)) LOG.exception(_LE("Caught error: %s"), unicode(inner))
safe = getattr(inner, 'safe', False) safe = getattr(inner, 'safe', False)
headers = getattr(inner, 'headers', None) headers = getattr(inner, 'headers', None)
@@ -232,9 +233,9 @@ class APIRouter(base_wsgi.Router):
msg_format_dict = {'collection': collection, msg_format_dict = {'collection': collection,
'ext_name': extension.extension.name} 'ext_name': extension.extension.name}
if collection not in self.resources: if collection not in self.resources:
LOG.warn(_LW('Extension %(ext_name)s: Cannot extend ' LOG.warning(_LW('Extension %(ext_name)s: Cannot extend '
'resource %(collection)s: No such resource'), 'resource %(collection)s: No such resource'),
msg_format_dict) msg_format_dict)
continue continue
LOG.debug('Extension %(ext_name)s extended resource: ' LOG.debug('Extension %(ext_name)s extended resource: '
@@ -283,11 +284,11 @@ class APIRouterV21(base_wsgi.Router):
if ext.obj.alias not in CONF.osapi_v3.extensions_blacklist: if ext.obj.alias not in CONF.osapi_v3.extensions_blacklist:
return self._register_extension(ext) return self._register_extension(ext)
else: else:
LOG.warn(_LW("Not loading %s because it is " LOG.warning(_LW("Not loading %s because it is "
"in the blacklist"), ext.obj.alias) "in the blacklist"), ext.obj.alias)
return False return False
else: else:
LOG.warn( LOG.warning(
_LW("Not loading %s because it is not in the " _LW("Not loading %s because it is not in the "
"whitelist"), ext.obj.alias) "whitelist"), ext.obj.alias)
return False return False
@@ -308,8 +309,8 @@ class APIRouterV21(base_wsgi.Router):
CONF.osapi_v3.extensions_whitelist).intersection( CONF.osapi_v3.extensions_whitelist).intersection(
CONF.osapi_v3.extensions_blacklist) CONF.osapi_v3.extensions_blacklist)
if len(in_blacklist_and_whitelist) != 0: if len(in_blacklist_and_whitelist) != 0:
LOG.warn(_LW("Extensions in both blacklist and whitelist: %s"), LOG.warning(_LW("Extensions in both blacklist and whitelist: %s"),
list(in_blacklist_and_whitelist)) list(in_blacklist_and_whitelist))
self.api_extension_manager = stevedore.enabled.EnabledExtensionManager( self.api_extension_manager = stevedore.enabled.EnabledExtensionManager(
namespace=self.API_EXTENSION_NAMESPACE, namespace=self.API_EXTENSION_NAMESPACE,
@@ -414,9 +415,9 @@ class APIRouterV21(base_wsgi.Router):
controller = extension.controller controller = extension.controller
if collection not in self.resources: if collection not in self.resources:
LOG.warn(_LW('Extension %(ext_name)s: Cannot extend ' LOG.warning(_LW('Extension %(ext_name)s: Cannot extend '
'resource %(collection)s: No such resource'), 'resource %(collection)s: No such resource'),
{'ext_name': ext_name, 'collection': collection}) {'ext_name': ext_name, 'collection': collection})
continue continue
LOG.debug('Extension %(ext_name)s extending resource: ' LOG.debug('Extension %(ext_name)s extending resource: '

View File

@@ -495,8 +495,8 @@ def check_snapshots_enabled(f):
@functools.wraps(f) @functools.wraps(f)
def inner(*args, **kwargs): def inner(*args, **kwargs):
if not CONF.allow_instance_snapshots: if not CONF.allow_instance_snapshots:
LOG.warn(_LW('Rejecting snapshot request, snapshots currently' LOG.warning(_LW('Rejecting snapshot request, snapshots currently'
' disabled')) ' disabled'))
msg = _("Instance snapshots are not permitted at this time.") msg = _("Instance snapshots are not permitted at this time.")
raise webob.exc.HTTPBadRequest(explanation=msg) raise webob.exc.HTTPBadRequest(explanation=msg)
return f(*args, **kwargs) return f(*args, **kwargs)

View File

@@ -231,8 +231,8 @@ class FloatingIPActionController(wsgi.Controller):
if not fixed_address: if not fixed_address:
fixed_address = fixed_ips[0]['address'] fixed_address = fixed_ips[0]['address']
if len(fixed_ips) > 1: if len(fixed_ips) > 1:
LOG.warn(_LW('multiple fixed_ips exist, using the first: ' LOG.warning(_LW('multiple fixed_ips exist, using the first: '
'%s'), fixed_address) '%s'), fixed_address)
try: try:
self.network_api.associate_floating_ip(context, instance, self.network_api.associate_floating_ip(context, instance,

View File

@@ -106,11 +106,11 @@ class ServersController(wsgi.Controller):
if ext.obj.alias not in CONF.osapi_v3.extensions_blacklist: if ext.obj.alias not in CONF.osapi_v3.extensions_blacklist:
return True return True
else: else:
LOG.warn(_LW("Not loading %s because it is " LOG.warning(_LW("Not loading %s because it is "
"in the blacklist"), ext.obj.alias) "in the blacklist"), ext.obj.alias)
return False return False
else: else:
LOG.warn( LOG.warning(
_LW("Not loading %s because it is not in the " _LW("Not loading %s because it is not in the "
"whitelist"), ext.obj.alias) "whitelist"), ext.obj.alias)
return False return False

View File

@@ -79,8 +79,8 @@ def make_server(elem, detailed=False):
global XML_WARNING global XML_WARNING
if not XML_WARNING: if not XML_WARNING:
LOG.warn(_LW('XML support has been deprecated and may be removed ' LOG.warning(_LW('XML support has been deprecated and may be removed '
'as early as the Juno release.')) 'as early as the Juno release.'))
XML_WARNING = True XML_WARNING = True
if detailed: if detailed:

View File

@@ -195,8 +195,8 @@ class ViewBuilder(common.ViewBuilder):
def _get_flavor(self, request, instance): def _get_flavor(self, request, instance):
instance_type = flavors.extract_flavor(instance) instance_type = flavors.extract_flavor(instance)
if not instance_type: if not instance_type:
LOG.warn(_LW("Instance has had its instance_type removed " LOG.warning(_LW("Instance has had its instance_type removed "
"from the DB"), instance=instance) "from the DB"), instance=instance)
return {} return {}
flavor_id = instance_type["flavorid"] flavor_id = instance_type["flavorid"]
flavor_bookmark = self._flavor_builder._get_bookmark_link(request, flavor_bookmark = self._flavor_builder._get_bookmark_link(request,

View File

@@ -28,6 +28,7 @@ from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil from nova.api.openstack import xmlutil
from nova import exception from nova import exception
from nova.i18n import _ from nova.i18n import _
from nova.i18n import _LE
from nova.i18n import _LW from nova.i18n import _LW
from nova.openstack.common import log as logging from nova.openstack.common import log as logging
import nova.policy import nova.policy
@@ -239,7 +240,7 @@ class ExtensionManager(object):
LOG.debug('Ext namespace: %s', extension.namespace) LOG.debug('Ext namespace: %s', extension.namespace)
LOG.debug('Ext updated: %s', extension.updated) LOG.debug('Ext updated: %s', extension.updated)
except AttributeError as ex: except AttributeError as ex:
LOG.exception(_("Exception loading extension: %s"), ex) LOG.exception(_LE("Exception loading extension: %s"), ex)
return False return False
return True return True
@@ -274,9 +275,9 @@ class ExtensionManager(object):
try: try:
self.load_extension(ext_factory) self.load_extension(ext_factory)
except Exception as exc: except Exception as exc:
LOG.warn(_LW('Failed to load extension %(ext_factory)s: ' LOG.warning(_LW('Failed to load extension %(ext_factory)s: '
'%(exc)s'), '%(exc)s'),
{'ext_factory': ext_factory, 'exc': exc}) {'ext_factory': ext_factory, 'exc': exc})
class ControllerExtension(object): class ControllerExtension(object):
@@ -498,7 +499,7 @@ def expected_errors(errors):
# expected error. # expected error.
raise raise
LOG.exception(_("Unexpected exception in API method")) LOG.exception(_LE("Unexpected exception in API method"))
msg = _('Unexpected API Error. Please report this at ' msg = _('Unexpected API Error. Please report this at '
'http://bugs.launchpad.net/nova/ and attach the Nova ' 'http://bugs.launchpad.net/nova/ and attach the Nova '
'API log if possible.\n%s') % type(exc) 'API log if possible.\n%s') % type(exc)

View File

@@ -303,11 +303,9 @@ def validate_log_translations(logical_line, physical_line, filename):
# and the Xen utilities # and the Xen utilities
if ("nova/tests" in filename or if ("nova/tests" in filename or
"plugins/xenserver/xenapi/etc/xapi.d" in filename or "plugins/xenserver/xenapi/etc/xapi.d" in filename or
"nova/compute" in filename or
# TODO(Mike_D):Needs to be remove with: # TODO(Mike_D):Needs to be remove with:
# I075ab2a522272f2082c292dfedc877abd8ebe328 # I075ab2a522272f2082c292dfedc877abd8ebe328
"nova/api" in filename or
"nova/compute" in filename or
"nova/network" in filename or
"nova/virt" in filename): "nova/virt" in filename):
return return
if pep8.noqa(physical_line): if pep8.noqa(physical_line):

View File

@@ -25,7 +25,7 @@ import six
from nova import context from nova import context
from nova.db import base from nova.db import base
from nova import exception from nova import exception
from nova.i18n import _, _LE, _LI from nova.i18n import _LE, _LI, _LW
from nova.network import rpcapi as network_rpcapi from nova.network import rpcapi as network_rpcapi
from nova import objects from nova import objects
from nova.openstack.common import log as logging from nova.openstack.common import log as logging
@@ -192,14 +192,14 @@ class FloatingIP(object):
if floating_ip.project_id != context.project_id: if floating_ip.project_id != context.project_id:
if floating_ip.project_id is None: if floating_ip.project_id is None:
LOG.warn(_('Address |%(address)s| is not allocated'), LOG.warning(_LW('Address |%(address)s| is not allocated'),
{'address': floating_ip.address}) {'address': floating_ip.address})
raise exception.Forbidden() raise exception.Forbidden()
else: else:
LOG.warn(_('Address |%(address)s| is not allocated to your ' LOG.warning(_LW('Address |%(address)s| is not allocated '
'project |%(project)s|'), 'to your project |%(project)s|'),
{'address': floating_ip.address, {'address': floating_ip.address,
'project': context.project_id}) 'project': context.project_id})
raise exception.Forbidden() raise exception.Forbidden()
def allocate_floating_ip(self, context, project_id, auto_assigned=False, def allocate_floating_ip(self, context, project_id, auto_assigned=False,
@@ -216,8 +216,8 @@ class FloatingIP(object):
reservations = QUOTAS.reserve(context, floating_ips=1, reservations = QUOTAS.reserve(context, floating_ips=1,
project_id=project_id) project_id=project_id)
except exception.OverQuota: except exception.OverQuota:
LOG.warn(_("Quota exceeded for %s, tried to allocate " LOG.warning(_LW("Quota exceeded for %s, tried to allocate "
"floating IP"), context.project_id) "floating IP"), context.project_id)
raise exception.FloatingIpLimitExceeded() raise exception.FloatingIpLimitExceeded()
try: try:
@@ -373,8 +373,8 @@ class FloatingIP(object):
objects.FloatingIP.disassociate(context, objects.FloatingIP.disassociate(context,
floating_address) floating_address)
except Exception: except Exception:
LOG.warn(_('Failed to disassociated floating ' LOG.warning(_LW('Failed to disassociated floating '
'address: %s'), floating_address) 'address: %s'), floating_address)
pass pass
if "Cannot find device" in six.text_type(e): if "Cannot find device" in six.text_type(e):
try: try:
@@ -538,10 +538,11 @@ class FloatingIP(object):
floating_ip = objects.FloatingIP.get_by_address(context, address) floating_ip = objects.FloatingIP.get_by_address(context, address)
if self._is_stale_floating_ip_address(context, floating_ip): if self._is_stale_floating_ip_address(context, floating_ip):
LOG.warn(_("Floating ip address |%(address)s| no longer " LOG.warning(_LW("Floating ip address |%(address)s| no longer "
"belongs to instance %(instance_uuid)s. Will not " "belongs to instance %(instance_uuid)s. "
"migrate it "), "Will not migrate it "),
{'address': address, 'instance_uuid': instance_uuid}) {'address': address,
'instance_uuid': instance_uuid})
continue continue
interface = CONF.public_interface or floating_ip.interface interface = CONF.public_interface or floating_ip.interface
@@ -574,10 +575,11 @@ class FloatingIP(object):
floating_ip = objects.FloatingIP.get_by_address(context, address) floating_ip = objects.FloatingIP.get_by_address(context, address)
if self._is_stale_floating_ip_address(context, floating_ip): if self._is_stale_floating_ip_address(context, floating_ip):
LOG.warn(_("Floating ip address |%(address)s| no longer " LOG.warning(_LW("Floating ip address |%(address)s| no longer "
"belongs to instance %(instance_uuid)s. Will not" "belongs to instance %(instance_uuid)s. "
"setup it."), "Will not setup it."),
{'address': address, 'instance_uuid': instance_uuid}) {'address': address,
'instance_uuid': instance_uuid})
continue continue
floating_ip.host = dest floating_ip.host = dest
@@ -617,10 +619,10 @@ class FloatingIP(object):
if domain_entry: if domain_entry:
domains.append(domain_entry) domains.append(domain_entry)
else: else:
LOG.warn(_('Database inconsistency: DNS domain |%s| is ' LOG.warning(_LW('Database inconsistency: DNS domain |%s| is '
'registered in the Nova db but not visible to ' 'registered in the Nova db but not visible to '
'either the floating or instance DNS driver. It ' 'either the floating or instance DNS driver. '
'will be ignored.'), dns_domain.domain) 'It will be ignored.'), dns_domain.domain)
return domains return domains
@@ -657,18 +659,18 @@ class FloatingIP(object):
try: try:
self.instance_dns_manager.create_domain(domain) self.instance_dns_manager.create_domain(domain)
except exception.FloatingIpDNSExists: except exception.FloatingIpDNSExists:
LOG.warn(_('Domain |%(domain)s| already exists, ' LOG.warning(_LW('Domain |%(domain)s| already exists, '
'changing zone to |%(av_zone)s|.'), 'changing zone to |%(av_zone)s|.'),
{'domain': domain, 'av_zone': av_zone}) {'domain': domain, 'av_zone': av_zone})
def create_public_dns_domain(self, context, domain, project): def create_public_dns_domain(self, context, domain, project):
objects.DNSDomain.register_for_project(context, domain, project) objects.DNSDomain.register_for_project(context, domain, project)
try: try:
self.floating_dns_manager.create_domain(domain) self.floating_dns_manager.create_domain(domain)
except exception.FloatingIpDNSExists: except exception.FloatingIpDNSExists:
LOG.warn(_('Domain |%(domain)s| already exists, ' LOG.warning(_LW('Domain |%(domain)s| already exists, '
'changing project to |%(project)s|.'), 'changing project to |%(project)s|.'),
{'domain': domain, 'project': project}) {'domain': domain, 'project': project})
def delete_dns_domain(self, context, domain): def delete_dns_domain(self, context, domain):
objects.DNSDomain.delete_by_domain(context, domain) objects.DNSDomain.delete_by_domain(context, domain)

View File

@@ -23,7 +23,7 @@ import time
from oslo.config import cfg from oslo.config import cfg
from nova import exception from nova import exception
from nova.i18n import _ from nova.i18n import _, _LW
from nova.network import dns_driver from nova.network import dns_driver
from nova.openstack.common import log as logging from nova.openstack.common import log as logging
from nova import utils from nova import utils
@@ -105,9 +105,9 @@ class DNSEntry(object):
if not entry: if not entry:
return None return None
if len(entry) > 1: if len(entry) > 1:
LOG.warn(_("Found multiple matches for domain " LOG.warning(_LW("Found multiple matches for domain "
"%(domain)s.\n%(entry)s") % "%(domain)s.\n%(entry)s"),
(domain, entry)) domain, entry)
return entry[0] return entry[0]
@classmethod @classmethod
@@ -132,10 +132,10 @@ class DNSEntry(object):
if name.endswith(z): if name.endswith(z):
dequalified = name[0:name.rfind(z)] dequalified = name[0:name.rfind(z)]
else: else:
LOG.warn(_("Unable to dequalify. %(name)s is not in " LOG.warning(_LW("Unable to dequalify. %(name)s is not in "
"%(domain)s.\n") % "%(domain)s.\n"),
{'name': name, {'name': name,
'domain': self.qualified_domain}) 'domain': self.qualified_domain})
dequalified = None dequalified = None
return dequalified return dequalified
@@ -373,5 +373,6 @@ class LdapDNS(dns_driver.DNSDriver):
dEntry.delete() dEntry.delete()
def delete_dns_file(self): def delete_dns_file(self):
LOG.warn(_("This shouldn't be getting called except during testing.")) LOG.warning(_LW("This shouldn't be getting called except during "
"testing."))
pass pass

View File

@@ -32,7 +32,7 @@ from oslo.utils import timeutils
import six import six
from nova import exception from nova import exception
from nova.i18n import _, _LE from nova.i18n import _, _LE, _LW
from nova import objects from nova import objects
from nova.openstack.common import fileutils from nova.openstack.common import fileutils
from nova.openstack.common import log as logging from nova.openstack.common import log as logging
@@ -229,8 +229,8 @@ class IptablesTable(object):
chain_set = self.unwrapped_chains chain_set = self.unwrapped_chains
if name not in chain_set: if name not in chain_set:
LOG.warn(_('Attempted to remove chain %s which does not exist'), LOG.warning(_LW('Attempted to remove chain %s which does not '
name) 'exist'), name)
return return
self.dirty = True self.dirty = True
@@ -298,10 +298,10 @@ class IptablesTable(object):
self.remove_rules.append(IptablesRule(chain, rule, wrap, top)) self.remove_rules.append(IptablesRule(chain, rule, wrap, top))
self.dirty = True self.dirty = True
except ValueError: except ValueError:
LOG.warn(_('Tried to remove rule that was not there:' LOG.warning(_LW('Tried to remove rule that was not there:'
' %(chain)r %(rule)r %(wrap)r %(top)r'), ' %(chain)r %(rule)r %(wrap)r %(top)r'),
{'chain': chain, 'rule': rule, {'chain': chain, 'rule': rule,
'top': top, 'wrap': wrap}) 'top': top, 'wrap': wrap})
def remove_rules_regex(self, regex): def remove_rules_regex(self, regex):
"""Remove all rules matching regex.""" """Remove all rules matching regex."""

View File

@@ -810,21 +810,21 @@ class NetworkManager(manager.Manager):
domainref = objects.DNSDomain.get_by_domain(context, instance_domain) domainref = objects.DNSDomain.get_by_domain(context, instance_domain)
if domainref is None: if domainref is None:
LOG.warn(_('instance-dns-zone not found |%s|.'), LOG.warning(_LW('instance-dns-zone not found |%s|.'),
instance_domain, instance=instance) instance_domain, instance=instance)
return True return True
dns_zone = domainref.availability_zone dns_zone = domainref.availability_zone
instance_zone = instance.get('availability_zone') instance_zone = instance.get('availability_zone')
if dns_zone and (dns_zone != instance_zone): if dns_zone and (dns_zone != instance_zone):
LOG.warn(_('instance-dns-zone is |%(domain)s|, ' LOG.warning(_LW('instance-dns-zone is |%(domain)s|, '
'which is in availability zone |%(zone)s|. ' 'which is in availability zone |%(zone)s|. '
'Instance is in zone |%(zone2)s|. ' 'Instance is in zone |%(zone2)s|. '
'No DNS record will be created.'), 'No DNS record will be created.'),
{'domain': instance_domain, {'domain': instance_domain,
'zone': dns_zone, 'zone': dns_zone,
'zone2': instance_zone}, 'zone2': instance_zone},
instance=instance) instance=instance)
return False return False
else: else:
return True return True
@@ -860,11 +860,12 @@ class NetworkManager(manager.Manager):
headroom = exc.kwargs['headroom'] headroom = exc.kwargs['headroom']
allowed = quotas['fixed_ips'] allowed = quotas['fixed_ips']
used = allowed - headroom['fixed_ips'] used = allowed - headroom['fixed_ips']
LOG.warn(_LW("Quota exceeded for project %(pid)s, tried to " LOG.warning(_LW("Quota exceeded for project %(pid)s, tried to "
"allocate fixed IP. %(used)s of %(allowed)s are in " "allocate fixed IP. %(used)s of %(allowed)s are "
"use or are already reserved."), "in use or are already reserved."),
{'pid': quota_project, 'used': used, 'allowed': allowed}, {'pid': quota_project, 'used': used,
instance_uuid=instance_id) 'allowed': allowed},
instance_uuid=instance_id)
raise exception.FixedIpLimitExceeded() raise exception.FixedIpLimitExceeded()
try: try:
@@ -947,9 +948,9 @@ class NetworkManager(manager.Manager):
try: try:
f() f()
except Exception: except Exception:
LOG.warn(_('Error cleaning up fixed ip allocation. ' LOG.warning(_LW('Error cleaning up fixed ip '
'Manual cleanup may be required.'), 'allocation. Manual cleanup may '
exc_info=True) 'be required.'), exc_info=True)
def deallocate_fixed_ip(self, context, address, host=None, teardown=True, def deallocate_fixed_ip(self, context, address, host=None, teardown=True,
instance=None): instance=None):
@@ -1049,9 +1050,9 @@ class NetworkManager(manager.Manager):
try: try:
quotas.rollback(context) quotas.rollback(context)
except Exception: except Exception:
LOG.warn(_LW("Failed to rollback quota for " LOG.warning(_LW("Failed to rollback quota for "
"deallocate fixed ip: %s"), address, "deallocate fixed ip: %s"), address,
instance=instance) instance=instance)
# Commit the reservations # Commit the reservations
quotas.commit(context) quotas.commit(context)
@@ -1062,14 +1063,14 @@ class NetworkManager(manager.Manager):
fixed_ip = objects.FixedIP.get_by_address(context, address) fixed_ip = objects.FixedIP.get_by_address(context, address)
if fixed_ip.instance_uuid is None: if fixed_ip.instance_uuid is None:
LOG.warn(_('IP %s leased that is not associated'), address, LOG.warning(_LW('IP %s leased that is not associated'), address,
context=context) context=context)
return return
fixed_ip.leased = True fixed_ip.leased = True
fixed_ip.save() fixed_ip.save()
if not fixed_ip.allocated: if not fixed_ip.allocated:
LOG.warn(_('IP |%s| leased that isn\'t allocated'), address, LOG.warning(_LW('IP |%s| leased that isn\'t allocated'), address,
context=context) context=context)
def release_fixed_ip(self, context, address): def release_fixed_ip(self, context, address):
"""Called by dhcp-bridge when ip is released.""" """Called by dhcp-bridge when ip is released."""
@@ -1077,12 +1078,12 @@ class NetworkManager(manager.Manager):
fixed_ip = objects.FixedIP.get_by_address(context, address) fixed_ip = objects.FixedIP.get_by_address(context, address)
if fixed_ip.instance_uuid is None: if fixed_ip.instance_uuid is None:
LOG.warn(_('IP %s released that is not associated'), address, LOG.warning(_LW('IP %s released that is not associated'), address,
context=context) context=context)
return return
if not fixed_ip.leased: if not fixed_ip.leased:
LOG.warn(_('IP %s released that was not leased'), address, LOG.warning(_LW('IP %s released that was not leased'), address,
context=context) context=context)
fixed_ip.leased = False fixed_ip.leased = False
fixed_ip.save() fixed_ip.save()
if not fixed_ip.allocated: if not fixed_ip.allocated:

View File

@@ -19,7 +19,7 @@ import tempfile
from oslo.config import cfg from oslo.config import cfg
from nova import exception from nova import exception
from nova.i18n import _, _LI from nova.i18n import _, _LI, _LW
from nova.network import dns_driver from nova.network import dns_driver
from nova.openstack.common import log as logging from nova.openstack.common import log as logging
@@ -119,8 +119,8 @@ class MiniDNS(dns_driver.DNSDriver):
outfile.close() outfile.close()
shutil.move(outfile.name, self.filename) shutil.move(outfile.name, self.filename)
if not deleted: if not deleted:
LOG.warn(_('Cannot delete entry |%s|'), LOG.warning(_LW('Cannot delete entry |%s|'),
self.qualify(name, domain)) self.qualify(name, domain))
raise exception.NotFound raise exception.NotFound
def modify_address(self, name, address, domain): def modify_address(self, name, address, domain):
@@ -204,5 +204,5 @@ class MiniDNS(dns_driver.DNSDriver):
outfile.close() outfile.close()
shutil.move(outfile.name, self.filename) shutil.move(outfile.name, self.filename)
if not deleted: if not deleted:
LOG.warn(_('Cannot delete domain |%s|'), fqdomain) LOG.warning(_LW('Cannot delete domain |%s|'), fqdomain)
raise exception.NotFound raise exception.NotFound

View File

@@ -299,7 +299,7 @@ class API(base_api.NetworkAPI):
nets = self._get_available_networks(context, instance.project_id, nets = self._get_available_networks(context, instance.project_id,
net_ids, neutron=neutron) net_ids, neutron=neutron)
if not nets: if not nets:
LOG.warn(_LW("No network configured!"), instance=instance) LOG.warning(_LW("No network configured!"), instance=instance)
return network_model.NetworkInfo([]) return network_model.NetworkInfo([])
# if this function is directly called without a requested_network param # if this function is directly called without a requested_network param

View File

@@ -24,7 +24,7 @@ from webob import exc
from nova.compute import api as compute_api from nova.compute import api as compute_api
from nova import exception from nova import exception
from nova.i18n import _, _LE, _LI from nova.i18n import _, _LE, _LI, _LW
from nova.network import neutronv2 from nova.network import neutronv2
from nova.network.security_group import security_group_base from nova.network.security_group import security_group_base
from nova import objects from nova import objects
@@ -428,10 +428,12 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase):
for port in ports: for port in ports:
if not self._has_security_group_requirements(port): if not self._has_security_group_requirements(port):
LOG.warn(_("Cannot add security group %(name)s to %(instance)s" LOG.warning(_LW("Cannot add security group %(name)s to "
" since the port %(port_id)s does not meet security" "%(instance)s since the port %(port_id)s "
" requirements"), {'name': security_group_name, "does not meet security requirements"),
'instance': instance['uuid'], 'port_id': port['id']}) {'name': security_group_name,
'instance': instance['uuid'],
'port_id': port['id']})
raise exception.SecurityGroupCannotBeApplied() raise exception.SecurityGroupCannotBeApplied()
if 'security_groups' not in port: if 'security_groups' not in port:
port['security_groups'] = [] port['security_groups'] = []