From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 4/5] controller: fix bug of completion of pri
Date: Mon, 4 Feb 2019 12:11:18 +0900 [thread overview]
Message-ID: <1549249879-31580-5-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1549249879-31580-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
`pri` command is completed without `;` after `pri`. This update is to
fix it and to not show candidates if `;` does not exist.
spp > pri; laun # show candidates
spp > pri lau # do not show without `pri;`
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/controller/commands/pri.py | 88 ++++++++++++++++++++++--------------------
src/controller/shell.py | 1 +
2 files changed, 47 insertions(+), 42 deletions(-)
diff --git a/src/controller/commands/pri.py b/src/controller/commands/pri.py
index 1f60ece..bb89a5f 100644
--- a/src/controller/commands/pri.py
+++ b/src/controller/commands/pri.py
@@ -5,6 +5,8 @@ from __future__ import absolute_import
from .. import spp_common
from ..shell_lib import common
+from ..spp_common import logger
+#from .. import spp_common
class SppPrimary(object):
@@ -151,48 +153,50 @@ class SppPrimary(object):
base_core = 1 # shared among secondaries
mytemplate = "-l {},{} -m 512 -- {} {} -s {}"
- # Show sub commands
- if len(tokens) == 2:
- # Add sub commands
- candidates = candidates + self.PRI_CMDS[:]
-
- # Show args of `launch` sub command.
- elif len(tokens) == 3 and tokens[1] == 'launch':
- for pt in spp_common.SEC_TYPES:
- candidates.append('{}'.format(pt))
-
- elif len(tokens) == 4 and tokens[1] == 'launch':
- if tokens[2] in spp_common.SEC_TYPES:
- candidates = [
- str(i+1) for i in range(spp_common.MAX_SECONDARY)]
-
- elif len(tokens) == 5 and tokens[1] == 'launch':
- if (tokens[2] in spp_common.SEC_TYPES) and \
- (int(tokens[3])-1 in range(spp_common.MAX_SECONDARY)):
- ptype = tokens[2]
- sid = tokens[3]
-
- if ptype == 'nfv':
- opt_sid = '-n'
- else:
- opt_sid = '--client-id'
-
- server_addr = common.current_server_addr()
- server_addr = server_addr.replace('7777', '6666')
-
- # Define rest of cores dynamically.
- # TODO(yasufum) decide rest of cores considering used cores
- if ptype == 'nfv': # one core is enough
- rest_core = sid
- elif ptype == 'vf': # at least three cores
- rest_core = '{}-{}'.format(int(sid), int(sid)+2)
- elif ptype == 'mirror': # two cores
- rest_core = sid
- elif ptype == 'pcap': # at least two cores
- rest_core = '{}-{}'.format(int(sid), int(sid)+1)
-
- candidates = [mytemplate.format(
- base_core, rest_core, opt_sid, sid, server_addr)]
+ if tokens[0].endswith(';'):
+
+ # Show sub commands
+ if len(tokens) == 2:
+ # Add sub commands
+ candidates = candidates + self.PRI_CMDS[:]
+
+ # Show args of `launch` sub command.
+ elif len(tokens) == 3 and tokens[1] == 'launch':
+ for pt in spp_common.SEC_TYPES:
+ candidates.append('{}'.format(pt))
+
+ elif len(tokens) == 4 and tokens[1] == 'launch':
+ if tokens[2] in spp_common.SEC_TYPES:
+ candidates = [
+ str(i+1) for i in range(spp_common.MAX_SECONDARY)]
+
+ elif len(tokens) == 5 and tokens[1] == 'launch':
+ if (tokens[2] in spp_common.SEC_TYPES) and \
+ (int(tokens[3])-1 in range(spp_common.MAX_SECONDARY)):
+ ptype = tokens[2]
+ sid = tokens[3]
+
+ if ptype == 'nfv':
+ opt_sid = '-n'
+ else:
+ opt_sid = '--client-id'
+
+ server_addr = common.current_server_addr()
+ server_addr = server_addr.replace('7777', '6666')
+
+ # Define rest of cores dynamically.
+ # TODO(yasufum) decide rest of cores considering used cores
+ if ptype == 'nfv': # one core is enough
+ rest_core = sid
+ elif ptype == 'vf': # at least three cores
+ rest_core = '{}-{}'.format(int(sid), int(sid)+2)
+ elif ptype == 'mirror': # two cores
+ rest_core = sid
+ elif ptype == 'pcap': # at least two cores
+ rest_core = '{}-{}'.format(int(sid), int(sid)+1)
+
+ candidates = [mytemplate.format(
+ base_core, rest_core, opt_sid, sid, server_addr)]
if not text:
completions = candidates
diff --git a/src/controller/shell.py b/src/controller/shell.py
index c2a31c6..e68ac63 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -330,6 +330,7 @@ class Shell(cmd.Cmd, object):
def complete_pri(self, text, line, begidx, endidx):
"""Completion for primary process commands."""
+ line = re.sub(r'\s+', " ", line)
return self.primary.complete(text, line, begidx, endidx)
def do_nfv(self, cmd):
--
2.7.4
next prev parent reply other threads:[~2019-02-04 3:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-04 3:11 [spp] [PATCH 0/5] Fix bugs of SPP CLI ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 1/5] controller: fix bug to add vf comps on same core ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 2/5] controller: add checking syntax for vf port cmd ogawa.yasufumi
2019-02-04 3:11 ` [spp] [PATCH 3/5] controller: fix bug of history command ogawa.yasufumi
2019-02-04 3:11 ` ogawa.yasufumi [this message]
2019-02-04 3:11 ` [spp] [PATCH 5/5] controller: refactor configuration of logfile 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=1549249879-31580-5-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).