From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 15BC5A0471 for ; Mon, 12 Aug 2019 09:12:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0F799DE3; Mon, 12 Aug 2019 09:12:53 +0200 (CEST) Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by dpdk.org (Postfix) with ESMTP id A5B66DE3 for ; Mon, 12 Aug 2019 09:12:49 +0200 (CEST) Received: by mail-pg1-f176.google.com with SMTP id u17so49019264pgi.6 for ; Mon, 12 Aug 2019 00:12:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=cgZZUygBAanhEVo49FfI9xovWuap/YH2X6iDbvz4PM0=; b=RN24BNmGOo2HJJal12kn4X49jA2qlWdHCIcjJVSBw6+9bbG8J+7h71mxZAcK2s4LyY 3Pfyuq6xThJ4e0RY/UE22xXCmDoheJWmvpYMcD1J/4PIacHNllGW7be5nLnjRb/FOECm 9Npm84jTDJTEZUwptXMazIEpqj/mNrcGUJMAD7WPuPWuJ95vQJmXFKSZ1heVRgVbRBdO 7smA2CFznI3bmJ5KsGK2BEWjx2l1mPtJB8uOMQzPQ5EcG7SEOESXxUQ6Oo3Zr4rA1PSg n6ovgsXLCdqyXUVEl37vHYLe7H5jW/pQBDgiw79h6kuhN8gbXPDuTNrNe0GIAUUYlq/c 8nuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=cgZZUygBAanhEVo49FfI9xovWuap/YH2X6iDbvz4PM0=; b=WmROZ7FLCGKtxPB11NnoG4jcKgnNDdtEaqNSb86iuuVaeNvSVMbnVL3U40is6r+K7K ANtyhhiWXyVEMJ0u88dEaRkTNiS1nnO+CxfV2A6n1lRc3KazLtPYCU+thvenYUguFsyD s/FhP/OX+H/PiVC40Eh8RhJXLsiSi7Cl8d0D9uAdQzMhizswS+Gsehf/J0vDwC1UvpwP q36MPISXDsNEuIfMNcgGduTUwbf5ZvxztCm0yvkCyz+q9pWP5Bn5fm5jTMjyjJOkhLp2 HxiUW33HSfTrwYZC87u4ScUXJCIMtNbuRZg5NSe3if8Ve5r0MI0rulmmrF1bATV6U77u 6jDA== X-Gm-Message-State: APjAAAWNIy/KNii55Ys2yQ07NMbUfCeQAcRgWU1x5cVZB0VRvRHq1not W41JEoHkQ6ajuGrECd6k43t1gzcW X-Google-Smtp-Source: APXvYqxNpYjYnKruJlASnxo2owv/doaPW7TFirUWQNoElCuWSz/Wk70fuISRKRKGO5hNXbk1N+DeUg== X-Received: by 2002:a17:90a:ac0e:: with SMTP id o14mr22434249pjq.142.1565593968771; Mon, 12 Aug 2019 00:12:48 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c8c2:de00:8000:cb51:dfcb:76c]) by smtp.gmail.com with ESMTPSA id h9sm94675326pgh.51.2019.08.12.00.12.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 12 Aug 2019 00:12:48 -0700 (PDT) From: Yasufumi Ogawa To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Mon, 12 Aug 2019 16:12:35 +0900 Message-Id: <20190812071242.18934-2-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190812071242.18934-1-yasufum.o@gmail.com> References: <20190812071242.18934-1-yasufum.o@gmail.com> Subject: [spp] [PATCH 1/8] cli: remove 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: , Errors-To: spp-bounces@dpdk.org Sender: "spp" As `topo_size` is introduced in config and `topo_resize` command is not required anymore, remove this command. Signed-off-by: Yasufumi Ogawa --- src/cli/commands/topo.py | 59 +++++++++++++++++++++------------------- src/cli/shell.py | 10 ++----- 2 files changed, 33 insertions(+), 36 deletions(-) diff --git a/src/cli/commands/topo.py b/src/cli/commands/topo.py index 21ef1ec..58c59d1 100644 --- a/src/cli/commands/topo.py +++ b/src/cli/commands/topo.py @@ -25,7 +25,11 @@ class SppTopo(object): def __init__(self, spp_ctl_cli, subgraphs, size): self.spp_ctl_cli = spp_ctl_cli self.subgraphs = subgraphs - self.graph_size = size + self.graph_size = None + + if self.resize(size) is not True: + print('Config "topo_size" is invalid value.') + exit() def run(self, args, sec_ids): args_ary = args.split() @@ -42,6 +46,32 @@ class SppTopo(object): else: print("Usage: topo dst [ftype]") + def resize(self, size): + """Parse given size and set to self.graph_size. + + The format of `size` is percentage or ratio. Return True if succeeded + to parse, or False if invalid format. + """ + + size = str(size) + matched = re.match(r'(\d+)%$', size) + if matched: # percentage + i = int(matched.group(1)) + if i > 0 and i <= 100: + self.graph_size = size + return True + else: + return False + elif re.match(r'0\.\d+$',size): # ratio + i = float(size) * 100 + self.graph_size = str(i) + '%' + return True + elif size == '1': + self.graph_size = '100%' + return True + else: + return False + def show(self, dtype, sec_ids, size): res_ary = [] error_codes = self.spp_ctl_cli.rest_common_error_codes @@ -319,21 +349,6 @@ class SppTopo(object): topo_doc += "commands/experimental.html" print("See '%s' for required packages." % topo_doc) - def resize_graph(self, args): - if args == '': - print(self.graph_size) - else: - if '%' in args: - self.graph_size = args - print(self.graph_size) - elif '.' in args: - ii = float(args) * 100 - self.graph_size = str(ii) + '%' - print(self.graph_size) - else: # TODO(yasufum) add check for no number - self.graph_size = str(float(args) * 100) + '%' - print(self.graph_size) - def format_sec_status(self, sec_id, stat): """Return formatted secondary status as a hash @@ -479,18 +494,6 @@ class SppTopo(object): print(msg) - @classmethod - def help_resize(cls): - msg = """Change the size of the image of topo command. - - You can specify the size by percentage or ratio. - - spp > topo resize 60% # percentage - spp > topo resize 0.6 # ratio - """ - - print(msg) - @classmethod def help_subgraph(cls): msg = """Edit subgarph for topo command. diff --git a/src/cli/shell.py b/src/cli/shell.py index 34c12a1..d98cc8b 100644 --- a/src/cli/shell.py +++ b/src/cli/shell.py @@ -627,6 +627,8 @@ class Shell(cmd.Cmd, object): # Command prompt should be updated immediately if key == 'prompt': self.prompt = self.cli_config['prompt']['val'] + elif key == 'topo_size': + self.spp_topo.resize(self.cli_config['topo_size']['val']) def help_config(self): """Print help message of config command.""" @@ -904,14 +906,6 @@ class Shell(cmd.Cmd, object): else: pass - def do_topo_resize(self, args): - """Change the size of the image of topo_resize command.""" - self.spp_topo.resize_graph(args) - - def help_topo_resize(self): - """Print help message of topo command.""" - topo.SppTopo.help_resize() - def do_topo(self, args): """Output network topology.""" self.spp_topo.run(args, self.get_sec_ids('nfv')) -- 2.17.1