From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from tama500.ecl.ntt.co.jp (tama500.ecl.ntt.co.jp [129.60.39.148]) by dpdk.org (Postfix) with ESMTP id 9B2591B13B for ; Tue, 29 Jan 2019 13:24:21 +0100 (CET) Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x0TCOK4L017121; Tue, 29 Jan 2019 21:24:20 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 4A000EA85EA; Tue, 29 Jan 2019 21:24:20 +0900 (JST) Received: from localhost.localdomain (lobster.nslab.ecl.ntt.co.jp [129.60.13.95]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 3B508EA85C9; Tue, 29 Jan 2019 21:24:20 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: ferruh.yigit@intel.com, spp@dpdk.org, ogawa.yasufumi@lab.ntt.co.jp Date: Tue, 29 Jan 2019 21:22:00 +0900 Message-Id: <1548764521-2827-8-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1548764521-2827-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> References: <1548764521-2827-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH 7/8] controller: revise completion of launch command X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jan 2019 12:24:22 -0000 From: Yasufumi Ogawa To help users by reducing input of launch command, change to generate options automatically from given secondary ID. Signed-off-by: Yasufumi Ogawa --- 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