From 1c91e9828d64c927cc28d9de61dd56887ca59dff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A1bor=20Antal?= Date: Mon, 13 Feb 2017 18:41:24 +0100 Subject: [PATCH] Handle log message interpolation by the logger in compute/ According to OpenStack Guideline[1], logged string message should be interpolated by the logger. [1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages Change-Id: Ib7b5fb5f794026fc8a84260c4803afea321a9cf5 Closes-Bug: #1596829 --- openstackclient/compute/v2/aggregate.py | 4 ++-- openstackclient/compute/v2/flavor.py | 7 +++---- openstackclient/compute/v2/keypair.py | 3 +-- openstackclient/compute/v2/service.py | 3 +-- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/openstackclient/compute/v2/aggregate.py b/openstackclient/compute/v2/aggregate.py index 76ba5cc662..7f9161a996 100644 --- a/openstackclient/compute/v2/aggregate.py +++ b/openstackclient/compute/v2/aggregate.py @@ -128,8 +128,8 @@ class DeleteAggregate(command.Command): except Exception as e: result += 1 LOG.error(_("Failed to delete aggregate with name or " - "ID '%(aggregate)s': %(e)s") - % {'aggregate': a, 'e': e}) + "ID '%(aggregate)s': %(e)s"), + {'aggregate': a, 'e': e}) if result > 0: total = len(parsed_args.aggregate) diff --git a/openstackclient/compute/v2/flavor.py b/openstackclient/compute/v2/flavor.py index 7cd22ed7a9..aa8cd19116 100644 --- a/openstackclient/compute/v2/flavor.py +++ b/openstackclient/compute/v2/flavor.py @@ -171,7 +171,7 @@ class CreateFlavor(command.ShowOne): except Exception as e: msg = _("Failed to add project %(project)s access to " "flavor: %(e)s") - LOG.error(msg % {'project': parsed_args.project, 'e': e}) + LOG.error(msg, {'project': parsed_args.project, 'e': e}) if parsed_args.property: try: flavor.set_keys(parsed_args.property) @@ -208,8 +208,7 @@ class DeleteFlavor(command.Command): except Exception as e: result += 1 LOG.error(_("Failed to delete flavor with name or " - "ID '%(flavor)s': %(e)s") - % {'flavor': f, 'e': e}) + "ID '%(flavor)s': %(e)s"), {'flavor': f, 'e': e}) if result > 0: total = len(parsed_args.flavor) @@ -395,7 +394,7 @@ class ShowFlavor(command.ShowOne): except Exception as e: msg = _("Failed to get access projects list " "for flavor '%(flavor)s': %(e)s") - LOG.error(msg % {'flavor': parsed_args.flavor, 'e': e}) + LOG.error(msg, {'flavor': parsed_args.flavor, 'e': e}) flavor = resource_flavor._info.copy() flavor.update({ diff --git a/openstackclient/compute/v2/keypair.py b/openstackclient/compute/v2/keypair.py index a63cbfecc0..2a8524d62b 100644 --- a/openstackclient/compute/v2/keypair.py +++ b/openstackclient/compute/v2/keypair.py @@ -106,8 +106,7 @@ class DeleteKeypair(command.Command): except Exception as e: result += 1 LOG.error(_("Failed to delete key with name " - "'%(name)s': %(e)s") - % {'name': n, 'e': e}) + "'%(name)s': %(e)s"), {'name': n, 'e': e}) if result > 0: total = len(parsed_args.name) diff --git a/openstackclient/compute/v2/service.py b/openstackclient/compute/v2/service.py index 9c384f0589..7b18c2e505 100644 --- a/openstackclient/compute/v2/service.py +++ b/openstackclient/compute/v2/service.py @@ -50,8 +50,7 @@ class DeleteService(command.Command): except Exception as e: result += 1 LOG.error(_("Failed to delete compute service with " - "ID '%(service)s': %(e)s") - % {'service': s, 'e': e}) + "ID '%(service)s': %(e)s"), {'service': s, 'e': e}) if result > 0: total = len(parsed_args.service)