summaryrefslogtreecommitdiff
path: root/openstackclient/common
diff options
context:
space:
mode:
authorAkihiro Motoki <motoki@da.jp.nec.com>2016-01-10 21:54:53 +0900
committerAkihiro Motoki <motoki@da.jp.nec.com>2016-02-02 09:58:32 +0900
commit258c1102cc6b93a860bcd7cc083d4e14ae0025ce (patch)
tree6b963e16d6bd946c066a7163f6f36e7becba9b3b /openstackclient/common
parente9ff42eee73de147339c42bca90f777a8f40f5c1 (diff)
downloadpython-openstackclient-258c1102cc6b93a860bcd7cc083d4e14ae0025ce.tar.gz
log take_action parameters in a single place
Previously each command logs take_action parameters explicitly by using @utils.log_method decorator or log.debug(). Some commands have no logging. This commit calls a logger in the base class and drops all logging definition from individual commands. Closes-Bug: #1532294 Change-Id: I43cd0290a4353c68c075bade9571c940733da1be
Diffstat (limited to 'openstackclient/common')
-rw-r--r--openstackclient/common/availability_zone.py8
-rw-r--r--openstackclient/common/command.py5
-rw-r--r--openstackclient/common/configuration.py10
-rw-r--r--openstackclient/common/extension.py10
-rw-r--r--openstackclient/common/limits.py9
-rw-r--r--openstackclient/common/module.py14
-rw-r--r--openstackclient/common/quota.py13
-rw-r--r--openstackclient/common/timing.py10
8 files changed, 19 insertions, 60 deletions
diff --git a/openstackclient/common/availability_zone.py b/openstackclient/common/availability_zone.py
index e72732e7..fa5aee47 100644
--- a/openstackclient/common/availability_zone.py
+++ b/openstackclient/common/availability_zone.py
@@ -14,12 +14,11 @@
"""Availability Zone action implementations"""
import copy
-import logging
-from cliff import lister
from novaclient import exceptions as nova_exceptions
import six
+from openstackclient.common import command
from openstackclient.common import utils
from openstackclient.i18n import _ # noqa
@@ -70,11 +69,9 @@ def _xform_volume_availability_zone(az):
return result
-class ListAvailabilityZone(lister.Lister):
+class ListAvailabilityZone(command.Lister):
"""List availability zones and their status"""
- log = logging.getLogger(__name__ + '.ListAvailabilityZone')
-
def get_parser(self, prog_name):
parser = super(ListAvailabilityZone, self).get_parser(prog_name)
parser.add_argument(
@@ -125,7 +122,6 @@ class ListAvailabilityZone(lister.Lister):
result += _xform_volume_availability_zone(zone)
return result
- @utils.log_method(log)
def take_action(self, parsed_args):
if parsed_args.long:
diff --git a/openstackclient/common/command.py b/openstackclient/common/command.py
index b8d9fc6f..13b0bcc2 100644
--- a/openstackclient/common/command.py
+++ b/openstackclient/common/command.py
@@ -31,7 +31,10 @@ class CommandMeta(abc.ABCMeta):
@six.add_metaclass(CommandMeta)
class Command(command.Command):
- pass
+
+ def run(self, parsed_args):
+ self.log.debug('run(%s)', parsed_args)
+ return super(Command, self).run(parsed_args)
class Lister(Command, lister.Lister):
diff --git a/openstackclient/common/configuration.py b/openstackclient/common/configuration.py
index ac2792dd..a70e4d14 100644
--- a/openstackclient/common/configuration.py
+++ b/openstackclient/common/configuration.py
@@ -13,21 +13,16 @@
"""Configuration action implementations"""
-import logging
-
-from cliff import show
import six
-from openstackclient.common import utils
+from openstackclient.common import command
REDACTED = "<redacted>"
-class ShowConfiguration(show.ShowOne):
+class ShowConfiguration(command.ShowOne):
"""Display configuration details"""
- log = logging.getLogger(__name__ + '.ShowConfiguration')
-
def get_parser(self, prog_name):
parser = super(ShowConfiguration, self).get_parser(prog_name)
mask_group = parser.add_mutually_exclusive_group()
@@ -46,7 +41,6 @@ class ShowConfiguration(show.ShowOne):
)
return parser
- @utils.log_method(log)
def take_action(self, parsed_args):
info = self.app.client_manager.get_configuration()
diff --git a/openstackclient/common/extension.py b/openstackclient/common/extension.py
index d1ae208d..8b556b4c 100644
--- a/openstackclient/common/extension.py
+++ b/openstackclient/common/extension.py
@@ -16,18 +16,14 @@
"""Extension action implementations"""
import itertools
-import logging
-
-from cliff import lister
+from openstackclient.common import command
from openstackclient.common import utils
-class ListExtension(lister.Lister):
+class ListExtension(command.Lister):
"""List API extensions"""
- log = logging.getLogger(__name__ + '.ListExtension')
-
def get_parser(self, prog_name):
parser = super(ListExtension, self).get_parser(prog_name)
parser.add_argument(
@@ -58,8 +54,6 @@ class ListExtension(lister.Lister):
return parser
def take_action(self, parsed_args):
- self.log.debug('take_action(%s)' % parsed_args)
-
if parsed_args.long:
columns = ('Name', 'Namespace', 'Description',
'Alias', 'Updated', 'Links')
diff --git a/openstackclient/common/limits.py b/openstackclient/common/limits.py
index 57703670..bd546c01 100644
--- a/openstackclient/common/limits.py
+++ b/openstackclient/common/limits.py
@@ -16,19 +16,15 @@
"""Limits Action Implementation"""
import itertools
-import logging
-
-from cliff import lister
+from openstackclient.common import command
from openstackclient.common import utils
from openstackclient.identity import common as identity_common
-class ShowLimits(lister.Lister):
+class ShowLimits(command.Lister):
"""Show compute and block storage limits"""
- log = logging.getLogger(__name__ + '.ShowLimits')
-
def get_parser(self, prog_name):
parser = super(ShowLimits, self).get_parser(prog_name)
type_group = parser.add_mutually_exclusive_group(required=True)
@@ -64,7 +60,6 @@ class ShowLimits(lister.Lister):
)
return parser
- @utils.log_method(log)
def take_action(self, parsed_args):
compute_client = self.app.client_manager.compute
diff --git a/openstackclient/common/module.py b/openstackclient/common/module.py
index f0ed23b2..a3dea5da 100644
--- a/openstackclient/common/module.py
+++ b/openstackclient/common/module.py
@@ -15,23 +15,17 @@
"""Module action implementation"""
-import logging
import six
import sys
-from cliff import lister
-from cliff import show
+from openstackclient.common import command
-from openstackclient.common import utils
-
-class ListCommand(lister.Lister):
+class ListCommand(command.Lister):
"""List recognized commands by group"""
auth_required = False
- log = logging.getLogger(__name__ + '.ListCommand')
- @utils.log_method(log)
def take_action(self, parsed_args):
cm = self.app.command_manager
groups = cm.get_command_groups()
@@ -40,11 +34,10 @@ class ListCommand(lister.Lister):
return (columns, ((c, cm.get_command_names(group=c)) for c in groups))
-class ListModule(show.ShowOne):
+class ListModule(command.ShowOne):
"""List module versions"""
auth_required = False
- log = logging.getLogger(__name__ + '.ListModule')
def get_parser(self, prog_name):
parser = super(ListModule, self).get_parser(prog_name)
@@ -56,7 +49,6 @@ class ListModule(show.ShowOne):
)
return parser
- @utils.log_method(log)
def take_action(self, parsed_args):
data = {}
diff --git a/openstackclient/common/quota.py b/openstackclient/common/quota.py
index 8a9b910f..480abbd9 100644
--- a/openstackclient/common/quota.py
+++ b/openstackclient/common/quota.py
@@ -16,13 +16,10 @@
"""Quota action implementations"""
import itertools
-import logging
import six
import sys
-from cliff import command
-from cliff import show
-
+from openstackclient.common import command
from openstackclient.common import utils
@@ -60,8 +57,6 @@ NETWORK_QUOTAS = {
class SetQuota(command.Command):
"""Set quotas for project or class"""
- log = logging.getLogger(__name__ + '.SetQuota')
-
def get_parser(self, prog_name):
parser = super(SetQuota, self).get_parser(prog_name)
parser.add_argument(
@@ -92,7 +87,6 @@ class SetQuota(command.Command):
)
return parser
- @utils.log_method(log)
def take_action(self, parsed_args):
identity_client = self.app.client_manager.identity
@@ -143,11 +137,9 @@ class SetQuota(command.Command):
**volume_kwargs)
-class ShowQuota(show.ShowOne):
+class ShowQuota(command.ShowOne):
"""Show quotas for project or class"""
- log = logging.getLogger(__name__ + '.ShowQuota')
-
def get_parser(self, prog_name):
parser = super(ShowQuota, self).get_parser(prog_name)
parser.add_argument(
@@ -203,7 +195,6 @@ class ShowQuota(show.ShowOne):
else:
return {}
- @utils.log_method(log)
def take_action(self, parsed_args):
compute_client = self.app.client_manager.compute
diff --git a/openstackclient/common/timing.py b/openstackclient/common/timing.py
index d13c86e7..5f628759 100644
--- a/openstackclient/common/timing.py
+++ b/openstackclient/common/timing.py
@@ -13,19 +13,13 @@
"""Timing Implementation"""
-import logging
+from openstackclient.common import command
-from cliff import lister
-
-class Timing(lister.Lister):
+class Timing(command.Lister):
"""Show timing data"""
- log = logging.getLogger(__name__ + '.Timing')
-
def take_action(self, parsed_args):
- self.log.debug('take_action(%s)' % parsed_args)
-
column_headers = (
'URL',
'Seconds',