From 105a8064930be75c8ab6ad3a8ef6f86d2eb9e1ba Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Mon, 19 May 2014 18:10:55 +0200 Subject: [PATCH] all non debug log messages should be translated Updated a set of files to add missing translation support in the log messages. Change-Id: I58d561c5e1ecff550483ee0be696999e927c98ad Partial-Bug: #1321283 --- bin/heat-api | 3 ++- bin/heat-api-cfn | 3 ++- bin/heat-api-cloudwatch | 3 ++- .../heat_keystoneclient_v2/client.py | 4 ++-- .../nova_flavor/resources/nova_flavor.py | 2 +- heat/api/cfn/v1/stacks.py | 2 +- heat/cloudinit/loguserdata.py | 18 +++++++++--------- heat/common/exception.py | 2 +- heat/common/heat_keystoneclient.py | 6 +++--- heat/engine/resource.py | 6 +++--- .../software_config/software_config.py | 2 +- 11 files changed, 27 insertions(+), 24 deletions(-) diff --git a/bin/heat-api b/bin/heat-api index 1c8bf74d73..3dc7290d7c 100755 --- a/bin/heat-api +++ b/bin/heat-api @@ -57,7 +57,8 @@ if __name__ == '__main__': port = cfg.CONF.heat_api.bind_port host = cfg.CONF.heat_api.bind_host - LOG.info('Starting Heat ReST API on %s:%s' % (host, port)) + LOG.info(_('Starting Heat ReST API on %(host)s:%(port)s'), + {'host': host, 'port': port}) server = wsgi.Server() server.start(app, cfg.CONF.heat_api, default_port=port) notify.startup_notify(cfg.CONF.onready) diff --git a/bin/heat-api-cfn b/bin/heat-api-cfn index c8876714f1..06aba9b02a 100755 --- a/bin/heat-api-cfn +++ b/bin/heat-api-cfn @@ -59,7 +59,8 @@ if __name__ == '__main__': port = cfg.CONF.heat_api_cfn.bind_port host = cfg.CONF.heat_api_cfn.bind_host - LOG.info('Starting Heat API on %s:%s' % (host, port)) + LOG.info(_('Starting Heat API on %(host)s:%(port)s'), + {'host': host, 'port': port}) server = wsgi.Server() server.start(app, cfg.CONF.heat_api_cfn, default_port=port) notify.startup_notify(cfg.CONF.onready) diff --git a/bin/heat-api-cloudwatch b/bin/heat-api-cloudwatch index 055bd9253a..b6e1f142ec 100755 --- a/bin/heat-api-cloudwatch +++ b/bin/heat-api-cloudwatch @@ -59,7 +59,8 @@ if __name__ == '__main__': port = cfg.CONF.heat_api_cloudwatch.bind_port host = cfg.CONF.heat_api_cloudwatch.bind_host - LOG.info('Starting Heat CloudWatch API on %s:%s' % (host, port)) + LOG.info(_('Starting Heat CloudWatch API on %(host)s:%(port)s'), + {'host': host, 'port': port}) server = wsgi.Server() server.start(app, cfg.CONF.heat_api_cloudwatch, default_port=port) notify.startup_notify(cfg.CONF.onready) diff --git a/contrib/heat_keystoneclient_v2/heat_keystoneclient_v2/client.py b/contrib/heat_keystoneclient_v2/heat_keystoneclient_v2/client.py index b73373406d..b1981bd1e2 100644 --- a/contrib/heat_keystoneclient_v2/heat_keystoneclient_v2/client.py +++ b/contrib/heat_keystoneclient_v2/heat_keystoneclient_v2/client.py @@ -109,8 +109,8 @@ class KeystoneClientV2(object): # Ensure the v2 API we're using is not impacted by keystone # bug #1239303, otherwise we can't trust the user_id if self.context.trustor_user_id != client.auth_ref.user_id: - LOG.error("Trust impersonation failed, bug #1239303 " - "suspected, you may need a newer keystone") + LOG.error(_("Trust impersonation failed, bug #1239303 " + "suspected, you may need a newer keystone")) raise exception.AuthorizationFailure() return client diff --git a/contrib/nova_flavor/nova_flavor/resources/nova_flavor.py b/contrib/nova_flavor/nova_flavor/resources/nova_flavor.py index 67bf8b513f..5d893fa6eb 100644 --- a/contrib/nova_flavor/nova_flavor/resources/nova_flavor.py +++ b/contrib/nova_flavor/nova_flavor/resources/nova_flavor.py @@ -103,7 +103,7 @@ class NovaFlavor(resource.Resource): self.nova().flavors.delete(self.resource_id) except nova_exceptions.NotFound: LOG.debug( - _('Could not find flavor %s.') % self.resource_id) + 'Could not find flavor %s.' % self.resource_id) self.resource_id_set(None) diff --git a/heat/api/cfn/v1/stacks.py b/heat/api/cfn/v1/stacks.py index 6861fae843..c4e1f59ea6 100644 --- a/heat/api/cfn/v1/stacks.py +++ b/heat/api/cfn/v1/stacks.py @@ -421,7 +421,7 @@ class StackController(object): msg = _("The Template must be a JSON or YAML document.") return exception.HeatInvalidParameterValueError(detail=msg) - LOG.info('validate_template') + LOG.info(_('validate_template')) def format_validate_parameter(key, value): """ diff --git a/heat/cloudinit/loguserdata.py b/heat/cloudinit/loguserdata.py index 2781976293..66d8c140b0 100755 --- a/heat/cloudinit/loguserdata.py +++ b/heat/cloudinit/loguserdata.py @@ -46,7 +46,7 @@ def call(args): def write(self, data): LOG.info(data) - LOG.info('%s\n' % ' '.join(args)) + LOG.info('%s\n', ' '.join(args)) # noqa try: ls = LogStream() p = subprocess.Popen(args, stdout=subprocess.PIPE, @@ -57,13 +57,13 @@ def call(args): ls.write(x) except OSError as ex: if ex.errno == errno.ENOEXEC: - LOG.error('Userdata empty or not executable: %s\n' % str(ex)) + LOG.error(_('Userdata empty or not executable: %s'), ex) return os.EX_OK else: - LOG.error('OS error running userdata: %s\n' % str(ex)) + LOG.error(_('OS error running userdata: %s'), ex) return os.EX_OSERR except Exception as ex: - LOG.error('Unknown error running userdata: %s\n' % str(ex)) + LOG.error(_('Unknown error running userdata: %s'), ex) return os.EX_SOFTWARE return p.returncode @@ -72,16 +72,16 @@ def main(): if not chk_ci_version(): # pre 0.6.0 - user data executed via cloudinit, not this helper - LOG.error('Unable to log provisioning, need a newer version of' - ' cloud-init\n') + LOG.error(_('Unable to log provisioning, need a newer version of' + ' cloud-init')) return -1 userdata_path = os.path.join(VAR_PATH, 'cfn-userdata') os.chmod(userdata_path, 0o700) - LOG.info('Provision began: %s\n' % datetime.datetime.now()) + LOG.info(_('Provision began: %s'), datetime.datetime.now()) returncode = call([userdata_path]) - LOG.info('Provision done: %s\n' % datetime.datetime.now()) + LOG.info(_('Provision done: %s'), datetime.datetime.now()) if returncode: return returncode @@ -91,7 +91,7 @@ if __name__ == '__main__': code = main() if code: - LOG.error('Provision failed with exit code %s' % code) + LOG.error(_('Provision failed with exit code %s'), code) sys.exit(code) provision_log = os.path.join(VAR_PATH, 'provision-finished') diff --git a/heat/common/exception.py b/heat/common/exception.py index 6a9016c9d9..2068d177ee 100644 --- a/heat/common/exception.py +++ b/heat/common/exception.py @@ -114,7 +114,7 @@ class HeatException(Exception): #log the issue and the kwargs LOG.exception(_('Exception in string format operation')) for name, value in kwargs.iteritems(): - LOG.error("%s: %s" % (name, value)) + LOG.error("%s: %s" % (name, value)) # noqa if _FATAL_EXCEPTION_FORMAT_ERRORS: raise exc_info[0], exc_info[1], exc_info[2] diff --git a/heat/common/heat_keystoneclient.py b/heat/common/heat_keystoneclient.py index 0299de046d..2371e5d231 100644 --- a/heat/common/heat_keystoneclient.py +++ b/heat/common/heat_keystoneclient.py @@ -119,7 +119,7 @@ class KeystoneClientV3(object): if c.authenticate(): self._admin_client = c else: - LOG.error("Admin client authentication failed") + LOG.error(_("Admin client authentication failed")) raise exception.AuthorizationFailure() return self._admin_client @@ -135,7 +135,7 @@ class KeystoneClientV3(object): if c.authenticate(domain_id=self.stack_domain_id): self._domain_admin_client = c else: - LOG.error("Domain admin client authentication failed") + LOG.error(_("Domain admin client authentication failed")) raise exception.AuthorizationFailure() return self._domain_admin_client @@ -178,7 +178,7 @@ class KeystoneClientV3(object): self.context.auth_url = kwargs.get('auth_url') # Sanity check that impersonation is effective if self.context.trustor_user_id != client.auth_ref.user_id: - LOG.error("Trust impersonation failed") + LOG.error(_("Trust impersonation failed")) raise exception.AuthorizationFailure() return client diff --git a/heat/engine/resource.py b/heat/engine/resource.py index 162bbebec6..410595c1b0 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -386,7 +386,7 @@ class Resource(object): while not check(handle_data): yield except Exception as ex: - LOG.exception('%s : %s' % (action, str(self))) + LOG.exception('%s : %s' % (action, str(self))) # noqa failure = exception.ResourceFailure(ex, self, action) self.state_set(action, self.FAILED, six.text_type(failure)) raise failure @@ -420,7 +420,7 @@ class Resource(object): % str(self.state)) raise exception.ResourceFailure(exc, self, action) - LOG.info('creating %s' % str(self)) + LOG.info(_('creating %s') % str(self)) # Re-resolve the template, since if the resource Ref's # the StackId pseudo parameter, it will change after @@ -501,7 +501,7 @@ class Resource(object): exc = Exception(_('Resource update already requested')) raise exception.ResourceFailure(exc, self, action) - LOG.info('updating %s' % str(self)) + LOG.info(_('updating %s') % str(self)) try: self.updated_time = datetime.utcnow() diff --git a/heat/engine/resources/software_config/software_config.py b/heat/engine/resources/software_config/software_config.py index f8a5bfe7de..22224a418f 100644 --- a/heat/engine/resources/software_config/software_config.py +++ b/heat/engine/resources/software_config/software_config.py @@ -168,7 +168,7 @@ class SoftwareConfig(resource.Resource): self.heat().software_configs.delete(self.resource_id) except heat_exp.HTTPNotFound: LOG.debug( - _('Software config %s is not found.') % self.resource_id) + 'Software config %s is not found.' % self.resource_id) def _resolve_attribute(self, name): '''