summaryrefslogtreecommitdiff
path: root/openstackclient/compute/v2/flavor.py
diff options
context:
space:
mode:
authorTang Chen <chen.tang@easystack.cn>2016-06-16 20:01:15 +0800
committerSteve Martinelli <s.martinelli@gmail.com>2016-06-20 15:16:51 +0000
commit047cb6849354f4fdf8d365bd109a0ed56a77d200 (patch)
treedc7372f6e90946e82606c2f1a1d974bd02879201 /openstackclient/compute/v2/flavor.py
parentba825a4d5c04e2e6fd8a82ebbfb2f71a85e683aa (diff)
downloadpython-openstackclient-047cb6849354f4fdf8d365bd109a0ed56a77d200.tar.gz
Standardize logger usage
Use file logger for all command specific logs. This patch also fixes some usage that doesn't follow rules in: http://docs.openstack.org/developer/oslo.i18n/guidelines.html After this patch, all self.log and self.app.log will be standardized to LOG(). NOTE: In shell.py, we got the log in class OpenStackShell, which is also known as self.app.log in other classes. This logger is used to record non-command-specific logs. So we leave it as-is. Change-Id: I114f73ee6c7e84593d71e724bc1ad00d343c1896 Implements: blueprint log-usage
Diffstat (limited to 'openstackclient/compute/v2/flavor.py')
-rw-r--r--openstackclient/compute/v2/flavor.py22
1 files changed, 12 insertions, 10 deletions
diff --git a/openstackclient/compute/v2/flavor.py b/openstackclient/compute/v2/flavor.py
index ab2bc85d..0a0d25c2 100644
--- a/openstackclient/compute/v2/flavor.py
+++ b/openstackclient/compute/v2/flavor.py
@@ -15,6 +15,8 @@
"""Flavor action implementations"""
+import logging
+
from osc_lib.cli import parseractions
from osc_lib.command import command
from osc_lib import exceptions
@@ -25,6 +27,9 @@ from openstackclient.i18n import _
from openstackclient.identity import common as identity_common
+LOG = logging.getLogger(__name__)
+
+
def _find_flavor(compute_client, flavor):
try:
return compute_client.flavors.get(flavor)
@@ -282,8 +287,7 @@ class SetFlavor(command.Command):
try:
flavor.set_keys(parsed_args.property)
except Exception as e:
- self.app.log.error(
- _("Failed to set flavor property: %s") % str(e))
+ LOG.error(_("Failed to set flavor property: %s"), e)
result += 1
if parsed_args.project:
@@ -300,13 +304,12 @@ class SetFlavor(command.Command):
compute_client.flavor_access.add_tenant_access(
flavor.id, project_id)
except Exception as e:
- self.app.log.error(_("Failed to set flavor access to"
- " project: %s") % str(e))
+ LOG.error(_("Failed to set flavor access to project: %s"), e)
result += 1
if result > 0:
raise exceptions.CommandError(_("Command Failed: One or more of"
- " the operations failed"))
+ " the operations failed"))
class ShowFlavor(command.ShowOne):
@@ -373,8 +376,7 @@ class UnsetFlavor(command.Command):
try:
flavor.unset_keys(parsed_args.property)
except Exception as e:
- self.app.log.error(
- _("Failed to unset flavor property: %s") % str(e))
+ LOG.error(_("Failed to unset flavor property: %s"), e)
result += 1
if parsed_args.project:
@@ -391,10 +393,10 @@ class UnsetFlavor(command.Command):
compute_client.flavor_access.remove_tenant_access(
flavor.id, project_id)
except Exception as e:
- self.app.log.error(_("Failed to remove flavor access from"
- " project: %s") % str(e))
+ LOG.error(_("Failed to remove flavor access from project: %s"),
+ e)
result += 1
if result > 0:
raise exceptions.CommandError(_("Command Failed: One or more of"
- " the operations failed"))
+ " the operations failed"))