[spp] [PATCH 06/10] controller: move pcap help msg to SppPcap

yasufum.o at gmail.com yasufum.o at gmail.com
Mon Jun 24 09:11:20 CEST 2019


From: Yasufumi Ogawa <yasufum.o at gmail.com>

This patch is to move comment of `do_pcap` to `SppPcap.help` to
reduce the number of lines.

Signed-off-by: Yasufumi Ogawa <yasufum.o at gmail.com>
---
 src/controller/commands/pcap.py | 24 ++++++++++++++++++++++++
 src/controller/shell.py         | 24 +++++-------------------
 2 files changed, 29 insertions(+), 19 deletions(-)

diff --git a/src/controller/commands/pcap.py b/src/controller/commands/pcap.py
index 88dd5c8..f2e1ffa 100644
--- a/src/controller/commands/pcap.py
+++ b/src/controller/commands/pcap.py
@@ -239,3 +239,27 @@ class SppPcap(object):
                             status['core_ids'].append(wk['core'])
 
         return status
+
+    @classmethod
+    def help(cls):
+        msg = """Send a command to spp_pcap.
+
+        Spp_pcap is a secondary process for capturing incoming packets.
+
+        'start' for launching a worker is replaced with 'stop' for
+        terminating. 'exit' for spp_pcap terminating.
+
+        Examples:
+
+        # (1) show status of worker threads and resources
+        spp > pcap 1; status
+
+        # (2) launch or terminate capture thread
+        spp > pcap 1; start
+        spp > pcap 1; stop
+
+        # (3) terminate spp_pcap secondaryd
+        spp > pcap 1; exit
+        """
+
+        print(msg)
diff --git a/src/controller/shell.py b/src/controller/shell.py
index 2682376..52fe645 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -475,25 +475,7 @@ class Shell(cmd.Cmd, object):
                         self.get_sec_ids('mirror'), text, line, begidx, endidx)
 
     def do_pcap(self, cmd):
-        """Send a command to spp_pcap.
-
-        Spp_pcap is a secondary process for capturing incoming packets.
-
-        'start' for launching a worker is replaced with 'stop' for
-        terminating. 'exit' for spp_pcap terminating.
-
-        Examples:
-
-        # (1) show status of worker threads and resources
-        spp > pcap 1; status
-
-        # (2) launch or terminate capture thread
-        spp > pcap 1; start
-        spp > pcap 1; stop
-
-        # (3) terminate spp_pcap secondaryd
-        spp > pcap 1; exit
-        """
+        """Send a command to spp_pcap."""
 
         # remove unwanted spaces to avoid invalid command error
         tmparg = self.clean_cmd(cmd)
@@ -506,6 +488,10 @@ class Shell(cmd.Cmd, object):
         else:
             print('Invalid command: {}'.format(tmparg))
 
+    def help_pcap(self):
+        """Print help message of pcap command."""
+        pcap.SppPcap.help()
+
     def complete_pcap(self, text, line, begidx, endidx):
         """Completion for pcap command."""
 
-- 
2.17.1



More information about the spp mailing list