diff --git a/nova/api/auth.py b/nova/api/auth.py index 4c44773057a8..feb9c4d838f6 100644 --- a/nova/api/auth.py +++ b/nova/api/auth.py @@ -70,7 +70,7 @@ def pipeline_factory(loader, global_conf, **local_conf): # If the configuration file still contains 'ratelimit_v3', just ignore it. # We will remove this code at next release (J) 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') return _load_pipeline(loader, pipeline) @@ -166,6 +166,6 @@ class NovaKeystoneContext(wsgi.Middleware): # Fallback to deprecated role header: roles = req.headers.get('X_ROLE', '') if roles: - LOG.warn(_LW("Sourcing roles from deprecated X-Role HTTP " - "header")) + LOG.warning(_LW("Sourcing roles from deprecated X-Role HTTP " + "header")) return [r.strip() for r in roles.split(',')] diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py index 962c195a2103..65b8dab227e9 100644 --- a/nova/api/ec2/__init__.py +++ b/nova/api/ec2/__init__.py @@ -87,7 +87,7 @@ class FaultWrapper(wsgi.Middleware): try: return req.get_response(self.application) except Exception as ex: - LOG.exception(_("FaultWrapper: %s"), ex) + LOG.exception(_LE("FaultWrapper: %s"), ex) 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. self.mc.set(failures_key, '1', time=CONF.lockout_window * 60) elif failures >= CONF.lockout_attempts: - LOG.warn(_LW('Access key %(access_key)s has had %(failures)d ' - 'failed authentications and will be locked out ' - 'for %(lock_mins)d minutes.'), - {'access_key': access_key, - 'failures': failures, - 'lock_mins': CONF.lockout_minutes}) + LOG.warning(_LW('Access key %(access_key)s has had ' + '%(failures)d failed authentications and ' + 'will be locked out for %(lock_mins)d ' + 'minutes.'), + {'access_key': access_key, + 'failures': failures, + 'lock_mins': CONF.lockout_minutes}) self.mc.set(failures_key, str(failures), time=CONF.lockout_minutes * 60) return res diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 0b180f866841..41370aeaa45f 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -1308,8 +1308,8 @@ class CloudController(object): # changed to support specifying a particular fixed_ip if # multiple exist but this may not apply to ec2.. if len(fixed_ips) > 1: - LOG.warn(_LW('multiple fixed_ips exist, using the first: %s'), - fixed_ips[0]) + LOG.warning(_LW('multiple fixed_ips exist, using the first: %s'), + fixed_ips[0]) self.network_api.associate_floating_ip(context, instance, floating_address=public_ip, diff --git a/nova/api/metadata/handler.py b/nova/api/metadata/handler.py index 74fb6f2aded5..37386ca2fbf6 100644 --- a/nova/api/metadata/handler.py +++ b/nova/api/metadata/handler.py @@ -110,7 +110,7 @@ class MetadataRequestHandler(wsgi.Application): meta_data = self._handle_instance_id_request(req) else: if req.headers.get('X-Instance-ID'): - LOG.warn( + LOG.warning( _LW("X-Instance-ID present in request headers. The " "'service_metadata_proxy' option must be " "enabled to process this header.")) @@ -144,7 +144,7 @@ class MetadataRequestHandler(wsgi.Application): try: meta_data = self.get_metadata_by_remote_address(remote_address) except Exception: - LOG.exception(_('Failed to get metadata for ip: %s'), + LOG.exception(_LE('Failed to get metadata for ip: %s'), remote_address) msg = _('An unknown error has occurred. ' 'Please try your request again.') @@ -186,14 +186,15 @@ class MetadataRequestHandler(wsgi.Application): if not utils.constant_time_compare(expected_signature, signature): if instance_id: - LOG.warn(_LW('X-Instance-ID-Signature: %(signature)s does ' - 'not match the expected value: ' - '%(expected_signature)s for id: %(instance_id)s.' - ' Request From: %(remote_address)s'), - {'signature': signature, - 'expected_signature': expected_signature, - 'instance_id': instance_id, - 'remote_address': remote_address}) + LOG.warning(_LW('X-Instance-ID-Signature: %(signature)s does ' + 'not match the expected value: ' + '%(expected_signature)s for id: ' + '%(instance_id)s. Request From: ' + '%(remote_address)s'), + {'signature': signature, + 'expected_signature': expected_signature, + 'instance_id': instance_id, + 'remote_address': remote_address}) msg = _('Invalid proxy request signature.') raise webob.exc.HTTPForbidden(explanation=msg) @@ -202,7 +203,7 @@ class MetadataRequestHandler(wsgi.Application): meta_data = self.get_metadata_by_instance_id(instance_id, remote_address) 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) msg = _('An unknown error has occurred. ' 'Please try your request again.') @@ -213,9 +214,9 @@ class MetadataRequestHandler(wsgi.Application): LOG.error(_LE('Failed to get metadata for instance id: %s'), instance_id) elif meta_data.instance['project_id'] != tenant_id: - LOG.warn(_LW("Tenant_id %(tenant_id)s does not match tenant_id " - "of instance %(instance_id)s."), - {'tenant_id': tenant_id, 'instance_id': instance_id}) + LOG.warning(_LW("Tenant_id %(tenant_id)s does not match tenant_id " + "of instance %(instance_id)s."), + {'tenant_id': tenant_id, 'instance_id': instance_id}) # causes a 404 to be raised meta_data = None diff --git a/nova/api/metadata/vendordata_json.py b/nova/api/metadata/vendordata_json.py index fe581c8cf1bc..73a83e834912 100644 --- a/nova/api/metadata/vendordata_json.py +++ b/nova/api/metadata/vendordata_json.py @@ -44,15 +44,15 @@ class JsonFileVendorData(base.VendorDataDriver): data = jsonutils.load(fp) except IOError as e: if e.errno == errno.ENOENT: - LOG.warn(_LW("%(logprefix)sfile does not exist"), - {'logprefix': logprefix}) + LOG.warning(_LW("%(logprefix)sfile does not exist"), + {'logprefix': logprefix}) else: - LOG.warn(_LW("%(logprefix)unexpected IOError when " - "reading"), {'logprefix': logprefix}) + LOG.warning(_LW("%(logprefix)unexpected IOError when " + "reading"), {'logprefix': logprefix}) raise e except ValueError: - LOG.warn(_LW("%(logprefix)sfailed to load json"), - {'logprefix': logprefix}) + LOG.warning(_LW("%(logprefix)sfailed to load json"), + {'logprefix': logprefix}) raise self._data = data diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index e927569bee4c..c16140a542ca 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -29,6 +29,7 @@ from nova.api.openstack import wsgi from nova import exception from nova.i18n import _ from nova.i18n import _LC +from nova.i18n import _LE from nova.i18n import _LI from nova.i18n import _LW from nova.i18n import translate @@ -89,7 +90,7 @@ class FaultWrapper(base_wsgi.Middleware): status, webob.exc.HTTPInternalServerError)() 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) headers = getattr(inner, 'headers', None) @@ -232,9 +233,9 @@ class APIRouter(base_wsgi.Router): msg_format_dict = {'collection': collection, 'ext_name': extension.extension.name} if collection not in self.resources: - LOG.warn(_LW('Extension %(ext_name)s: Cannot extend ' - 'resource %(collection)s: No such resource'), - msg_format_dict) + LOG.warning(_LW('Extension %(ext_name)s: Cannot extend ' + 'resource %(collection)s: No such resource'), + msg_format_dict) continue 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: return self._register_extension(ext) else: - LOG.warn(_LW("Not loading %s because it is " - "in the blacklist"), ext.obj.alias) + LOG.warning(_LW("Not loading %s because it is " + "in the blacklist"), ext.obj.alias) return False else: - LOG.warn( + LOG.warning( _LW("Not loading %s because it is not in the " "whitelist"), ext.obj.alias) return False @@ -308,8 +309,8 @@ class APIRouterV21(base_wsgi.Router): CONF.osapi_v3.extensions_whitelist).intersection( CONF.osapi_v3.extensions_blacklist) if len(in_blacklist_and_whitelist) != 0: - LOG.warn(_LW("Extensions in both blacklist and whitelist: %s"), - list(in_blacklist_and_whitelist)) + LOG.warning(_LW("Extensions in both blacklist and whitelist: %s"), + list(in_blacklist_and_whitelist)) self.api_extension_manager = stevedore.enabled.EnabledExtensionManager( namespace=self.API_EXTENSION_NAMESPACE, @@ -414,9 +415,9 @@ class APIRouterV21(base_wsgi.Router): controller = extension.controller if collection not in self.resources: - LOG.warn(_LW('Extension %(ext_name)s: Cannot extend ' - 'resource %(collection)s: No such resource'), - {'ext_name': ext_name, 'collection': collection}) + LOG.warning(_LW('Extension %(ext_name)s: Cannot extend ' + 'resource %(collection)s: No such resource'), + {'ext_name': ext_name, 'collection': collection}) continue LOG.debug('Extension %(ext_name)s extending resource: ' diff --git a/nova/api/openstack/common.py b/nova/api/openstack/common.py index fe3b66c417cc..613cce5692ac 100644 --- a/nova/api/openstack/common.py +++ b/nova/api/openstack/common.py @@ -495,8 +495,8 @@ def check_snapshots_enabled(f): @functools.wraps(f) def inner(*args, **kwargs): if not CONF.allow_instance_snapshots: - LOG.warn(_LW('Rejecting snapshot request, snapshots currently' - ' disabled')) + LOG.warning(_LW('Rejecting snapshot request, snapshots currently' + ' disabled')) msg = _("Instance snapshots are not permitted at this time.") raise webob.exc.HTTPBadRequest(explanation=msg) return f(*args, **kwargs) diff --git a/nova/api/openstack/compute/contrib/floating_ips.py b/nova/api/openstack/compute/contrib/floating_ips.py index 089e4a55b800..bbb9da2b9840 100644 --- a/nova/api/openstack/compute/contrib/floating_ips.py +++ b/nova/api/openstack/compute/contrib/floating_ips.py @@ -231,8 +231,8 @@ class FloatingIPActionController(wsgi.Controller): if not fixed_address: fixed_address = fixed_ips[0]['address'] if len(fixed_ips) > 1: - LOG.warn(_LW('multiple fixed_ips exist, using the first: ' - '%s'), fixed_address) + LOG.warning(_LW('multiple fixed_ips exist, using the first: ' + '%s'), fixed_address) try: self.network_api.associate_floating_ip(context, instance, diff --git a/nova/api/openstack/compute/plugins/v3/servers.py b/nova/api/openstack/compute/plugins/v3/servers.py index c38084ac5c8a..205229fc5036 100644 --- a/nova/api/openstack/compute/plugins/v3/servers.py +++ b/nova/api/openstack/compute/plugins/v3/servers.py @@ -106,11 +106,11 @@ class ServersController(wsgi.Controller): if ext.obj.alias not in CONF.osapi_v3.extensions_blacklist: return True else: - LOG.warn(_LW("Not loading %s because it is " - "in the blacklist"), ext.obj.alias) + LOG.warning(_LW("Not loading %s because it is " + "in the blacklist"), ext.obj.alias) return False else: - LOG.warn( + LOG.warning( _LW("Not loading %s because it is not in the " "whitelist"), ext.obj.alias) return False diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index f72e2012d526..1898a2588499 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -79,8 +79,8 @@ def make_server(elem, detailed=False): global XML_WARNING if not XML_WARNING: - LOG.warn(_LW('XML support has been deprecated and may be removed ' - 'as early as the Juno release.')) + LOG.warning(_LW('XML support has been deprecated and may be removed ' + 'as early as the Juno release.')) XML_WARNING = True if detailed: diff --git a/nova/api/openstack/compute/views/servers.py b/nova/api/openstack/compute/views/servers.py index cd024325be0b..c9bda3b9bde1 100644 --- a/nova/api/openstack/compute/views/servers.py +++ b/nova/api/openstack/compute/views/servers.py @@ -195,8 +195,8 @@ class ViewBuilder(common.ViewBuilder): def _get_flavor(self, request, instance): instance_type = flavors.extract_flavor(instance) if not instance_type: - LOG.warn(_LW("Instance has had its instance_type removed " - "from the DB"), instance=instance) + LOG.warning(_LW("Instance has had its instance_type removed " + "from the DB"), instance=instance) return {} flavor_id = instance_type["flavorid"] flavor_bookmark = self._flavor_builder._get_bookmark_link(request, diff --git a/nova/api/openstack/extensions.py b/nova/api/openstack/extensions.py index 90702b93efa3..ebac21829095 100644 --- a/nova/api/openstack/extensions.py +++ b/nova/api/openstack/extensions.py @@ -28,6 +28,7 @@ from nova.api.openstack import wsgi from nova.api.openstack import xmlutil from nova import exception from nova.i18n import _ +from nova.i18n import _LE from nova.i18n import _LW from nova.openstack.common import log as logging import nova.policy @@ -239,7 +240,7 @@ class ExtensionManager(object): LOG.debug('Ext namespace: %s', extension.namespace) LOG.debug('Ext updated: %s', extension.updated) except AttributeError as ex: - LOG.exception(_("Exception loading extension: %s"), ex) + LOG.exception(_LE("Exception loading extension: %s"), ex) return False return True @@ -274,9 +275,9 @@ class ExtensionManager(object): try: self.load_extension(ext_factory) except Exception as exc: - LOG.warn(_LW('Failed to load extension %(ext_factory)s: ' - '%(exc)s'), - {'ext_factory': ext_factory, 'exc': exc}) + LOG.warning(_LW('Failed to load extension %(ext_factory)s: ' + '%(exc)s'), + {'ext_factory': ext_factory, 'exc': exc}) class ControllerExtension(object): @@ -498,7 +499,7 @@ def expected_errors(errors): # expected error. raise - LOG.exception(_("Unexpected exception in API method")) + LOG.exception(_LE("Unexpected exception in API method")) msg = _('Unexpected API Error. Please report this at ' 'http://bugs.launchpad.net/nova/ and attach the Nova ' 'API log if possible.\n%s') % type(exc) diff --git a/nova/hacking/checks.py b/nova/hacking/checks.py index ea9e2835b97e..f967e77eef3f 100644 --- a/nova/hacking/checks.py +++ b/nova/hacking/checks.py @@ -303,11 +303,9 @@ def validate_log_translations(logical_line, physical_line, filename): # and the Xen utilities if ("nova/tests" 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: # I075ab2a522272f2082c292dfedc877abd8ebe328 - "nova/api" in filename or - "nova/compute" in filename or - "nova/network" in filename or "nova/virt" in filename): return if pep8.noqa(physical_line): diff --git a/nova/network/floating_ips.py b/nova/network/floating_ips.py index 5dc3e21e79b0..3f0a7ed95341 100644 --- a/nova/network/floating_ips.py +++ b/nova/network/floating_ips.py @@ -25,7 +25,7 @@ import six from nova import context from nova.db import base 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 import objects 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 is None: - LOG.warn(_('Address |%(address)s| is not allocated'), - {'address': floating_ip.address}) + LOG.warning(_LW('Address |%(address)s| is not allocated'), + {'address': floating_ip.address}) raise exception.Forbidden() else: - LOG.warn(_('Address |%(address)s| is not allocated to your ' - 'project |%(project)s|'), - {'address': floating_ip.address, - 'project': context.project_id}) + LOG.warning(_LW('Address |%(address)s| is not allocated ' + 'to your project |%(project)s|'), + {'address': floating_ip.address, + 'project': context.project_id}) raise exception.Forbidden() 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, project_id=project_id) except exception.OverQuota: - LOG.warn(_("Quota exceeded for %s, tried to allocate " - "floating IP"), context.project_id) + LOG.warning(_LW("Quota exceeded for %s, tried to allocate " + "floating IP"), context.project_id) raise exception.FloatingIpLimitExceeded() try: @@ -373,8 +373,8 @@ class FloatingIP(object): objects.FloatingIP.disassociate(context, floating_address) except Exception: - LOG.warn(_('Failed to disassociated floating ' - 'address: %s'), floating_address) + LOG.warning(_LW('Failed to disassociated floating ' + 'address: %s'), floating_address) pass if "Cannot find device" in six.text_type(e): try: @@ -538,10 +538,11 @@ class FloatingIP(object): floating_ip = objects.FloatingIP.get_by_address(context, address) if self._is_stale_floating_ip_address(context, floating_ip): - LOG.warn(_("Floating ip address |%(address)s| no longer " - "belongs to instance %(instance_uuid)s. Will not " - "migrate it "), - {'address': address, 'instance_uuid': instance_uuid}) + LOG.warning(_LW("Floating ip address |%(address)s| no longer " + "belongs to instance %(instance_uuid)s. " + "Will not migrate it "), + {'address': address, + 'instance_uuid': instance_uuid}) continue interface = CONF.public_interface or floating_ip.interface @@ -574,10 +575,11 @@ class FloatingIP(object): floating_ip = objects.FloatingIP.get_by_address(context, address) if self._is_stale_floating_ip_address(context, floating_ip): - LOG.warn(_("Floating ip address |%(address)s| no longer " - "belongs to instance %(instance_uuid)s. Will not" - "setup it."), - {'address': address, 'instance_uuid': instance_uuid}) + LOG.warning(_LW("Floating ip address |%(address)s| no longer " + "belongs to instance %(instance_uuid)s. " + "Will not setup it."), + {'address': address, + 'instance_uuid': instance_uuid}) continue floating_ip.host = dest @@ -617,10 +619,10 @@ class FloatingIP(object): if domain_entry: domains.append(domain_entry) else: - LOG.warn(_('Database inconsistency: DNS domain |%s| is ' - 'registered in the Nova db but not visible to ' - 'either the floating or instance DNS driver. It ' - 'will be ignored.'), dns_domain.domain) + LOG.warning(_LW('Database inconsistency: DNS domain |%s| is ' + 'registered in the Nova db but not visible to ' + 'either the floating or instance DNS driver. ' + 'It will be ignored.'), dns_domain.domain) return domains @@ -657,18 +659,18 @@ class FloatingIP(object): try: self.instance_dns_manager.create_domain(domain) except exception.FloatingIpDNSExists: - LOG.warn(_('Domain |%(domain)s| already exists, ' - 'changing zone to |%(av_zone)s|.'), - {'domain': domain, 'av_zone': av_zone}) + LOG.warning(_LW('Domain |%(domain)s| already exists, ' + 'changing zone to |%(av_zone)s|.'), + {'domain': domain, 'av_zone': av_zone}) def create_public_dns_domain(self, context, domain, project): objects.DNSDomain.register_for_project(context, domain, project) try: self.floating_dns_manager.create_domain(domain) except exception.FloatingIpDNSExists: - LOG.warn(_('Domain |%(domain)s| already exists, ' - 'changing project to |%(project)s|.'), - {'domain': domain, 'project': project}) + LOG.warning(_LW('Domain |%(domain)s| already exists, ' + 'changing project to |%(project)s|.'), + {'domain': domain, 'project': project}) def delete_dns_domain(self, context, domain): objects.DNSDomain.delete_by_domain(context, domain) diff --git a/nova/network/ldapdns.py b/nova/network/ldapdns.py index 488467f1196e..c0815f118963 100644 --- a/nova/network/ldapdns.py +++ b/nova/network/ldapdns.py @@ -23,7 +23,7 @@ import time from oslo.config import cfg from nova import exception -from nova.i18n import _ +from nova.i18n import _, _LW from nova.network import dns_driver from nova.openstack.common import log as logging from nova import utils @@ -105,9 +105,9 @@ class DNSEntry(object): if not entry: return None if len(entry) > 1: - LOG.warn(_("Found multiple matches for domain " - "%(domain)s.\n%(entry)s") % - (domain, entry)) + LOG.warning(_LW("Found multiple matches for domain " + "%(domain)s.\n%(entry)s"), + domain, entry) return entry[0] @classmethod @@ -132,10 +132,10 @@ class DNSEntry(object): if name.endswith(z): dequalified = name[0:name.rfind(z)] else: - LOG.warn(_("Unable to dequalify. %(name)s is not in " - "%(domain)s.\n") % - {'name': name, - 'domain': self.qualified_domain}) + LOG.warning(_LW("Unable to dequalify. %(name)s is not in " + "%(domain)s.\n"), + {'name': name, + 'domain': self.qualified_domain}) dequalified = None return dequalified @@ -373,5 +373,6 @@ class LdapDNS(dns_driver.DNSDriver): dEntry.delete() 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 diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index f9d3aa041bbe..e523247e1446 100644 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -32,7 +32,7 @@ from oslo.utils import timeutils import six from nova import exception -from nova.i18n import _, _LE +from nova.i18n import _, _LE, _LW from nova import objects from nova.openstack.common import fileutils from nova.openstack.common import log as logging @@ -229,8 +229,8 @@ class IptablesTable(object): chain_set = self.unwrapped_chains if name not in chain_set: - LOG.warn(_('Attempted to remove chain %s which does not exist'), - name) + LOG.warning(_LW('Attempted to remove chain %s which does not ' + 'exist'), name) return self.dirty = True @@ -298,10 +298,10 @@ class IptablesTable(object): self.remove_rules.append(IptablesRule(chain, rule, wrap, top)) self.dirty = True except ValueError: - LOG.warn(_('Tried to remove rule that was not there:' - ' %(chain)r %(rule)r %(wrap)r %(top)r'), - {'chain': chain, 'rule': rule, - 'top': top, 'wrap': wrap}) + LOG.warning(_LW('Tried to remove rule that was not there:' + ' %(chain)r %(rule)r %(wrap)r %(top)r'), + {'chain': chain, 'rule': rule, + 'top': top, 'wrap': wrap}) def remove_rules_regex(self, regex): """Remove all rules matching regex.""" diff --git a/nova/network/manager.py b/nova/network/manager.py index e112530ed673..40de639ca65f 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -810,21 +810,21 @@ class NetworkManager(manager.Manager): domainref = objects.DNSDomain.get_by_domain(context, instance_domain) 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) return True dns_zone = domainref.availability_zone instance_zone = instance.get('availability_zone') if dns_zone and (dns_zone != instance_zone): - LOG.warn(_('instance-dns-zone is |%(domain)s|, ' - 'which is in availability zone |%(zone)s|. ' - 'Instance is in zone |%(zone2)s|. ' - 'No DNS record will be created.'), - {'domain': instance_domain, - 'zone': dns_zone, - 'zone2': instance_zone}, - instance=instance) + LOG.warning(_LW('instance-dns-zone is |%(domain)s|, ' + 'which is in availability zone |%(zone)s|. ' + 'Instance is in zone |%(zone2)s|. ' + 'No DNS record will be created.'), + {'domain': instance_domain, + 'zone': dns_zone, + 'zone2': instance_zone}, + instance=instance) return False else: return True @@ -860,11 +860,12 @@ class NetworkManager(manager.Manager): headroom = exc.kwargs['headroom'] allowed = quotas['fixed_ips'] used = allowed - headroom['fixed_ips'] - LOG.warn(_LW("Quota exceeded for project %(pid)s, tried to " - "allocate fixed IP. %(used)s of %(allowed)s are in " - "use or are already reserved."), - {'pid': quota_project, 'used': used, 'allowed': allowed}, - instance_uuid=instance_id) + LOG.warning(_LW("Quota exceeded for project %(pid)s, tried to " + "allocate fixed IP. %(used)s of %(allowed)s are " + "in use or are already reserved."), + {'pid': quota_project, 'used': used, + 'allowed': allowed}, + instance_uuid=instance_id) raise exception.FixedIpLimitExceeded() try: @@ -947,9 +948,9 @@ class NetworkManager(manager.Manager): try: f() except Exception: - LOG.warn(_('Error cleaning up fixed ip allocation. ' - 'Manual cleanup may be required.'), - exc_info=True) + LOG.warning(_LW('Error cleaning up fixed ip ' + 'allocation. Manual cleanup may ' + 'be required.'), exc_info=True) def deallocate_fixed_ip(self, context, address, host=None, teardown=True, instance=None): @@ -1049,9 +1050,9 @@ class NetworkManager(manager.Manager): try: quotas.rollback(context) except Exception: - LOG.warn(_LW("Failed to rollback quota for " - "deallocate fixed ip: %s"), address, - instance=instance) + LOG.warning(_LW("Failed to rollback quota for " + "deallocate fixed ip: %s"), address, + instance=instance) # Commit the reservations quotas.commit(context) @@ -1062,14 +1063,14 @@ class NetworkManager(manager.Manager): fixed_ip = objects.FixedIP.get_by_address(context, address) if fixed_ip.instance_uuid is None: - LOG.warn(_('IP %s leased that is not associated'), address, - context=context) + LOG.warning(_LW('IP %s leased that is not associated'), address, + context=context) return fixed_ip.leased = True fixed_ip.save() if not fixed_ip.allocated: - LOG.warn(_('IP |%s| leased that isn\'t allocated'), address, - context=context) + LOG.warning(_LW('IP |%s| leased that isn\'t allocated'), address, + context=context) def release_fixed_ip(self, context, address): """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) if fixed_ip.instance_uuid is None: - LOG.warn(_('IP %s released that is not associated'), address, - context=context) + LOG.warning(_LW('IP %s released that is not associated'), address, + context=context) return if not fixed_ip.leased: - LOG.warn(_('IP %s released that was not leased'), address, - context=context) + LOG.warning(_LW('IP %s released that was not leased'), address, + context=context) fixed_ip.leased = False fixed_ip.save() if not fixed_ip.allocated: diff --git a/nova/network/minidns.py b/nova/network/minidns.py index b860d8bb4dbd..2cee8f985c79 100644 --- a/nova/network/minidns.py +++ b/nova/network/minidns.py @@ -19,7 +19,7 @@ import tempfile from oslo.config import cfg from nova import exception -from nova.i18n import _, _LI +from nova.i18n import _, _LI, _LW from nova.network import dns_driver from nova.openstack.common import log as logging @@ -119,8 +119,8 @@ class MiniDNS(dns_driver.DNSDriver): outfile.close() shutil.move(outfile.name, self.filename) if not deleted: - LOG.warn(_('Cannot delete entry |%s|'), - self.qualify(name, domain)) + LOG.warning(_LW('Cannot delete entry |%s|'), + self.qualify(name, domain)) raise exception.NotFound def modify_address(self, name, address, domain): @@ -204,5 +204,5 @@ class MiniDNS(dns_driver.DNSDriver): outfile.close() shutil.move(outfile.name, self.filename) if not deleted: - LOG.warn(_('Cannot delete domain |%s|'), fqdomain) + LOG.warning(_LW('Cannot delete domain |%s|'), fqdomain) raise exception.NotFound diff --git a/nova/network/neutronv2/api.py b/nova/network/neutronv2/api.py index 84bb405ab251..d283d6385f76 100644 --- a/nova/network/neutronv2/api.py +++ b/nova/network/neutronv2/api.py @@ -299,7 +299,7 @@ class API(base_api.NetworkAPI): nets = self._get_available_networks(context, instance.project_id, net_ids, neutron=neutron) if not nets: - LOG.warn(_LW("No network configured!"), instance=instance) + LOG.warning(_LW("No network configured!"), instance=instance) return network_model.NetworkInfo([]) # if this function is directly called without a requested_network param diff --git a/nova/network/security_group/neutron_driver.py b/nova/network/security_group/neutron_driver.py index 77e9ecca3689..3c82f372ad70 100644 --- a/nova/network/security_group/neutron_driver.py +++ b/nova/network/security_group/neutron_driver.py @@ -24,7 +24,7 @@ from webob import exc from nova.compute import api as compute_api 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.security_group import security_group_base from nova import objects @@ -428,10 +428,12 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase): for port in ports: if not self._has_security_group_requirements(port): - LOG.warn(_("Cannot add security group %(name)s to %(instance)s" - " since the port %(port_id)s does not meet security" - " requirements"), {'name': security_group_name, - 'instance': instance['uuid'], 'port_id': port['id']}) + LOG.warning(_LW("Cannot add security group %(name)s to " + "%(instance)s since the port %(port_id)s " + "does not meet security requirements"), + {'name': security_group_name, + 'instance': instance['uuid'], + 'port_id': port['id']}) raise exception.SecurityGroupCannotBeApplied() if 'security_groups' not in port: port['security_groups'] = []