Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: ferruh.yigit@intel.com, spp@dpdk.org, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 7/8] controller: revise completion of launch command
Date: Tue, 29 Jan 2019 21:22:00 +0900	[thread overview]
Message-ID: <1548764521-2827-8-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1548764521-2827-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>

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

To help users by reducing input of launch command, change to generate
options automatically from given secondary ID.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/controller/commands/pri.py | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/src/controller/commands/pri.py b/src/controller/commands/pri.py
index 577952c..7712ba2 100644
--- a/src/controller/commands/pri.py
+++ b/src/controller/commands/pri.py
@@ -136,7 +136,8 @@ class SppPrimary(object):
         candidates = []
         tokens = line.split(' ')
 
-        mytemplate = "-l 1,2 -m 512 -- -n {} -s {}"
+        base_core = 1  # shared among secondaries
+        mytemplate = "-l {},{} -m 512 -- {} {} -s {}"
 
         # Show sub commands
         if len(tokens) == 2:
@@ -156,8 +157,30 @@ class SppPrimary(object):
         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]
-                candidates = [mytemplate.format(sid, common.current_server_addr())]
+
+                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
@@ -166,8 +189,6 @@ class SppPrimary(object):
                            if p.startswith(text)
                            ]
 
-        #completions.append("nof_tokens:{}".format(len(tokens)))
-
         return completions
 
     def _get_sec_ids(self):
@@ -299,7 +320,7 @@ class SppPrimary(object):
         if res is not None:
             error_codes = self.spp_ctl_cli.rest_common_error_codes
             if res.status_code == 204:
-                print('Succeeded to launch {}:{}.'.format(
+                print('Send request to launch {}:{}.'.format(
                     proc_type, sec_id))
             elif res.status_code in error_codes:
                 pass
-- 
2.7.4

  parent reply	other threads:[~2019-01-29 12:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-29 12:21 [spp] [PATCH 0/8] Add launch command to spp_primary ogawa.yasufumi
2019-01-29 12:21 ` [spp] [PATCH 1/8] shared: add func for getting dirname of secondary ogawa.yasufumi
2019-01-29 12:21 ` [spp] [PATCH 2/8] spp_priamry: add launch command ogawa.yasufumi
2019-01-29 12:21 ` [spp] [PATCH 3/8] spp-ctl: add launch command support for REST API ogawa.yasufumi
2019-01-29 12:21 ` [spp] [PATCH 4/8] controller: add launch sub command in pri ogawa.yasufumi
2019-01-29 12:21 ` [spp] [PATCH 5/8] spp_primary: change launching sec to use python ogawa.yasufumi
2019-01-29 12:21 ` [spp] [PATCH 6/8] tools/helpers: add sec launcher script ogawa.yasufumi
2019-01-29 12:22 ` ogawa.yasufumi [this message]
2019-01-29 12:22 ` [spp] [PATCH 8/8] tools/helpers: move cpu_layout script to helpers 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=1548764521-2827-8-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).