Skip to content

Commit 258c110

Browse files
author
Akihiro Motoki
committed
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
1 parent e9ff42e commit 258c110

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+242
-1391
lines changed

openstackclient/common/availability_zone.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
"""Availability Zone action implementations"""
1515

1616
import copy
17-
import logging
1817

19-
from cliff import lister
2018
from novaclient import exceptions as nova_exceptions
2119
import six
2220

21+
from openstackclient.common import command
2322
from openstackclient.common import utils
2423
from openstackclient.i18n import _ # noqa
2524

@@ -70,11 +69,9 @@ def _xform_volume_availability_zone(az):
7069
return result
7170

7271

73-
class ListAvailabilityZone(lister.Lister):
72+
class ListAvailabilityZone(command.Lister):
7473
"""List availability zones and their status"""
7574

76-
log = logging.getLogger(__name__ + '.ListAvailabilityZone')
77-
7875
def get_parser(self, prog_name):
7976
parser = super(ListAvailabilityZone, self).get_parser(prog_name)
8077
parser.add_argument(
@@ -125,7 +122,6 @@ def get_volume_availability_zones(self, parsed_args):
125122
result += _xform_volume_availability_zone(zone)
126123
return result
127124

128-
@utils.log_method(log)
129125
def take_action(self, parsed_args):
130126

131127
if parsed_args.long:

openstackclient/common/command.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,10 @@ def __new__(mcs, name, bases, cls_dict):
3131

3232
@six.add_metaclass(CommandMeta)
3333
class Command(command.Command):
34-
pass
34+
35+
def run(self, parsed_args):
36+
self.log.debug('run(%s)', parsed_args)
37+
return super(Command, self).run(parsed_args)
3538

3639

3740
class Lister(Command, lister.Lister):

openstackclient/common/configuration.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,16 @@
1313

1414
"""Configuration action implementations"""
1515

16-
import logging
17-
18-
from cliff import show
1916
import six
2017

21-
from openstackclient.common import utils
18+
from openstackclient.common import command
2219

2320
REDACTED = "<redacted>"
2421

2522

26-
class ShowConfiguration(show.ShowOne):
23+
class ShowConfiguration(command.ShowOne):
2724
"""Display configuration details"""
2825

29-
log = logging.getLogger(__name__ + '.ShowConfiguration')
30-
3126
def get_parser(self, prog_name):
3227
parser = super(ShowConfiguration, self).get_parser(prog_name)
3328
mask_group = parser.add_mutually_exclusive_group()
@@ -46,7 +41,6 @@ def get_parser(self, prog_name):
4641
)
4742
return parser
4843

49-
@utils.log_method(log)
5044
def take_action(self, parsed_args):
5145

5246
info = self.app.client_manager.get_configuration()

openstackclient/common/extension.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,14 @@
1616
"""Extension action implementations"""
1717

1818
import itertools
19-
import logging
20-
21-
from cliff import lister
2219

20+
from openstackclient.common import command
2321
from openstackclient.common import utils
2422

2523

26-
class ListExtension(lister.Lister):
24+
class ListExtension(command.Lister):
2725
"""List API extensions"""
2826

29-
log = logging.getLogger(__name__ + '.ListExtension')
30-
3127
def get_parser(self, prog_name):
3228
parser = super(ListExtension, self).get_parser(prog_name)
3329
parser.add_argument(
@@ -58,8 +54,6 @@ def get_parser(self, prog_name):
5854
return parser
5955

6056
def take_action(self, parsed_args):
61-
self.log.debug('take_action(%s)' % parsed_args)
62-
6357
if parsed_args.long:
6458
columns = ('Name', 'Namespace', 'Description',
6559
'Alias', 'Updated', 'Links')

openstackclient/common/limits.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,15 @@
1616
"""Limits Action Implementation"""
1717

1818
import itertools
19-
import logging
20-
21-
from cliff import lister
2219

20+
from openstackclient.common import command
2321
from openstackclient.common import utils
2422
from openstackclient.identity import common as identity_common
2523

2624

27-
class ShowLimits(lister.Lister):
25+
class ShowLimits(command.Lister):
2826
"""Show compute and block storage limits"""
2927

30-
log = logging.getLogger(__name__ + '.ShowLimits')
31-
3228
def get_parser(self, prog_name):
3329
parser = super(ShowLimits, self).get_parser(prog_name)
3430
type_group = parser.add_mutually_exclusive_group(required=True)
@@ -64,7 +60,6 @@ def get_parser(self, prog_name):
6460
)
6561
return parser
6662

67-
@utils.log_method(log)
6863
def take_action(self, parsed_args):
6964

7065
compute_client = self.app.client_manager.compute

openstackclient/common/module.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,17 @@
1515

1616
"""Module action implementation"""
1717

18-
import logging
1918
import six
2019
import sys
2120

22-
from cliff import lister
23-
from cliff import show
21+
from openstackclient.common import command
2422

25-
from openstackclient.common import utils
2623

27-
28-
class ListCommand(lister.Lister):
24+
class ListCommand(command.Lister):
2925
"""List recognized commands by group"""
3026

3127
auth_required = False
32-
log = logging.getLogger(__name__ + '.ListCommand')
3328

34-
@utils.log_method(log)
3529
def take_action(self, parsed_args):
3630
cm = self.app.command_manager
3731
groups = cm.get_command_groups()
@@ -40,11 +34,10 @@ def take_action(self, parsed_args):
4034
return (columns, ((c, cm.get_command_names(group=c)) for c in groups))
4135

4236

43-
class ListModule(show.ShowOne):
37+
class ListModule(command.ShowOne):
4438
"""List module versions"""
4539

4640
auth_required = False
47-
log = logging.getLogger(__name__ + '.ListModule')
4841

4942
def get_parser(self, prog_name):
5043
parser = super(ListModule, self).get_parser(prog_name)
@@ -56,7 +49,6 @@ def get_parser(self, prog_name):
5649
)
5750
return parser
5851

59-
@utils.log_method(log)
6052
def take_action(self, parsed_args):
6153

6254
data = {}

openstackclient/common/quota.py

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,10 @@
1616
"""Quota action implementations"""
1717

1818
import itertools
19-
import logging
2019
import six
2120
import sys
2221

23-
from cliff import command
24-
from cliff import show
25-
22+
from openstackclient.common import command
2623
from openstackclient.common import utils
2724

2825

@@ -60,8 +57,6 @@
6057
class SetQuota(command.Command):
6158
"""Set quotas for project or class"""
6259

63-
log = logging.getLogger(__name__ + '.SetQuota')
64-
6560
def get_parser(self, prog_name):
6661
parser = super(SetQuota, self).get_parser(prog_name)
6762
parser.add_argument(
@@ -92,7 +87,6 @@ def get_parser(self, prog_name):
9287
)
9388
return parser
9489

95-
@utils.log_method(log)
9690
def take_action(self, parsed_args):
9791

9892
identity_client = self.app.client_manager.identity
@@ -143,11 +137,9 @@ def take_action(self, parsed_args):
143137
**volume_kwargs)
144138

145139

146-
class ShowQuota(show.ShowOne):
140+
class ShowQuota(command.ShowOne):
147141
"""Show quotas for project or class"""
148142

149-
log = logging.getLogger(__name__ + '.ShowQuota')
150-
151143
def get_parser(self, prog_name):
152144
parser = super(ShowQuota, self).get_parser(prog_name)
153145
parser.add_argument(
@@ -203,7 +195,6 @@ def get_network_quota(self, parsed_args):
203195
else:
204196
return {}
205197

206-
@utils.log_method(log)
207198
def take_action(self, parsed_args):
208199

209200
compute_client = self.app.client_manager.compute

openstackclient/common/timing.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,13 @@
1313

1414
"""Timing Implementation"""
1515

16-
import logging
16+
from openstackclient.common import command
1717

18-
from cliff import lister
1918

20-
21-
class Timing(lister.Lister):
19+
class Timing(command.Lister):
2220
"""Show timing data"""
2321

24-
log = logging.getLogger(__name__ + '.Timing')
25-
2622
def take_action(self, parsed_args):
27-
self.log.debug('take_action(%s)' % parsed_args)
28-
2923
column_headers = (
3024
'URL',
3125
'Seconds',

openstackclient/compute/v2/agent.py

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,15 @@
1515

1616
"""Agent action implementations"""
1717

18-
import logging
1918
import six
2019

21-
from cliff import command
22-
from cliff import lister
23-
from cliff import show
24-
20+
from openstackclient.common import command
2521
from openstackclient.common import utils
2622

2723

28-
class CreateAgent(show.ShowOne):
24+
class CreateAgent(command.ShowOne):
2925
"""Create compute agent command"""
3026

31-
log = logging.getLogger(__name__ + ".CreateAgent")
32-
3327
def get_parser(self, prog_name):
3428
parser = super(CreateAgent, self).get_parser(prog_name)
3529
parser.add_argument(
@@ -60,7 +54,6 @@ def get_parser(self, prog_name):
6054
return parser
6155

6256
def take_action(self, parsed_args):
63-
self.log.debug("take_action(%s)", parsed_args)
6457
compute_client = self.app.client_manager.compute
6558
args = (
6659
parsed_args.os,
@@ -77,8 +70,6 @@ def take_action(self, parsed_args):
7770
class DeleteAgent(command.Command):
7871
"""Delete compute agent command"""
7972

80-
log = logging.getLogger(__name__ + ".DeleteAgent")
81-
8273
def get_parser(self, prog_name):
8374
parser = super(DeleteAgent, self).get_parser(prog_name)
8475
parser.add_argument(
@@ -88,16 +79,13 @@ def get_parser(self, prog_name):
8879
return parser
8980

9081
def take_action(self, parsed_args):
91-
self.log.debug("take_action(%s)", parsed_args)
9282
compute_client = self.app.client_manager.compute
9383
compute_client.agents.delete(parsed_args.id)
9484

9585

96-
class ListAgent(lister.Lister):
86+
class ListAgent(command.Lister):
9787
"""List compute agent command"""
9888

99-
log = logging.getLogger(__name__ + ".ListAgent")
100-
10189
def get_parser(self, prog_name):
10290
parser = super(ListAgent, self).get_parser(prog_name)
10391
parser.add_argument(
@@ -107,7 +95,6 @@ def get_parser(self, prog_name):
10795
return parser
10896

10997
def take_action(self, parsed_args):
110-
self.log.debug("take_action(%s)", parsed_args)
11198
compute_client = self.app.client_manager.compute
11299
columns = (
113100
"Agent ID",
@@ -125,11 +112,9 @@ def take_action(self, parsed_args):
125112
) for s in data))
126113

127114

128-
class SetAgent(show.ShowOne):
115+
class SetAgent(command.ShowOne):
129116
"""Set compute agent command"""
130117

131-
log = logging.getLogger(__name__ + ".SetAgent")
132-
133118
def get_parser(self, prog_name):
134119
parser = super(SetAgent, self).get_parser(prog_name)
135120
parser.add_argument(
@@ -151,7 +136,6 @@ def get_parser(self, prog_name):
151136
return parser
152137

153138
def take_action(self, parsed_args):
154-
self.log.debug("take_action(%s)", parsed_args)
155139
compute_client = self.app.client_manager.compute
156140
args = (
157141
parsed_args.id,

0 commit comments

Comments
 (0)