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 E80941B429 for ; Thu, 11 Oct 2018 12:33:57 +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 w9BAXuFD005237; Thu, 11 Oct 2018 19:33:56 +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 0D1BC125; Thu, 11 Oct 2018 19:33:56 +0900 (JST) Received: from localhost.localdomain (unknown [129.60.13.51]) by bcmv-ns01.ecl.ntt.co.jp (Postfix) with ESMTP id EB3CF105; Thu, 11 Oct 2018 19:33:55 +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:45 +0900 Message-Id: <20181011103347.48630-3-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 2/4] controller: update parsing status message 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:58 -0000 From: Yasufumi Ogawa To apply with the update of spp_nfv and spp_vm, update parsing the message of status. In the updated message, 'ports' attribute is changed to not include patch info and it is moved to the new 'patches' attribute. This patch is to parse 'patches' attribute. Output of status command is not changed. Signed-off-by: Yasufumi Ogawa --- src/controller/shell.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/controller/shell.py b/src/controller/shell.py index 09b9e86..8fb5a1a 100644 --- a/src/controller/shell.py +++ b/src/controller/shell.py @@ -194,27 +194,30 @@ class Shell(cmd.Cmd, object): - phy:1 The format of the received message is JSON and ended with - series of null character "\x00". The value of "ports" attribute - is a set of combinations of patches. If a port is not patched, - the "dst" is set to "null". + series of null character "\x00". - {"status":"idling","ports":[{"src":"phy:0", "dst": ...,]}'\x00\x00.. + {"client-id":1,...,"patches":[{"src":"phy:0"...},...]}'\x00.. """ - msg = msg.replace("\x00", "") # clean sec's msg + msg = msg.replace("\x00", "") # Clean received msg try: sec_attr = json.loads(msg) print('- status: %s' % sec_attr['status']) print('- ports:') for port in sec_attr['ports']: - if port['dst'] == 'null': - print(' - %s' % port['src']) + dst = None + for patch in sec_attr['patches']: + if patch['src'] == port: + dst = patch['dst'] + + if dst is None: + print(' - %s' % port) else: - print(' - %s -> %s' % (port['src'], port['dst'])) + print(' - %s -> %s' % (port, dst)) except ValueError as err: print('Invalid format: {0}.'.format(err)) - print(" '%s'" % msg) + print("'%s'" % msg) def command_primary(self, command): """Send command to primary process""" -- 2.7.4