diff options
| author | Akihiro Motoki <motoki@da.jp.nec.com> | 2016-01-10 21:54:53 +0900 |
|---|---|---|
| committer | Akihiro Motoki <motoki@da.jp.nec.com> | 2016-02-02 09:58:32 +0900 |
| commit | 258c1102cc6b93a860bcd7cc083d4e14ae0025ce (patch) | |
| tree | 6b963e16d6bd946c066a7163f6f36e7becba9b3b /openstackclient/compute/v2/security_group.py | |
| parent | e9ff42eee73de147339c42bca90f777a8f40f5c1 (diff) | |
| download | python-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/compute/v2/security_group.py')
| -rw-r--r-- | openstackclient/compute/v2/security_group.py | 46 |
1 files changed, 7 insertions, 39 deletions
diff --git a/openstackclient/compute/v2/security_group.py b/openstackclient/compute/v2/security_group.py index 6395e102..b975a505 100644 --- a/openstackclient/compute/v2/security_group.py +++ b/openstackclient/compute/v2/security_group.py @@ -16,13 +16,8 @@ """Compute v2 Security Group action implementations""" -import logging import six -from cliff import command -from cliff import lister -from cliff import show - from keystoneauth1 import exceptions as ks_exc try: @@ -30,6 +25,7 @@ try: except ImportError: from novaclient.v1_1 import security_group_rules +from openstackclient.common import command from openstackclient.common import parseractions from openstackclient.common import utils @@ -79,11 +75,9 @@ def _xform_and_trim_security_group_rule(sgroup): return info -class CreateSecurityGroup(show.ShowOne): +class CreateSecurityGroup(command.ShowOne): """Create a new security group""" - log = logging.getLogger(__name__ + ".CreateSecurityGroup") - def get_parser(self, prog_name): parser = super(CreateSecurityGroup, self).get_parser(prog_name) parser.add_argument( @@ -99,8 +93,6 @@ class CreateSecurityGroup(show.ShowOne): return parser def take_action(self, parsed_args): - self.log.debug("take_action(%s)", parsed_args) - compute_client = self.app.client_manager.compute description = parsed_args.description or parsed_args.name @@ -115,11 +107,9 @@ class CreateSecurityGroup(show.ShowOne): return zip(*sorted(six.iteritems(info))) -class CreateSecurityGroupRule(show.ShowOne): +class CreateSecurityGroupRule(command.ShowOne): """Create a new security group rule""" - log = logging.getLogger(__name__ + ".CreateSecurityGroupRule") - def get_parser(self, prog_name): parser = super(CreateSecurityGroupRule, self).get_parser(prog_name) parser.add_argument( @@ -157,8 +147,6 @@ class CreateSecurityGroupRule(show.ShowOne): return parser def take_action(self, parsed_args): - self.log.debug("take_action(%s)", parsed_args) - compute_client = self.app.client_manager.compute group = utils.find_resource( compute_client.security_groups, @@ -184,8 +172,6 @@ class CreateSecurityGroupRule(show.ShowOne): class DeleteSecurityGroup(command.Command): """Delete a security group""" - log = logging.getLogger(__name__ + '.DeleteSecurityGroup') - def get_parser(self, prog_name): parser = super(DeleteSecurityGroup, self).get_parser(prog_name) parser.add_argument( @@ -195,7 +181,6 @@ class DeleteSecurityGroup(command.Command): ) return parser - @utils.log_method(log) def take_action(self, parsed_args): compute_client = self.app.client_manager.compute @@ -209,8 +194,6 @@ class DeleteSecurityGroup(command.Command): class DeleteSecurityGroupRule(command.Command): """Delete a security group rule""" - log = logging.getLogger(__name__ + '.DeleteSecurityGroupRule') - def get_parser(self, prog_name): parser = super(DeleteSecurityGroupRule, self).get_parser(prog_name) parser.add_argument( @@ -220,18 +203,15 @@ class DeleteSecurityGroupRule(command.Command): ) return parser - @utils.log_method(log) def take_action(self, parsed_args): compute_client = self.app.client_manager.compute compute_client.security_group_rules.delete(parsed_args.rule) -class ListSecurityGroup(lister.Lister): +class ListSecurityGroup(command.Lister): """List security groups""" - log = logging.getLogger(__name__ + ".ListSecurityGroup") - def get_parser(self, prog_name): parser = super(ListSecurityGroup, self).get_parser(prog_name) parser.add_argument( @@ -250,8 +230,6 @@ class ListSecurityGroup(lister.Lister): except KeyError: return project_id - self.log.debug("take_action(%s)", parsed_args) - compute_client = self.app.client_manager.compute columns = ( "ID", @@ -283,11 +261,9 @@ class ListSecurityGroup(lister.Lister): ) for s in data)) -class ListSecurityGroupRule(lister.Lister): +class ListSecurityGroupRule(command.Lister): """List security group rules""" - log = logging.getLogger(__name__ + ".ListSecurityGroupRule") - def get_parser(self, prog_name): parser = super(ListSecurityGroupRule, self).get_parser(prog_name) parser.add_argument( @@ -299,8 +275,6 @@ class ListSecurityGroupRule(lister.Lister): return parser def take_action(self, parsed_args): - self.log.debug("take_action(%s)", parsed_args) - compute_client = self.app.client_manager.compute columns = column_headers = ( "ID", @@ -337,11 +311,9 @@ class ListSecurityGroupRule(lister.Lister): ) for s in rules)) -class SetSecurityGroup(show.ShowOne): +class SetSecurityGroup(command.ShowOne): """Set security group properties""" - log = logging.getLogger(__name__ + '.SetSecurityGroup') - def get_parser(self, prog_name): parser = super(SetSecurityGroup, self).get_parser(prog_name) parser.add_argument( @@ -361,7 +333,6 @@ class SetSecurityGroup(show.ShowOne): ) return parser - @utils.log_method(log) def take_action(self, parsed_args): compute_client = self.app.client_manager.compute @@ -388,11 +359,9 @@ class SetSecurityGroup(show.ShowOne): return ({}, {}) -class ShowSecurityGroup(show.ShowOne): +class ShowSecurityGroup(command.ShowOne): """Display security group details""" - log = logging.getLogger(__name__ + '.ShowSecurityGroup') - def get_parser(self, prog_name): parser = super(ShowSecurityGroup, self).get_parser(prog_name) parser.add_argument( @@ -402,7 +371,6 @@ class ShowSecurityGroup(show.ShowOne): ) return parser - @utils.log_method(log) def take_action(self, parsed_args): compute_client = self.app.client_manager.compute |
