Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 1/2] controller: fix bug terminated if no sec ID found
Date: Thu, 21 Feb 2019 12:27:38 +0900	[thread overview]
Message-ID: <1550719659-14226-2-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1550719659-14226-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

SPP CLI is terminated if sec ID of process is not exist. For instance,
it is failed and terminated if you run `nfv 1; status` without launching
nfv 1.

This update is to add `_is_sec_registered()` to check sec process is
launched before.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/controller/shell.py | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)

diff --git a/src/controller/shell.py b/src/controller/shell.py
index 43ef991..2568523 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -214,11 +214,26 @@ class Shell(cmd.Cmd, object):
         res = re.sub(r'\s?;\s?', ";", tmparg)
         return res
 
+    def _is_sec_registered(self, ptype, sid):
+        """Check secondary process is registered.
+
+        Return True if registered, or print error and return False if not.
+        """
+
+        if sid in self.secondaries[ptype]:
+            return True
+        else:
+            print('"{ptype} {sid}" does not exist.'.format(
+                ptype=ptype, sid=sid))
+            return False
+
     def precmd(self, line):
         """Called before running a command
 
         It is called for checking a contents of command line.
         """
+        if self.use_cache is False:
+            self.init_spp_procs()
 
         if self.recorded_file:
             if not (
@@ -341,7 +356,8 @@ class Shell(cmd.Cmd, object):
         if len(cmds) < 2:
             print("Required an ID and ';' before the command.")
         elif str.isdigit(cmds[0]):
-            self.secondaries['nfv'][int(cmds[0])].run(cmds[1])
+            if self._is_sec_registered('nfv', int(cmds[0])):
+                self.secondaries['nfv'][int(cmds[0])].run(cmds[1])
         else:
             print('Invalid command: %s' % tmparg)
 
@@ -440,7 +456,9 @@ class Shell(cmd.Cmd, object):
         if len(cmds) < 2:
             print("Required an ID and ';' before the command.")
         elif str.isdigit(cmds[0]):
-            self.secondaries['vf'][int(cmds[0])].run(cmds[1])
+
+            if self._is_sec_registered('vf', int(cmds[0])):
+                self.secondaries['vf'][int(cmds[0])].run(cmds[1])
         else:
             print('Invalid command: %s' % tmparg)
 
@@ -518,7 +536,8 @@ class Shell(cmd.Cmd, object):
         if len(cmds) < 2:
             print("Required an ID and ';' before the command.")
         elif str.isdigit(cmds[0]):
-            self.secondaries['mirror'][int(cmds[0])].run(cmds[1])
+            if self._is_sec_registered('mirror', int(cmds[0])):
+                self.secondaries['mirror'][int(cmds[0])].run(cmds[1])
         else:
             print('Invalid command: %s' % tmparg)
 
@@ -585,7 +604,8 @@ class Shell(cmd.Cmd, object):
         if len(cmds) < 2:
             print("Required an ID and ';' before the command.")
         elif str.isdigit(cmds[0]):
-            self.secondaries['pcap'][int(cmds[0])].run(cmds[1])
+            if self._is_sec_registered('pcap', int(cmds[0])):
+                self.secondaries['pcap'][int(cmds[0])].run(cmds[1])
         else:
             print('Invalid command: {}'.format(tmparg))
 
-- 
2.17.1

  reply	other threads:[~2019-02-21  3:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-21  3:27 [spp] [PATCH 0/2] Fix bugs of SPP CLI ogawa.yasufumi
2019-02-21  3:27 ` ogawa.yasufumi [this message]
2019-02-21  3:27 ` [spp] [PATCH 2/2] controller: fix compl for sec enabled immediately ogawa.yasufumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1550719659-14226-2-git-send-email-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).