From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from bcmv-tmail01.ecl.ntt.co.jp (bcmv-tmail01.ecl.ntt.co.jp [124.146.185.148]) by dpdk.org (Postfix) with ESMTP id 5344D1B3A5 for ; Thu, 11 Oct 2018 12:33:59 +0200 (CEST) Received: from bcmv-ns01.ecl.ntt.co.jp (bcmv-ns01.ecl.ntt.co.jp [129.60.83.123]) by bcmv-tmail01.ecl.ntt.co.jp (8.14.4/8.14.4) with ESMTP id w9BAXwFi005243; Thu, 11 Oct 2018 19:33:58 +0900 Received: from bcmv-ns01.ecl.ntt.co.jp (localhost [127.0.0.1]) by bcmv-ns01.ecl.ntt.co.jp (Postfix) with ESMTP id 221C6125; Thu, 11 Oct 2018 19:33:58 +0900 (JST) Received: from localhost.localdomain (unknown [129.60.13.51]) by bcmv-ns01.ecl.ntt.co.jp (Postfix) with ESMTP id 0BE50105; Thu, 11 Oct 2018 19:33:58 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Date: Thu, 11 Oct 2018 19:33:47 +0900 Message-Id: <20181011103347.48630-5-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20181011103347.48630-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20181009105047.42568-1-ogawa.yasufumi@lab.ntt.co.jp> <20181011103347.48630-1-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH v2 4/4] spp-ctl: update parsing status 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: Thu, 11 Oct 2018 10:33:59 -0000 From: Yasufumi Ogawa Update parsing the result of status. Spp_nfv and spp_vm are changed to return the same status message as spp-ctl, so it can be used without modifying. Signed-off-by: Yasufumi Ogawa --- src/spp-ctl/spp_webapi.py | 39 ++++++++++----------------------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/src/spp-ctl/spp_webapi.py b/src/spp-ctl/spp_webapi.py index ddf6513..c81d0b7 100644 --- a/src/spp-ctl/spp_webapi.py +++ b/src/spp-ctl/spp_webapi.py @@ -321,33 +321,15 @@ class V1NFVHandler(BaseHandler): def convert_nfv_info(self, sec_id, data): nfv = {} - # spp_nfv returns status info in two lines. First line is - # status of running or idling, and second is patch info. - # 'null' means that it has no dst port. - # "status: idling\nports: 'phy:0-phy:1,phy:1-null'\x00\x00.." - entries = data.split('\n') - if len(entries) != 2: - return {} - - nfv['client_id'] = int(sec_id) - nfv['status'] = entries[0].split()[1] - - patch_list = entries[1].split()[1].replace("'", '') - - ports = [] - nfv['patches'] = [] - - for port_cmb in patch_list.split(','): - p_src, p_dst = port_cmb.split('-') - if p_src != 'null' and p_dst != 'null': - nfv['patches'].append({'src': p_src, 'dst': p_dst}) - - for port in [p_src, p_dst]: - if port != 'null': - ports.append(port) - - nfv['ports'] = list(set(ports)) + # spp_nfv returns status info in JSON format. 'null' means + # that it has no dst port. + # {"status":"idling","ports":[{"src":"phy:0","dst":"null"},... + # TODO(yasufum) modify after nfv and vm is updated for new data definition. + try: + nfv = json.loads(data) + except json.JSONDecodeError as e: + print("%s" % e) return nfv def nfv_get(self, proc): @@ -376,11 +358,10 @@ class V1NFVHandler(BaseHandler): def nfv_port(self, proc, body): self._validate_nfv_port(body) - if_type, if_num = body['port'].split(":") if body['action'] == "add": - proc.port_add(if_type, if_num) + proc.port_add(body['port']) else: - proc.port_del(if_type, if_num) + proc.port_del(body['port']) def _validate_nfv_patch(self, body): for key in ['src', 'dst']: -- 2.7.4