From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id CD121A046B for ; Mon, 24 Jun 2019 09:11:41 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C559B1BED2; Mon, 24 Jun 2019 09:11:41 +0200 (CEST) Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by dpdk.org (Postfix) with ESMTP id 1ABA71BED2 for ; Mon, 24 Jun 2019 09:11:41 +0200 (CEST) Received: by mail-pf1-f169.google.com with SMTP id r1so6951971pfq.12 for ; Mon, 24 Jun 2019 00:11:41 -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=//y2hC3C1B5+PfW0eRqNP+aYUd3shCOS1OnGn7QbAf4=; b=ZVAC6/gUQIWf1RQrjyyTyyzhLSVxkMFa/nXQ258Nyw6zzIEC4gUxTDof1/3AfujszD yJGTiyC9lcBrLN6jmJMOD8/QD6tywzDyUtE+PWjQl+yYBg5eM2KXDCWAJ4Osxp/kRElA Fi7DC15IzX3OLEWnheSEgJWQkJH0++L8/RDvKafpfZfDjfT6hQmV4KS1ITYdQLO3Zb5E uQi9tiyutbt9DWCYF0sTCBPRQ2WFoRcD8Ya+jI1C86STiI/qmT5ZUc7+DDEFV+5PorM4 Hjach+zFsHGtoB2amH+oj21lpNpaX1s/HNPJnmJOx8hhq1qHshvPHZQ+QAn2hJXpgFhc 9Ntw== 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=//y2hC3C1B5+PfW0eRqNP+aYUd3shCOS1OnGn7QbAf4=; b=Kfd5kxAqYQk+p4ISyeJMAVneHn9nM+8pbUx//qMXBri8jcAGALfWbwtRvTeTn7e6Do I2T2UXr7eXV0s3ps2ZSngV4dt43M8qRQDs50SdCZwMmSNKkSuDwK29sWKlVRQczFM72x eNPYPW2Caou7vUPGN8DJ38E36pg/HeEwsqS/NOSOCEdmDu5jzytJOKUfSBGr8GaqpdDk 9KGAH8wsLWJJcoV+t6odpq7xNgn3f1WU/a8GHm9LDP+54nyhvsRTr/eBzlSorNx/4Buk qwQ3F4jUo8MnlirIh33h43ulXFBEiiu8mOu9+7oPUVNk07mk09mAmSiF7YyvVrGAHULJ DDFw== X-Gm-Message-State: APjAAAXH49IIY56rJw6xwJHYLPrkvUuo6DFEkbLsYjSznq3/ZkBitHYA GeZ/B0ZNNTpv0bhn9cf90vtHU7Rx X-Google-Smtp-Source: APXvYqzH6I75JAFjDyykppQeNQL5JHTIDYcgyteGpcFBV+rbbQJpWIk9Du27ZhAWUJ6yru1vFcVYXA== X-Received: by 2002:a65:41c5:: with SMTP id b5mr12147494pgq.128.1561360300187; Mon, 24 Jun 2019 00:11:40 -0700 (PDT) Received: from localhost.localdomain ([192.47.164.146]) by smtp.gmail.com with ESMTPSA id y17sm6357948pfe.148.2019.06.24.00.11.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 24 Jun 2019 00:11:39 -0700 (PDT) From: yasufum.o@gmail.com To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Mon, 24 Jun 2019 16:11:22 +0900 Message-Id: <20190624071124.23451-9-yasufum.o@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190624071124.23451-1-yasufum.o@gmail.com> References: <20190624071124.23451-1-yasufum.o@gmail.com> Subject: [spp] [PATCH 08/10] controller: move topo help msg to SppBye 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" From: Yasufumi Ogawa This patch is to move comment of `do_topo`, `do_topo_subgraph` and `do_topo_resize` to `SppTopo.help` to reduce the number of lines. Signed-off-by: Yasufumi Ogawa --- src/controller/commands/topo.py | 52 ++++++++++++++++++++++++++++ src/controller/shell.py | 61 +++++++++------------------------ 2 files changed, 68 insertions(+), 45 deletions(-) diff --git a/src/controller/commands/topo.py b/src/controller/commands/topo.py index 3b24c1a..21ef1ec 100644 --- a/src/controller/commands/topo.py +++ b/src/controller/commands/topo.py @@ -459,3 +459,55 @@ class SppTopo(object): return True else: return False + + @classmethod + def help(cls): + msg = """Output network topology. + + Support four types of output. + * terminal (but very few terminals supporting to display images) + * browser (websocket server is required) + * image file (jpg, png, bmp) + * text (dot, js or json, yml or yaml) + + spp > topo term # terminal + spp > topo http # browser + spp > topo network_conf.jpg # image + spp > topo network_conf.dot # text + spp > topo network_conf.js# text + """ + + 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. + + Subgraph is a group of object defined in dot language. For topo + command, it is used for grouping resources of each of VM or + container to topology be more understandable. + + (1) Add subgraph labeled 'vm1'. + spp > topo_subgraph add vm1 vhost:1;vhost:2 + + (2) Delete subgraph 'vm1'. + spp > topo_subgraph del vm1 + + (3) Show subgraphs by running topo_subgraph without args. + spp > topo_subgraph + label: vm1 subgraph: "vhost:1;vhost:2" + """ + + print(msg) diff --git a/src/controller/shell.py b/src/controller/shell.py index 8cb74a0..54376c9 100644 --- a/src/controller/shell.py +++ b/src/controller/shell.py @@ -824,11 +824,7 @@ class Shell(cmd.Cmd, object): {'cmdqueue': [], 'completekey': 'tab', 'completion_matches': ['inspect'], - 'lastcmd': 'inspect', - 'old_completer': None, - 'stdin': ', mode 'r' at 0x7fe96bddf0c0>, - 'stdout': ', mode 'w' at 0x7fe96bddf150>} - + ... """ from pprint import pprint @@ -841,22 +837,7 @@ class Shell(cmd.Cmd, object): return ['add', 'del'] def do_topo_subgraph(self, args): - """Edit subgarph for topo command. - - Subgraph is a group of object defined in dot language. For topo - command, it is used for grouping resources of each of VM or - container to topology be more understandable. - - (1) Add subgraph labeled 'vm1'. - spp > topo_subgraph add vm1 vhost:1;vhost:2 - - (2) Delete subgraph 'vm1'. - spp > topo_subgraph del vm1 - - (3) Show subgraphs by running topo_subgraph without args. - spp > topo_subgraph - label: vm1 subgraph: "vhost:1;vhost:2" - """ + """Edit subgarph for topo command.""" # logger.info("Topo initialized with sec IDs %s" % sec_ids) @@ -897,6 +878,10 @@ class Shell(cmd.Cmd, object): else: print("Ivalid subcommand '%s'!" % tokens[0]) + def help_topo_subgraph(self): + """Print help message of topo_subgraph command.""" + topo.SppTopo.help_subgraph() + def complete_topo_subgraph(self, text, line, begidx, endidx): terms = self.terms_topo_subgraph() @@ -921,35 +906,21 @@ class Shell(cmd.Cmd, object): pass def do_topo_resize(self, args): - """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 - - """ - + """Change the size of the image of topo_resize command.""" self.spp_topo.resize_graph(args) - def do_topo(self, args): - """Output network topology. - - Support four types of output. - * terminal (but very few terminals supporting to display images) - * browser (websocket server is required) - * image file (jpg, png, bmp) - * text (dot, js or json, yml or yaml) - - spp > topo term # terminal - spp > topo http # browser - spp > topo network_conf.jpg # image - spp > topo network_conf.dot # text - spp > topo network_conf.js# text - """ + 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')) + def help_topo(self): + """Print help message of topo command.""" + topo.SppTopo.help() + def complete_topo(self, text, line, begidx, endidx): return self.spp_topo.complete(text, line, begidx, endidx) -- 2.17.1