diff --git a/heat/engine/api.py b/heat/engine/api.py index f5cf8b3cfa..a220ee51d5 100644 --- a/heat/engine/api.py +++ b/heat/engine/api.py @@ -14,6 +14,7 @@ from oslo.utils import timeutils from heat.common.i18n import _ +from heat.common.i18n import _LE from heat.common import param_utils from heat.common import template_format from heat.engine import constraints as constr @@ -263,7 +264,7 @@ def format_watch_data(wd): if len(metric) == 1: metric_name, metric_data = metric[0] else: - LOG.error(_("Unexpected number of keys in watch_data.data!")) + LOG.error(_LE("Unexpected number of keys in watch_data.data!")) return result = { diff --git a/heat/engine/clients/__init__.py b/heat/engine/clients/__init__.py index 2f2705c367..da659af71f 100644 --- a/heat/engine/clients/__init__.py +++ b/heat/engine/clients/__init__.py @@ -16,7 +16,7 @@ from oslo.utils import importutils from stevedore import extension import warnings -from heat.common.i18n import _ +from heat.common.i18n import _LW from heat.openstack.common import log as logging LOG = logging.getLogger(__name__) @@ -65,7 +65,7 @@ class OpenStackClients(object): client = getattr(self, method_name)() self._clients[name] = client return client - LOG.warn(_('Requested client "%s" not found') % name) + LOG.warn(_LW('Requested client "%s" not found'), name) @property def auth_token(self): diff --git a/heat/engine/clients/os/cinder.py b/heat/engine/clients/os/cinder.py index d6a23c7856..b8a0288a2e 100644 --- a/heat/engine/clients/os/cinder.py +++ b/heat/engine/clients/os/cinder.py @@ -17,8 +17,9 @@ from cinderclient import client as cc from cinderclient import exceptions from heat.common import exception +from heat.common.i18n import _ +from heat.common.i18n import _LI from heat.engine import clients -from heat.openstack.common.gettextutils import _ LOG = logging.getLogger(__name__) @@ -56,7 +57,7 @@ class CinderClientPlugin(clients.client_plugin.ClientPlugin): client_version = '2' else: raise exception.Error(_('No volume service available.')) - LOG.info(_('Creating Cinder client with volume API version %d.'), + LOG.info(_LI('Creating Cinder client with volume API version %d.'), volume_api_version) endpoint_type = self._get_client_option('cinder', 'endpoint_type') diff --git a/heat/engine/clients/os/glance.py b/heat/engine/clients/os/glance.py index 20db6f970a..49c6e1b8d1 100644 --- a/heat/engine/clients/os/glance.py +++ b/heat/engine/clients/os/glance.py @@ -16,6 +16,7 @@ from glanceclient import exc from heat.common import exception from heat.common.i18n import _ +from heat.common.i18n import _LI from heat.engine.clients import client_plugin from heat.engine import constraints from heat.openstack.common import log as logging @@ -92,11 +93,11 @@ class GlanceClientPlugin(client_plugin.ClientPlugin): _("Error retrieving image list from glance: %s") % ex) num_matches = len(image_list) if num_matches == 0: - LOG.info(_("Image %s was not found in glance") % + LOG.info(_LI("Image %s was not found in glance"), image_identifier) raise exception.ImageNotFound(image_name=image_identifier) elif num_matches > 1: - LOG.info(_("Multiple images %s were found in glance with name") % + LOG.info(_LI("Multiple images %s were found in glance with name"), image_identifier) raise exception.PhysicalResourceNameAmbiguity( name=image_identifier) diff --git a/heat/engine/clients/os/nova.py b/heat/engine/clients/os/nova.py index 2d67cd56a3..2a95ebf938 100644 --- a/heat/engine/clients/os/nova.py +++ b/heat/engine/clients/os/nova.py @@ -29,6 +29,7 @@ from six.moves.urllib import parse as urlparse from heat.common import exception from heat.common.i18n import _ +from heat.common.i18n import _LW from heat.engine.clients import client_plugin from heat.engine import scheduler @@ -104,19 +105,20 @@ class NovaClientPlugin(client_plugin.ClientPlugin): try: server.get() except exceptions.OverLimit as exc: - msg = _("Server %(name)s (%(id)s) received an OverLimit " - "response during server.get(): %(exception)s") - LOG.warning(msg % {'name': server.name, - 'id': server.id, - 'exception': exc}) + LOG.warn(_LW("Server %(name)s (%(id)s) received an OverLimit " + "response during server.get(): %(exception)s"), + {'name': server.name, + 'id': server.id, + 'exception': exc}) except exceptions.ClientException as exc: if ((getattr(exc, 'http_status', getattr(exc, 'code', None)) in (500, 503))): - msg = _('Server "%(name)s" (%(id)s) received the following ' - 'exception during server.get(): %(exception)s') - LOG.warning(msg % {'name': server.name, - 'id': server.id, - 'exception': exc}) + LOG.warn(_LW('Server "%(name)s" (%(id)s) received the ' + 'following exception during server.get(): ' + '%(exception)s'), + {'name': server.name, + 'id': server.id, + 'exception': exc}) else: raise @@ -396,8 +398,8 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers try: server = self.client().servers.get(server) except exceptions.NotFound as ex: - LOG.warn(_('Instance (%(server)s) not found: %(ex)s') - % {'server': server, 'ex': ex}) + LOG.warn(_LW('Instance (%(server)s) not found: %(ex)s'), + {'server': server, 'ex': ex}) else: for n in server.networks: if len(server.networks[n]) > 0: diff --git a/heat/engine/environment.py b/heat/engine/environment.py index 383b6a38be..2534cfaad1 100644 --- a/heat/engine/environment.py +++ b/heat/engine/environment.py @@ -23,6 +23,9 @@ import six from heat.common import environment_format as env_fmt from heat.common import exception from heat.common.i18n import _ +from heat.common.i18n import _LE +from heat.common.i18n import _LI +from heat.common.i18n import _LW from heat.engine import support from heat.openstack.common import log @@ -193,13 +196,13 @@ class ResourceRegistry(object): for res_name in registry.keys(): if isinstance(registry[res_name], ResourceInfo) and \ res_name.startswith(name[:-1]): - LOG.warn(_('Removing %(item)s from %(path)s') % { + LOG.warn(_LW('Removing %(item)s from %(path)s'), { 'item': res_name, 'path': descriptive_path}) del registry[res_name] else: # delete this entry. - LOG.warn(_('Removing %(item)s from %(path)s') % { + LOG.warn(_LW('Removing %(item)s from %(path)s'), { 'item': name, 'path': descriptive_path}) registry.pop(name, None) @@ -212,9 +215,10 @@ class ResourceRegistry(object): 'path': descriptive_path, 'was': str(registry[name].value), 'now': str(info.value)} - LOG.warn(_('Changing %(path)s from %(was)s to %(now)s') % details) + LOG.warn(_LW('Changing %(path)s from %(was)s to %(now)s'), + details) else: - LOG.info(_('Registering %(path)s -> %(value)s') % { + LOG.info(_LI('Registering %(path)s -> %(value)s'), { 'path': descriptive_path, 'value': str(info.value)}) @@ -429,22 +433,22 @@ def read_global_environment(env, env_dir=None): try: env_files = glob.glob(os.path.join(env_dir, '*')) except OSError as osex: - LOG.error(_('Failed to read %s') % env_dir) + LOG.error(_LE('Failed to read %s'), env_dir) LOG.exception(osex) return for file_path in env_files: try: with open(file_path) as env_fd: - LOG.info(_('Loading %s') % file_path) + LOG.info(_LI('Loading %s'), file_path) env_body = env_fmt.parse(env_fd.read()) env_fmt.default_for_missing(env_body) env.load(env_body) except ValueError as vex: - LOG.error(_('Failed to parse %(file_path)s') % { + LOG.error(_LE('Failed to parse %(file_path)s'), { 'file_path': file_path}) LOG.exception(vex) except IOError as ioex: - LOG.error(_('Failed to read %(file_path)s') % { + LOG.error(_LE('Failed to read %(file_path)s'), { 'file_path': file_path}) LOG.exception(ioex) diff --git a/heat/engine/event.py b/heat/engine/event.py index 3df6cf1f48..ff03dad8b2 100644 --- a/heat/engine/event.py +++ b/heat/engine/event.py @@ -17,9 +17,6 @@ from heat.common import exception from heat.common.i18n import _ from heat.common import identifier from heat.db import api as db_api -from heat.openstack.common import log as logging - -LOG = logging.getLogger(__name__) class Event(object): diff --git a/heat/engine/notification/__init__.py b/heat/engine/notification/__init__.py index a8fcf96edf..68fc7e517b 100644 --- a/heat/engine/notification/__init__.py +++ b/heat/engine/notification/__init__.py @@ -14,9 +14,7 @@ from oslo.config import cfg from heat.common import messaging -from heat.openstack.common import log -LOG = log.getLogger(__name__) SERVICE = 'orchestration' INFO = 'INFO' ERROR = 'ERROR' diff --git a/heat/engine/plugin_manager.py b/heat/engine/plugin_manager.py index 6a3bd425f2..538037bf4d 100644 --- a/heat/engine/plugin_manager.py +++ b/heat/engine/plugin_manager.py @@ -19,7 +19,7 @@ import sys from oslo.config import cfg import six -from heat.common.i18n import _ +from heat.common.i18n import _LE from heat.common import plugin_loader from heat.openstack.common import log @@ -95,15 +95,15 @@ class PluginMapping(object): try: mapping_dict = mapping_func(*self.args, **self.kwargs) except Exception: - LOG.error(_('Failed to load %(mapping_name)s ' - 'from %(module)s') % fmt_data) + LOG.error(_LE('Failed to load %(mapping_name)s ' + 'from %(module)s'), fmt_data) raise else: if isinstance(mapping_dict, collections.Mapping): return mapping_dict elif mapping_dict is not None: - LOG.error(_('Invalid type for %(mapping_name)s ' - 'from %(module)s') % fmt_data) + LOG.error(_LE('Invalid type for %(mapping_name)s ' + 'from %(module)s'), fmt_data) return {} diff --git a/heat/engine/resource.py b/heat/engine/resource.py index ccf0e6996a..722a265d0d 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -21,6 +21,9 @@ import warnings from heat.common import exception from heat.common.i18n import _ +from heat.common.i18n import _LE +from heat.common.i18n import _LI +from heat.common.i18n import _LW from heat.common import identifier from heat.common import short_id from heat.common import timeutils @@ -528,7 +531,7 @@ class Resource(object): % str(self.state)) raise exception.ResourceFailure(exc, self, action) - LOG.info(_('creating %s') % str(self)) + LOG.info(_LI('creating %s'), str(self)) # Re-resolve the template, since if the resource Ref's # the StackId pseudo parameter, it will change after @@ -677,7 +680,7 @@ class Resource(object): exc = Exception(_('Resource update already requested')) raise exception.ResourceFailure(exc, self, action) - LOG.info(_('updating %s') % str(self)) + LOG.info(_LI('updating %s'), six.text_type(self)) self.updated_time = datetime.utcnow() with self._action_recorder(action, UpdateReplace): @@ -702,7 +705,7 @@ class Resource(object): original state with the added message that check was not performed. """ action = self.CHECK - LOG.info(_('Checking %s') % six.text_type(self)) + LOG.info(_LI('Checking %s'), six.text_type(self)) if hasattr(self, 'handle_%s' % action.lower()): return self._do_action(action) @@ -723,7 +726,7 @@ class Resource(object): % str(self.state)) raise exception.ResourceFailure(exc, self, action) - LOG.info(_('suspending %s') % str(self)) + LOG.info(_LI('suspending %s'), six.text_type(self)) return self._do_action(action) def resume(self): @@ -739,12 +742,12 @@ class Resource(object): % str(self.state)) raise exception.ResourceFailure(exc, self, action) - LOG.info(_('resuming %s') % str(self)) + LOG.info(_LI('resuming %s'), six.text_type(self)) return self._do_action(action) def snapshot(self): '''Snapshot the resource and return the created data, if any.''' - LOG.info(_('snapshotting %s') % str(self)) + LOG.info(_LI('snapshotting %s'), six.text_type(self)) return self._do_action(self.SNAPSHOT) @scheduler.wrappertask @@ -790,7 +793,7 @@ class Resource(object): return name[0:2] + '-' + name[-postfix_length:] def validate(self): - LOG.info(_('Validating %s') % str(self)) + LOG.info(_LI('Validating %s'), six.text_type(self)) function.validate(self.t) self.validate_deletion_policy(self.t.deletion_policy()) @@ -823,7 +826,7 @@ class Resource(object): initial_state = self.state - LOG.info(_('deleting %s') % str(self)) + LOG.info(_LI('deleting %s'), six.text_type(self)) with self._action_recorder(action): if self.abandon_in_progress: @@ -864,7 +867,7 @@ class Resource(object): rs = db_api.resource_get(self.context, self.id) rs.update_and_save({'nova_instance': self.resource_id}) except Exception as ex: - LOG.warn(_('db error %s') % ex) + LOG.warn(_LW('db error %s'), ex) def _store(self): '''Create the resource in the database.''' @@ -885,7 +888,7 @@ class Resource(object): self.created_time = new_rs.created_at self._rsrc_metadata = metadata except Exception as ex: - LOG.error(_('DB error %s') % ex) + LOG.error(_LE('DB error %s'), ex) def _add_event(self, action, status, reason): '''Add a state change event to the database.''' @@ -912,7 +915,7 @@ class Resource(object): 'properties_data': self._stored_properties_data, 'nova_instance': self.resource_id}) except Exception as ex: - LOG.error(_('DB error %s') % ex) + LOG.error(_LE('DB error %s'), ex) # store resource in DB on transition to CREATE_IN_PROGRESS # all other transitions (other than to DELETE_COMPLETE) @@ -1050,8 +1053,8 @@ class Resource(object): No-op for resources which don't explicitly override this method ''' if new_metadata: - LOG.warning(_("Resource %s does not implement metadata update") - % self.name) + LOG.warn(_LW("Resource %s does not implement metadata update"), + self.name) @classmethod def resource_to_template(cls, resource_type): diff --git a/heat/engine/resources/autoscaling.py b/heat/engine/resources/autoscaling.py index a1cc61f867..176b6608a6 100644 --- a/heat/engine/resources/autoscaling.py +++ b/heat/engine/resources/autoscaling.py @@ -20,6 +20,7 @@ import six from heat.common import environment_format from heat.common import exception from heat.common.i18n import _ +from heat.common.i18n import _LI from heat.common import timeutils as iso8601utils from heat.engine import attributes from heat.engine import constraints @@ -617,10 +618,10 @@ class AutoScalingGroup(InstanceGroup, cooldown.CooldownMixin): Adjust the size of the scaling group if the cooldown permits. """ if self._cooldown_inprogress(): - LOG.info(_("%(name)s NOT performing scaling adjustment, " - "cooldown %(cooldown)s") - % {'name': self.name, - 'cooldown': self.properties[self.COOLDOWN]}) + LOG.info(_LI("%(name)s NOT performing scaling adjustment, " + "cooldown %(cooldown)s"), + {'name': self.name, + 'cooldown': self.properties[self.COOLDOWN]}) return capacity = len(self.get_instances()) diff --git a/heat/engine/resources/aws/scaling_policy.py b/heat/engine/resources/aws/scaling_policy.py index e13a09d4b0..5566838f71 100644 --- a/heat/engine/resources/aws/scaling_policy.py +++ b/heat/engine/resources/aws/scaling_policy.py @@ -13,6 +13,7 @@ from heat.common import exception from heat.common.i18n import _ +from heat.common.i18n import _LI from heat.engine import attributes from heat.engine import constraints @@ -114,16 +115,16 @@ class AWSScalingPolicy(signal_responder.SignalResponder, alarm_state = details.get('current', details.get('state', 'alarm')).lower() - LOG.info(_('%(name)s Alarm, new state %(state)s') - % {'name': self.name, 'state': alarm_state}) + LOG.info(_LI('%(name)s Alarm, new state %(state)s'), + {'name': self.name, 'state': alarm_state}) if alarm_state != 'alarm': return if self._cooldown_inprogress(): - LOG.info(_("%(name)s NOT performing scaling action, " - "cooldown %(cooldown)s") - % {'name': self.name, - 'cooldown': self.properties[self.COOLDOWN]}) + LOG.info(_LI("%(name)s NOT performing scaling action, " + "cooldown %(cooldown)s"), + {'name': self.name, + 'cooldown': self.properties[self.COOLDOWN]}) return asgn_id = self.properties[self.AUTO_SCALING_GROUP_NAME] @@ -134,10 +135,10 @@ class AWSScalingPolicy(signal_responder.SignalResponder, 'alarm': self.name, 'group': asgn_id}) - LOG.info(_('%(name)s Alarm, adjusting Group %(group)s with id ' - '%(asgn_id)s by %(filter)s') - % {'name': self.name, 'group': group.name, 'asgn_id': asgn_id, - 'filter': self.properties[self.SCALING_ADJUSTMENT]}) + LOG.info(_LI('%(name)s Alarm, adjusting Group %(group)s with id ' + '%(asgn_id)s by %(filter)s'), + {'name': self.name, 'group': group.name, 'asgn_id': asgn_id, + 'filter': self.properties[self.SCALING_ADJUSTMENT]}) adjustment_type = self._get_adjustement_type() group.adjust(self.properties[self.SCALING_ADJUSTMENT], adjustment_type) diff --git a/heat/engine/resources/eip.py b/heat/engine/resources/eip.py index 071a9682df..8dc5a6b235 100644 --- a/heat/engine/resources/eip.py +++ b/heat/engine/resources/eip.py @@ -15,6 +15,9 @@ from oslo.utils import excutils from heat.common import exception from heat.common.i18n import _ +from heat.common.i18n import _LE +from heat.common.i18n import _LI +from heat.common.i18n import _LW from heat.engine import attributes from heat.engine import constraints from heat.engine import properties @@ -96,21 +99,21 @@ class ElasticIp(resource.Resource): 'floatingip': props})['floatingip'] self.ipaddress = ips['floating_ip_address'] self.resource_id_set(ips['id']) - LOG.info(_('ElasticIp create %s') % str(ips)) + LOG.info(_LI('ElasticIp create %s'), str(ips)) else: try: ips = self.nova().floating_ips.create() except Exception as e: with excutils.save_and_reraise_exception(): if self.client_plugin('nova').is_not_found(e): - msg = _("No default floating IP pool configured. " - "Set 'default_floating_pool' in nova.conf.") - LOG.error(msg) + LOG.error(_LE("No default floating IP pool configured." + " Set 'default_floating_pool' in " + "nova.conf.")) if ips: self.ipaddress = ips.ip self.resource_id_set(ips.id) - LOG.info(_('ElasticIp create %s') % str(ips)) + LOG.info(_LI('ElasticIp create %s'), str(ips)) instance_id = self.properties[self.INSTANCE_ID] if instance_id: @@ -316,7 +319,7 @@ class ElasticIpAssociation(resource.Resource): self._floatingIp_detach(nova_ignore_not_found=True) port_id, port_rsrc = self._get_port_info(ni_id, instance_id) if not port_id or not port_rsrc: - LOG.error(_('Port not specified.')) + LOG.error(_LE('Port not specified.')) raise exception.NotFound(_('Failed to update, can not found ' 'port info.')) @@ -339,7 +342,7 @@ class ElasticIpAssociation(resource.Resource): port_id, port_rsrc = self._get_port_info(ni_id_update, instance_id_update) if not port_id or not port_rsrc: - LOG.error(_('Port not specified.')) + LOG.error(_LE('Port not specified.')) raise exception.NotFound(_('Failed to update, can not found ' 'port info.')) @@ -383,7 +386,7 @@ class ElasticIpAssociation(resource.Resource): instance_id = self.properties[self.INSTANCE_ID] port_id, port_rsrc = self._get_port_info(ni_id, instance_id) if not port_id or not port_rsrc: - LOG.warn(_('Skipping association, resource not specified')) + LOG.warn(_LW('Skipping association, resource not specified')) return float_id = self.properties[self.ALLOCATION_ID] diff --git a/heat/engine/resources/instance.py b/heat/engine/resources/instance.py index 820141cee8..c5ca0d5657 100644 --- a/heat/engine/resources/instance.py +++ b/heat/engine/resources/instance.py @@ -18,6 +18,7 @@ import six from heat.common import exception from heat.common.i18n import _ +from heat.common.i18n import _LI from heat.engine import attributes from heat.engine import constraints from heat.engine import properties @@ -83,21 +84,22 @@ class Restarter(signal_responder.SignalResponder): else: alarm_state = details.get('state', 'alarm').lower() - LOG.info(_('%(name)s Alarm, new state %(state)s') - % {'name': self.name, 'state': alarm_state}) + LOG.info(_LI('%(name)s Alarm, new state %(state)s'), + {'name': self.name, 'state': alarm_state}) if alarm_state != 'alarm': return victim = self._find_resource(self.properties[self.INSTANCE_ID]) if victim is None: - LOG.info(_('%(name)s Alarm, can not find instance %(instance)s') - % {'name': self.name, - 'instance': self.properties[self.INSTANCE_ID]}) + LOG.info(_LI('%(name)s Alarm, can not find instance ' + '%(instance)s'), + {'name': self.name, + 'instance': self.properties[self.INSTANCE_ID]}) return - LOG.info(_('%(name)s Alarm, restarting resource: %(victim)s') - % {'name': self.name, 'victim': victim.name}) + LOG.info(_LI('%(name)s Alarm, restarting resource: %(victim)s'), + {'name': self.name, 'victim': victim.name}) self.stack.restart_resource(victim.name) def _resolve_attribute(self, name): @@ -457,7 +459,7 @@ class Instance(resource.Resource): elif name in self.ATTRIBUTES[1:]: res = self._ipaddress() - LOG.info(_('%(name)s._resolve_attribute(%(attname)s) == %(res)s'), + LOG.info(_LI('%(name)s._resolve_attribute(%(attname)s) == %(res)s'), {'name': self.name, 'attname': name, 'res': res}) return unicode(res) if res else None