From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mogw0537.ocn.ad.jp (mogw0537.ocn.ad.jp [118.23.178.179]) by dpdk.org (Postfix) with ESMTP id 928402C58 for ; Mon, 12 Mar 2018 06:35:34 +0100 (CET) Received: from mf-smf-ucb035c1 (mf-smf-ucb035c1.ocn.ad.jp [153.153.66.230]) by mogw0537.ocn.ad.jp (Postfix) with ESMTP id 09408F42CE; Mon, 12 Mar 2018 14:35:33 +0900 (JST) Received: from ntt.pod01.mv-mta-ucb023 ([153.149.142.86]) by mf-smf-ucb035c1 with ESMTP id vG7PeB8uIwTkQvG7QeeXWN; Mon, 12 Mar 2018 14:35:33 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.165]) by ntt.pod01.mv-mta-ucb023 with id LtbY1x00A3akymp01tbYM5; Mon, 12 Mar 2018 05:35:32 +0000 Received: from linaloe.flets-east.jp (sp1-66-103-93.msc.spmode.ne.jp [1.66.103.93]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Mon, 12 Mar 2018 14:35:32 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com Cc: Yasufumi Ogawa Date: Mon, 12 Mar 2018 14:35:16 +0900 Message-Id: <1520832924-28387-2-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1520832924-28387-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> References: <8b08be87-6b64-8a4a-53e0-29269011d81c@lab.ntt.co.jp> <1520832924-28387-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> Subject: [spp] [PATCH 1/9] controller: change displaying 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: Mon, 12 Mar 2018 05:35:35 -0000 From: Yasufumi Ogawa This update is for removing port_id from the result of status command because bahaviour of port_id assignment is changed from DPDK 18.02 and it possibly confuses users. Secondary's status message is changed from spp > sec 1;status port_id:0,on,PHY,outport:none port_id:1,on,PHY,outport:none port_id:2,on,RING(0),outport:none to be more simplified YAML like style. spp > sec 1;status status: idling ports: - 'phy:0 -> ring:0' - 'phy:1' - 'ring:0 -> phy:1' SPP controller expects message format from secondary is as following to decode it to show as above example. status: running\nports: phy:0-vhost:0,vhost:0-null This update is only for controller. Updates for secondary processes are included in next patches. Signed-off-by: Yasufumi Ogawa --- src/controller/conn_thread.py | 4 ++-- src/controller/shell.py | 22 +++++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/controller/conn_thread.py b/src/controller/conn_thread.py index 1620046..039a3ad 100644 --- a/src/controller/conn_thread.py +++ b/src/controller/conn_thread.py @@ -49,8 +49,8 @@ class ConnectionThread(threading.Thread): # 1024 stands for bytes of data to be received data = self.conn.recv(1024) if data: - spp_common.SEC2MAIN[self.client_id].put( - "recv:%s:{%s}" % (str(self.conn.fileno()), data)) + msg = "%s" % data + spp_common.SEC2MAIN[self.client_id].put(msg) else: spp_common.SEC2MAIN[self.client_id].put( "closing:" + str(self.conn)) diff --git a/src/controller/shell.py b/src/controller/shell.py index 91b78f1..4bca3e5 100644 --- a/src/controller/shell.py +++ b/src/controller/shell.py @@ -88,6 +88,23 @@ class Shell(cmd.Cmd, object): for i in spp_common.SECONDARY_LIST: print ("Connected secondary id: %d" % i) + def print_sec_status(self, msg): + msg = msg.replace("\x00", "") # remove null chars in msg from sec + status, ports = msg.split("\n") + res = "%s\nports:\n" % status + port_list = ports.split(' ')[1].split(',') + + tmp = [] + for p in port_list: + p1, p2 = p.split('-') + if p2 == 'null': + tmp.append(" - '%s'" % p1) + else: + tmp.append(" - '%s -> %s'" % (p1, p2)) + tmp.sort() + res += "\n".join(tmp) + print(res) + def command_primary(self, command): """Send command to primary process""" @@ -107,7 +124,10 @@ class Shell(cmd.Cmd, object): if sec_id in spp_common.SECONDARY_LIST: spp_common.MAIN2SEC[sec_id].put(command) recv = spp_common.SEC2MAIN[sec_id].get(True) - print (recv) + if command == 'status': + self.print_sec_status(recv) + else: + print(recv) return self.CMD_OK, recv else: message = "secondary id %d not exist" % sec_id -- 2.7.4