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 EDCC35589 for ; Mon, 4 Feb 2019 04:13:29 +0100 (CET) Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x143DSTZ023145; Mon, 4 Feb 2019 12:13:28 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id D3C4C638BAC; Mon, 4 Feb 2019 12:13:28 +0900 (JST) Received: from localhost.localdomain (lobster.nslab.ecl.ntt.co.jp [129.60.13.95]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id C5D16638B0E; Mon, 4 Feb 2019 12:13:28 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Date: Mon, 4 Feb 2019 12:11:16 +0900 Message-Id: <1549249879-31580-3-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1549249879-31580-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> References: <1549249879-31580-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH 2/5] controller: add checking syntax for vf port cmd 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: Mon, 04 Feb 2019 03:13:30 -0000 From: Yasufumi Ogawa This update is add checking the number of params for `port` sub command of vf to avoid SPP CLI is terminated if its syntax is invalid. Signed-off-by: Yasufumi Ogawa --- src/controller/commands/vf.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/src/controller/commands/vf.py b/src/controller/commands/vf.py index 7518c04..ff08231 100644 --- a/src/controller/commands/vf.py +++ b/src/controller/commands/vf.py @@ -279,6 +279,7 @@ class SppVf(object): print('Error: unknown response.') def _run_port(self, params): + req_params = None if len(params) == 4: if params[0] == 'add': action = 'attach' @@ -314,17 +315,20 @@ class SppVf(object): 'dir': params[2], 'vlan': {'operation': op, 'id': int(params[5]), 'pcp': int(params[6])}} + else: + print('Error: Invalid syntax.') - res = self.spp_ctl_cli.put('vfs/%d/components/%s/ports' - % (self.sec_id, params[3]), req_params) - if res is not None: - error_codes = self.spp_ctl_cli.rest_common_error_codes - if res.status_code == 204: - print("Succeeded to %s port" % params[0]) - elif res.status_code in error_codes: - pass - else: - print('Error: unknown response.') + if req_params is not None: + res = self.spp_ctl_cli.put('vfs/%d/components/%s/ports' + % (self.sec_id, params[3]), req_params) + if res is not None: + error_codes = self.spp_ctl_cli.rest_common_error_codes + if res.status_code == 204: + print("Succeeded to %s port" % params[0]) + elif res.status_code in error_codes: + pass + else: + print('Error: unknown response.') def _run_cls_table(self, params): req_params = None @@ -337,7 +341,7 @@ class SppVf(object): 'vlan': params[2], 'mac_address': params[3], 'port': params[4]} else: - print('Error: Invalid params') + print('Error: Invalid syntax.') if req_params is not None: req = 'vfs/%d/classifier_table' % self.sec_id -- 2.7.4