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 94BACA0471 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 2E22D37A8; Mon, 12 Aug 2019 09:12:53 +0200 (CEST) Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by dpdk.org (Postfix) with ESMTP id 8E785DE3 for ; Mon, 12 Aug 2019 09:12:52 +0200 (CEST) Received: by mail-pf1-f174.google.com with SMTP id o70so3910146pfg.5 for ; Mon, 12 Aug 2019 00:12:52 -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=FiMHAtZmU8fUpV4fooO5qtp53lpSTiqxTdUymtws/uw=; b=b4ZsE/M+fa2pQfhnj+5mMCpj+RfqSSB2vcOOuZLkmUGQOjZN55KQgnIUd+dOlQuBr0 q4aLxuek655GibbT7h8YPzooyZMjfoymAh+lOzIzwRvzc3Lc+8HWpCmX8FjfkLqZAiNj mowHhMLyz+25NcOFXMAn0ySsLYa5RT7xTxSPbrLGCfyDPfnp+Xvu4eol6Xf4ygmUYNr+ zQ2TB0+OgTbDfEIOcqkyyCsIhUmpbc8+8tIa5a2Ew3+lpR0gNAzvh3xrBxPM3L/uc7BA UM+JJ/UHOXoJc5erXPXH6BNqMg8L+j7sip6/5VAS++QdMTlTs+1llEAYvOZgyH4LVA7W apNQ== 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=FiMHAtZmU8fUpV4fooO5qtp53lpSTiqxTdUymtws/uw=; b=OSIhu1Zs2kfTlSMnEhwhzVwCydzLj8LihdNgZu32nXqYYVibCc/Poyh8xTWy4tDfKr nj+gp3+nxdEln+zSnDip6ITqkLHu5+/9m1T+PEjbjy6loiGc0BByRbCotP8v1sYKy01M 9A5OPt3oI9AM/Yu+/DFb5xNelWylF3Hchb35DHpQy3pv3McNd4jN1uccRWaTDv+XwUXr 2ozEMN2XqNForZzvBiEiBXw2Xuq8KQS0G77T9rEpPpTc/znPvbZDzjJlQ4zsvey39pjT oCziYVvBoT/kIqJGWIk5diYLHaBdgCTzin2GvIPXaB1NPgeQgP+4TQwCG658vR8fTTQ2 bWEQ== X-Gm-Message-State: APjAAAX274J0hbMmwMm3IF8EtoDwsxtUAyM51oYfqJcOI0YEu1ckqwvD dIyVzZqQyxkSYFaTx2qlcAnjREzs X-Google-Smtp-Source: APXvYqyACs3UWxz1QDsPFmqmCR1QrGdmqxq9ELgylukCMFG/wwvFdxFHYyV3pGmAH4edYM0RtzP+aQ== X-Received: by 2002:a17:90a:b00b:: with SMTP id x11mr22077736pjq.120.1565593971617; Mon, 12 Aug 2019 00:12:51 -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.50 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 12 Aug 2019 00:12:51 -0700 (PDT) From: Yasufumi Ogawa To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com Date: Mon, 12 Aug 2019 16:12:37 +0900 Message-Id: <20190812071242.18934-4-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 3/8] cli: move style params for dot to config 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" This update is to move style parameters defined in `topo.py` , such as node colors or link colors, to `topo.yml`. Signed-off-by: Yasufumi Ogawa --- src/cli/commands/topo.py | 44 ++++++++++++++++---------------------- src/cli/config/default.yml | 8 ++++--- src/cli/config/topo.yml | 8 +++++++ src/cli/shell.py | 2 +- 4 files changed, 33 insertions(+), 29 deletions(-) create mode 100644 src/cli/config/topo.yml diff --git a/src/cli/commands/topo.py b/src/cli/commands/topo.py index 0d613cb..86495c8 100644 --- a/src/cli/commands/topo.py +++ b/src/cli/commands/topo.py @@ -22,12 +22,21 @@ class SppTopo(object): delim_node = '_' - def __init__(self, spp_ctl_cli, subgraphs, size): + def __init__(self, spp_ctl_cli, subgraphs, cli_config): self.spp_ctl_cli = spp_ctl_cli self.subgraphs = subgraphs self.graph_size = None - if self.resize(size) is not True: + # Graphviz params + topo_file = '{dir}/../config/topo.yml'.format(dir=os.path.dirname(__file__)) + topo_conf = yaml.load(open(topo_file), Loader=yaml.FullLoader) + self.SEC_COLORS = topo_conf['topo_sec_colors']['val'] + self.PORT_COLORS = topo_conf['topo_port_colors']['val'] + self.LINE_STYLE = {"running": "solid", "idling": "dashed"} + self.GRAPH_TYPE = "digraph" + self.LINK_TYPE = "->" + + if self.resize(cli_config['topo_size']['val']) is not True: print('Config "topo_size" is invalid value.') exit() @@ -126,21 +135,6 @@ class SppTopo(object): def to_dot(self, sec_list, output_fname): """Output dot script.""" - # Graphviz params - # TODO(yasufum) consider to move gviz params to config file. - SEC_COLORS = [ - "blue", "green", "orange", "chocolate", "black", - "cyan3", "green3", "indianred", "lawngreen", "limegreen"] - PORT_COLORS = { - "phy": "white", - "ring": "yellow", - "vhost": "limegreen"} - LINE_STYLE = { - "running": "solid", - "idling": "dashed"} - GRAPH_TYPE = "digraph" - LINK_TYPE = "->" - node_attrs = 'node[shape="rectangle", style="filled"];' node_template = '{}' + self.delim_node + '{}' @@ -176,12 +170,12 @@ class SppTopo(object): for patch in sec['patches']: if sec['status'] == 'running': - l_style = LINE_STYLE["running"] + l_style = self.LINE_STYLE["running"] else: - l_style = LINE_STYLE["idling"] + l_style = self.LINE_STYLE["idling"] attrs = '[label="%s", color="%s", style="%s"]' % ( "sec%d" % sec["client-id"], - SEC_COLORS[sec["client-id"]], + self.SEC_COLORS[sec["client-id"]], l_style ) link_style = node_template + ' {} ' + node_template + '{};' @@ -191,11 +185,11 @@ class SppTopo(object): if self._is_valid_port(patch['dst']): dst_type, dst_id = patch['dst'].split(':') - tmp = link_style.format(src_type, src_id, LINK_TYPE, + tmp = link_style.format(src_type, src_id, self.LINK_TYPE, dst_type, dst_id, attrs) links.append(tmp) - output = ["{} spp{{".format(GRAPH_TYPE)] + output = ["{} spp{{".format(self.GRAPH_TYPE)] output.append("newrank=true;") output.append(node_attrs) @@ -209,7 +203,7 @@ class SppTopo(object): label = re.sub(r'{}'.format(self.delim_node), ':', node) output.append( '{n}[label="{l}", fillcolor="{c}"];'.format( - n=node, l=label, c=PORT_COLORS["phy"])) + n=node, l=label, c=self.PORT_COLORS["phy"])) ring_nodes = [] for node in rings: @@ -220,7 +214,7 @@ class SppTopo(object): label = re.sub(r'{}'.format(self.delim_node), ':', node) output.append( '{n}[label="{l}", fillcolor="{c}"];'.format( - n=node, l=label, c=PORT_COLORS["ring"])) + n=node, l=label, c=self.PORT_COLORS["ring"])) vhost_nodes = [] for node in vhosts: @@ -231,7 +225,7 @@ class SppTopo(object): label = re.sub(r'{}'.format(self.delim_node), ':', node) output.append( '{n}[label="{l}", fillcolor="{c}"];'.format( - n=node, l=label, c=PORT_COLORS["vhost"])) + n=node, l=label, c=self.PORT_COLORS["vhost"])) # Align the same type of nodes with rank attribute output.append( diff --git a/src/cli/config/default.yml b/src/cli/config/default.yml index a746c9a..60aaef7 100644 --- a/src/cli/config/default.yml +++ b/src/cli/config/default.yml @@ -5,9 +5,6 @@ max_secondary: prompt: val: "spp > " desc: Command prompt -topo_size: - val: 60% - desc: Percentage or ratio of topo # Secondary common config sec_mem: @@ -45,3 +42,8 @@ sec_pcap_nof_lcores: sec_pcap_port: val: "phy:0" desc: Default captured port + +# topo +topo_size: + val: 60% + desc: Percentage or ratio of topo diff --git a/src/cli/config/topo.yml b/src/cli/config/topo.yml new file mode 100644 index 0000000..fa5497e --- /dev/null +++ b/src/cli/config/topo.yml @@ -0,0 +1,8 @@ +topo_sec_colors: + val: ["blue", "green", "orange", "chocolate", "black", "cyan3", + "green3", "indianred", "lawngreen", "limegreen"] + desc: Line colors for secondary processes +topo_port_colors: + val: {"phy": "white", "ring": "yellow", "vhost": "azure", + "tap": "cornsilk", "nullpmd": "cyan"} + desc: Port colors diff --git a/src/cli/shell.py b/src/cli/shell.py index d98cc8b..8eae982 100644 --- a/src/cli/shell.py +++ b/src/cli/shell.py @@ -73,7 +73,7 @@ class Shell(cmd.Cmd, object): self.use_cache = use_cache self.init_spp_procs() self.spp_topo = topo.SppTopo( - self.spp_ctl_cli, {}, self.cli_config['topo_size']['val']) + self.spp_ctl_cli, {}, self.cli_config) common.set_current_server_addr( self.spp_ctl_cli.ip_addr, self.spp_ctl_cli.port) -- 2.17.1