* [spp] [PATCH 1/2] controller: fix bug terminated if no sec ID found
2019-02-21 3:27 [spp] [PATCH 0/2] Fix bugs of SPP CLI ogawa.yasufumi
@ 2019-02-21 3:27 ` ogawa.yasufumi
2019-02-21 3:27 ` [spp] [PATCH 2/2] controller: fix compl for sec enabled immediately ogawa.yasufumi
1 sibling, 0 replies; 3+ messages in thread
From: ogawa.yasufumi @ 2019-02-21 3:27 UTC (permalink / raw)
To: spp, ferruh.yigit, ogawa.yasufumi
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* [spp] [PATCH 2/2] controller: fix compl for sec enabled immediately
2019-02-21 3:27 [spp] [PATCH 0/2] Fix bugs of SPP CLI ogawa.yasufumi
2019-02-21 3:27 ` [spp] [PATCH 1/2] controller: fix bug terminated if no sec ID found ogawa.yasufumi
@ 2019-02-21 3:27 ` ogawa.yasufumi
1 sibling, 0 replies; 3+ messages in thread
From: ogawa.yasufumi @ 2019-02-21 3:27 UTC (permalink / raw)
To: spp, ferruh.yigit, ogawa.yasufumi
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
SPP CLI does not complete for sec IDs until secondary list is updated.
This list is updated while running some of commands, such as `status`.
However, this behaviour might confuse user because user cannot find
secondary after launched and doubt it is failed to.
This update is to do completion everytime pressing TAB to update the
list immediately.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/controller/shell.py | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/src/controller/shell.py b/src/controller/shell.py
index 2568523..e3f1ff8 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -362,7 +362,10 @@ class Shell(cmd.Cmd, object):
print('Invalid command: %s' % tmparg)
def complete_nfv(self, text, line, begidx, endidx):
- """Completion for nfv command"""
+ """Completion for nfv command."""
+
+ if self.use_cache is False:
+ self.init_spp_procs()
line = self.clean_cmd(line)
@@ -463,7 +466,10 @@ class Shell(cmd.Cmd, object):
print('Invalid command: %s' % tmparg)
def complete_vf(self, text, line, begidx, endidx):
- """Completion for vf command"""
+ """Completion for vf command."""
+
+ if self.use_cache is False:
+ self.init_spp_procs()
line = self.clean_cmd(line)
@@ -542,7 +548,10 @@ class Shell(cmd.Cmd, object):
print('Invalid command: %s' % tmparg)
def complete_mirror(self, text, line, begidx, endidx):
- """Completion for mirror command"""
+ """Completion for mirror command."""
+
+ if self.use_cache is False:
+ self.init_spp_procs()
line = self.clean_cmd(line)
@@ -610,7 +619,10 @@ class Shell(cmd.Cmd, object):
print('Invalid command: {}'.format(tmparg))
def complete_pcap(self, text, line, begidx, endidx):
- """Completion for pcap command"""
+ """Completion for pcap command."""
+
+ if self.use_cache is False:
+ self.init_spp_procs()
line = self.clean_cmd(line)
--
2.17.1
^ permalink raw reply [flat|nested] 3+ messages in thread