]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Make neutron-debug command follow cliff command convention
authorAkihiro Motoki <motoki@da.jp.nec.com>
Fri, 8 Jan 2016 18:35:05 +0000 (03:35 +0900)
committerAkihiro Motoki <motoki@da.jp.nec.com>
Fri, 8 Jan 2016 18:38:19 +0000 (03:38 +0900)
In the guideline of cliff command, developers implementing
commands should override take_action() rather than run().
The similar effort is being done in neutronclient side and
this fix is required to complete the effort.

Logger definition in each command class is no longer needed.
This commit also drops them.

Closes-Bug: #1532258
Change-Id: I613b7e18b3c058568fc3669ad1524e60a93eb9f8

neutron/debug/commands.py

index bb77b58f896d7566dab49aa7f68bd29ebf7775b7..7caa353bf2d7d6836e9a23c7a447d39ad7cbe1d9 100644 (file)
@@ -17,27 +17,19 @@ from cliff import lister
 from neutronclient.common import utils
 from neutronclient.neutron import v2_0 as client
 from neutronclient.neutron.v2_0 import port
-from oslo_log import log as logging
 
 from neutron._i18n import _, _LI
 
 
 class ProbeCommand(client.NeutronCommand):
-    log = logging.getLogger(__name__ + '.ProbeCommand')
 
     def get_debug_agent(self):
         return self.app.debug_agent
 
-    def run(self, parsed_args):
-        self.log.debug('run(%s)', parsed_args)
-        self.log.info(_('Unimplemented commands'))
-
 
 class CreateProbe(ProbeCommand):
     """Create probe port and interface, then plug it in."""
 
-    log = logging.getLogger(__name__ + '.CreateProbe')
-
     def get_parser(self, prog_name):
         parser = super(CreateProbe, self).get_parser(prog_name)
         parser.add_argument(
@@ -49,8 +41,7 @@ class CreateProbe(ProbeCommand):
             help=_('Owner type of the device: network/compute'))
         return parser
 
-    def run(self, parsed_args):
-        self.log.debug('run(%s)', parsed_args)
+    def take_action(self, parsed_args):
         debug_agent = self.get_debug_agent()
         probe_port = debug_agent.create_probe(parsed_args.id,
                                               parsed_args.device_owner)
@@ -60,8 +51,6 @@ class CreateProbe(ProbeCommand):
 class DeleteProbe(ProbeCommand):
     """Delete probe - delete port then uplug."""
 
-    log = logging.getLogger(__name__ + '.DeleteProbe')
-
     def get_parser(self, prog_name):
         parser = super(DeleteProbe, self).get_parser(prog_name)
         parser.add_argument(
@@ -69,24 +58,18 @@ class DeleteProbe(ProbeCommand):
             help=_('ID of probe port to delete'))
         return parser
 
-    def run(self, parsed_args):
-        self.log.debug('run(%s)', parsed_args)
+    def take_action(self, parsed_args):
         debug_agent = self.get_debug_agent()
         debug_agent.delete_probe(parsed_args.id)
         self.log.info(_('Probe %s deleted'), parsed_args.id)
 
 
-class ListProbe(client.NeutronCommand, lister.Lister):
+class ListProbe(ProbeCommand, lister.Lister):
     """List probes."""
 
-    log = logging.getLogger(__name__ + '.ListProbe')
     _formatters = {'fixed_ips': port._format_fixed_ips, }
 
-    def get_debug_agent(self):
-        return self.app.debug_agent
-
-    def get_data(self, parsed_args):
-
+    def take_action(self, parsed_args):
         debug_agent = self.get_debug_agent()
         info = debug_agent.list_probes()
         columns = sorted(info[0].keys()) if info else []
@@ -98,10 +81,7 @@ class ListProbe(client.NeutronCommand, lister.Lister):
 class ClearProbe(ProbeCommand):
     """Clear All probes."""
 
-    log = logging.getLogger(__name__ + '.ClearProbe')
-
-    def run(self, parsed_args):
-        self.log.debug('run(%s)', parsed_args)
+    def take_action(self, parsed_args):
         debug_agent = self.get_debug_agent()
         cleared_probes_count = debug_agent.clear_probes()
         self.log.info(_LI('%d probe(s) deleted'), cleared_probes_count)
@@ -110,8 +90,6 @@ class ClearProbe(ProbeCommand):
 class ExecProbe(ProbeCommand):
     """Exec commands on the namespace of the probe."""
 
-    log = logging.getLogger(__name__ + '.ExecProbe')
-
     def get_parser(self, prog_name):
         parser = super(ExecProbe, self).get_parser(prog_name)
         parser.add_argument(
@@ -124,8 +102,7 @@ class ExecProbe(ProbeCommand):
             help=_('Command to execute'))
         return parser
 
-    def run(self, parsed_args):
-        self.log.debug('run(%s)', parsed_args)
+    def take_action(self, parsed_args):
         debug_agent = self.get_debug_agent()
         result = debug_agent.exec_command(parsed_args.id, parsed_args.command)
         self.app.stdout.write(result + '\n')
@@ -134,8 +111,6 @@ class ExecProbe(ProbeCommand):
 class PingAll(ProbeCommand):
     """Ping all fixed_ip."""
 
-    log = logging.getLogger(__name__ + '.ExecProbe')
-
     def get_parser(self, prog_name):
         parser = super(PingAll, self).get_parser(prog_name)
         parser.add_argument(
@@ -148,8 +123,7 @@ class PingAll(ProbeCommand):
             help=_('ID of network'))
         return parser
 
-    def run(self, parsed_args):
-        self.log.debug('run(%s)', parsed_args)
+    def take_action(self, parsed_args):
         debug_agent = self.get_debug_agent()
         result = debug_agent.ping_all(parsed_args.id,
                                       timeout=parsed_args.timeout)