From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mogw1009.ocn.ad.jp (mogw1009.ocn.ad.jp [153.149.231.15]) by dpdk.org (Postfix) with ESMTP id E0E971DBE for ; Mon, 23 Apr 2018 08:23:48 +0200 (CEST) Received: from mf-smf-ucb022c1 (mf-smf-ucb022c1.ocn.ad.jp [153.153.66.139]) by mogw1009.ocn.ad.jp (Postfix) with ESMTP id 31FC8C00211; Mon, 23 Apr 2018 15:23:47 +0900 (JST) Received: from ntt.pod01.mv-mta-ucb025 ([153.149.142.99]) by mf-smf-ucb022c1 with ESMTP id AUsvfI0rceuR1AUt9f1lMc; Mon, 23 Apr 2018 15:23:47 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.167]) by ntt.pod01.mv-mta-ucb025 with id diPm1x00H3dLKTM01iPmGL; Mon, 23 Apr 2018 06:23:47 +0000 Received: from localhost.localdomain (sp1-72-1-217.msc.spmode.ne.jp [1.72.1.217]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Mon, 23 Apr 2018 15:23:46 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: ferruh.yigit@intel.com, geminoa@juno.ocn.ne.jp Cc: spp@dpdk.org, ogawa.yasufumi@lab.ntt.co.jp Date: Mon, 23 Apr 2018 15:22:36 +0900 Message-Id: <20180423054630.6789-3-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180423054630.6789-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20180423054630.6789-1-ogawa.yasufumi@lab.ntt.co.jp> X-Account-Key: account3 X-UIDL: 10323.+uP,eXr4x+tuiWREKd1zPAmCglg= X-Mozilla-Status: 0000 Received: from mzcmta018.ocn.ad.jp (LHLO mzcmta018.ocn.ad.jp) (118.23.178.209) by mzcstore251.ocn.ad.jp with LMTP; Mon, 23 Apr 2018 14:46:34 +0900 (JST) Received: from mfgw721.ocn.ad.jp (mfgw721.ocn.ad.jp [153.153.63.101]) by mzcmta018.ocn.ad.jp (Postfix) with ESMTP id 01CB9F2001C for ; Mon, 23 Apr 2018 14:46:34 +0900 (JST) Received-SPF: softfail (mf-ofc-ucb072: domain of transitioning dose not designate client-ip as permitted sender) client-ip=153.149.232.5; envelope-from=; helo=mogw0704.ocn.ad.jp; Authentication-Results: mf-ofc-ucb072; spf=softfail smtp.mailfrom=ogawa.yasufumi@lab.ntt.co.jp Received: from mogw0704.ocn.ad.jp (mogw0704.ocn.ad.jp [153.149.232.5]) by mfgw721.ocn.ad.jp (Postfix) with ESMTP id D11FB9C0286 for ; Mon, 23 Apr 2018 14:46:33 +0900 (JST) Received: from mf-smf-ucb036c3 (mf-smf-ucb036c3.ocn.ad.jp [153.153.66.235]) by mogw0704.ocn.ad.jp (Postfix) with ESMTP id C3C2F280114; Mon, 23 Apr 2018 14:46:33 +0900 (JST) Received: from ntt.pod01.mv-mta-ucb027 ([153.149.142.101]) by mf-smf-ucb036c3 with ESMTP id AUJ6fD9toN9S5AUJ7f18Df; Mon, 23 Apr 2018 14:46:33 +0900 Received: from smtp.ocn.ne.jp ([153.149.227.134]) by ntt.pod01.mv-mta-ucb027 with id dhmZ1x0042ud8JZ01hmZlr; Mon, 23 Apr 2018 05:46:33 +0000 Received: from localhost.localdomain (sp1-72-1-217.msc.spmode.ne.jp [1.72.1.217]) by smtp.ocn.ne.jp (Postfix) with ESMTPA; Mon, 23 Apr 2018 14:46:33 +0900 (JST) X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180423054630.6789-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20180423054630.6789-1-ogawa.yasufumi@lab.ntt.co.jp> Subject: [spp] [PATCH 2/3] controller: add topo_resize 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: Mon, 23 Apr 2018 06:23:49 -0000 From: ogawa.yasufumi@lab.ntt.co.jp From: Yasufumi Ogawa topo_resize command is for changing size of an image of topo term. # topo_resize without arg shows current ratio spp > topo_resize 60% # resize with percentage spp > topo_resize 80% 80% # resize with ratio spp > topo_resize 0.8 80% # it is also able to use int spp > topo_resize 1 100% Signed-off-by: Yasufumi Ogawa --- src/controller/shell.py | 18 +++++++++++++++++- src/controller/topo.py | 8 ++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/controller/shell.py b/src/controller/shell.py index ea5e8a9..1cf712c 100644 --- a/src/controller/shell.py +++ b/src/controller/shell.py @@ -31,6 +31,7 @@ class Shell(cmd.Cmd, object): PLUGIN_DIR = 'command' subgraphs = {} + topo_size = '60%' def default(self, line): """Define defualt behaviour @@ -646,6 +647,21 @@ class Shell(cmd.Cmd, object): else: pass + def do_topo_resize(self, args): + if args == '': + print(self.topo_size) + else: + if '%' in args: + self.topo_size = args + print(self.topo_size) + elif '.' in args: + ii = float(args) * 100 + self.topo_size = str(ii) + '%' + print(self.topo_size) + else: # TODO(yasufum) add check for no number + self.topo_size = str(float(args) * 100) + '%' + print(self.topo_size) + def do_topo(self, args): """Output network topology @@ -676,7 +692,7 @@ class Shell(cmd.Cmd, object): print("Usage: topo dst [ftype]") return False elif (args_ary[0] == "term") or (args_ary[0] == "http"): - res_ary = tp.show(args_ary[0]) + res_ary = tp.show(args_ary[0], self.topo_size) elif len(args_ary) == 1: ftype = args_ary[0].split(".")[-1] res_ary = tp.output(args_ary[0], ftype) diff --git a/src/controller/topo.py b/src/controller/topo.py index aa81e03..ff1349c 100644 --- a/src/controller/topo.py +++ b/src/controller/topo.py @@ -28,7 +28,7 @@ class Topo(object): self.s2m_queues = s2m_queues self.sub_graphs = sub_graphs - def show(self, dtype): + def show(self, dtype, size): res_ary = [] for sec_id in self.sec_ids: self.m2s_queues[sec_id].put("status") @@ -38,7 +38,7 @@ class Topo(object): if dtype == "http": self.to_http(res_ary) elif dtype == "term": - self.to_term(res_ary) + self.to_term(res_ary, size) else: print("Invalid file type") return res_ary @@ -259,7 +259,7 @@ class Topo(object): ws.send(msg) ws.close() - def to_term(self, sec_list): + def to_term(self, sec_list, size): tmpfile = "%s.jpg" % uuid.uuid4().hex self.to_img(sec_list, tmpfile) from distutils import spawn @@ -272,7 +272,7 @@ class Topo(object): img_cmd = "%s/%s/imgcat.sh" % ( os.path.dirname(__file__), '3rd_party') # Resize image to fit the terminal - img_size = "60%" + img_size = size cmd = "convert -resize %s %s %s" % (img_size, tmpfile, tmpfile) subprocess.call(cmd, shell=True) subprocess.call("%s %s" % (img_cmd, tmpfile), shell=True) -- 2.13.1