From: Yasufumi Ogawa <yasufum.o@gmail.com>
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH 6/8] cli: add port types for topo command
Date: Mon, 12 Aug 2019 16:12:40 +0900 [thread overview]
Message-ID: <20190812071242.18934-7-yasufum.o@gmail.com> (raw)
In-Reply-To: <20190812071242.18934-1-yasufum.o@gmail.com>
To depict spp_pcap's output file and tap device as a port, add these
types to port type list. This update is also to fix wrong coding style.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/cli/commands/topo.py | 66 +++++++++++++++++++++++-----------------
src/cli/shell.py | 3 +-
2 files changed, 40 insertions(+), 29 deletions(-)
diff --git a/src/cli/commands/topo.py b/src/cli/commands/topo.py
index bfd92f0..2e1bc3d 100644
--- a/src/cli/commands/topo.py
+++ b/src/cli/commands/topo.py
@@ -108,9 +108,9 @@ class SppTopo(object):
"""Output dot script."""
node_attrs = 'node[shape="rectangle", style="filled"];'
- node_template = '{}' + self.delim_node + '{}'
+ node_temp = '{}' + self.delim_node + '{}'
- ports, links = self._get_dot_elements(node_template)
+ ports, links = self._get_dot_elements(node_temp)
# Remove duplicated entries.
for ptype in spp_common.PORT_TYPES:
@@ -120,15 +120,18 @@ class SppTopo(object):
output.append("newrank=true;")
output.append(node_attrs)
+ # topo should support spp_pcap's file and tap port
+ all_port_types = spp_common.PORT_TYPES + [
+ self.SPP_PCAP_LABEL, 'tap']
+
# Setup node entries
- all_port_types = spp_common.PORT_TYPES + [self.SPP_PCAP_LABEL]
nodes = {}
for ptype in all_port_types:
nodes[ptype] = []
for node in ports[ptype]:
r_type, r_id = node.split(':')
nodes[ptype].append(
- node_template.format(r_type, r_id))
+ node_temp.format(r_type, r_id))
nodes[ptype] = list(set(nodes[ptype]))
for node in nodes[ptype]:
label = re.sub(r'{}'.format(self.delim_node), ':', node)
@@ -144,7 +147,7 @@ class SppTopo(object):
# Decide the bottom, phy or vhost
# TODO(yasufum) revise how to decide bottom
- rank_style = '{{rank=max; ' + node_template + '}}'
+ rank_style = '{{rank=max; ' + node_temp + '}}'
if len(ports['phy']) > 0:
r_type, r_id = ports['phy'][0].split(':')
elif len(ports['vhost']) > 0:
@@ -406,7 +409,7 @@ class SppTopo(object):
pass
return True
- def _get_dot_elements(self, node_template):
+ def _get_dot_elements(self, node_temp):
"""Get entries of nodes and links.
To generate dot script, this method returns ports as nodes and links
@@ -416,8 +419,10 @@ class SppTopo(object):
ports = {}
links = []
+ # topo should support spp_pcap's file and tap port
+ all_port_types = spp_common.PORT_TYPES + [self.SPP_PCAP_LABEL, 'tap']
+
# Initialize ports
- all_port_types = spp_common.PORT_TYPES + [self.SPP_PCAP_LABEL]
for ptype in all_port_types:
ports[ptype] = []
@@ -434,7 +439,7 @@ class SppTopo(object):
# TODO make it to a method
if self._is_valid_port(port):
r_type = port.split(':')[0]
- if r_type in spp_common.PORT_TYPES:
+ if r_type in all_port_types:
ports[r_type].append(port)
else:
raise ValueError(
@@ -446,7 +451,7 @@ class SppTopo(object):
port = c['rx_port'][0]['port']
if self._is_valid_port(port):
r_type = port.split(':')[0]
- if r_type in spp_common.PORT_TYPES:
+ if r_type in all_port_types:
ports[r_type].append(port)
else:
raise ValueError(
@@ -454,7 +459,7 @@ class SppTopo(object):
r_type))
ports[self.SPP_PCAP_LABEL].append(
'{}:{}'.format(self.SPP_PCAP_LABEL,
- sec['client-id']))
+ sec['client-id']))
# Get links
if proc_t == 'nfv':
@@ -467,14 +472,15 @@ class SppTopo(object):
"nfv:{}".format(sec["client-id"]),
self.SEC_COLORS[sec["client-id"]],
l_style)
- link_style = node_template + ' {} ' + node_template + '{};'
+ link_style = node_temp + ' {} ' + node_temp + '{};'
if self._is_valid_port(patch['src']):
src_type, src_id = patch['src'].split(':')
if self._is_valid_port(patch['dst']):
dst_type, dst_id = patch['dst'].split(':')
- tmp = link_style.format(src_type, src_id, self.LINK_TYPE,
+ tmp = link_style.format(src_type, src_id,
+ self.LINK_TYPE,
dst_type, dst_id, attrs)
links.append(tmp)
@@ -489,10 +495,9 @@ class SppTopo(object):
sec["client-id"], comp['type'][0]),
self.SEC_COLORS[sec["client-id"]],
l_style)
- link_style = node_template + ' {} ' + \
- node_template + '{};'
+ link_style = node_temp + ' {} ' + node_temp + '{};'
- if comp['type'] == 'forward': # TODO change to forwarder
+ if comp['type'] == 'forward':
rxport = comp['rx_port'][0]['port']
if self._is_valid_port(rxport):
src_type, src_id = rxport.split(':')
@@ -500,8 +505,9 @@ class SppTopo(object):
if self._is_valid_port(txport):
dst_type, dst_id = txport.split(':')
- tmp = link_style.format(src_type, src_id, self.LINK_TYPE,
- dst_type, dst_id, attrs)
+ tmp = link_style.format(src_type, src_id,
+ self.LINK_TYPE,
+ dst_type, dst_id, attrs)
links.append(tmp)
elif comp['type'] == 'classifier':
@@ -512,8 +518,10 @@ class SppTopo(object):
if self._is_valid_port(txp['port']):
dst_type, dst_id = txp['port'].split(':')
- tmp = link_style.format(src_type, src_id, self.LINK_TYPE,
- dst_type, dst_id, attrs)
+ tmp = link_style.format(src_type, src_id,
+ self.LINK_TYPE,
+ dst_type, dst_id,
+ attrs)
links.append(tmp)
elif comp['type'] == 'merge': # TODO change to merger
txport = comp['tx_port'][0]['port']
@@ -523,8 +531,10 @@ class SppTopo(object):
if self._is_valid_port(rxp['port']):
src_type, src_id = rxp['port'].split(':')
- tmp = link_style.format(src_type, src_id, self.LINK_TYPE,
- dst_type, dst_id, attrs)
+ tmp = link_style.format(src_type, src_id,
+ self.LINK_TYPE,
+ dst_type, dst_id,
+ attrs)
links.append(tmp)
elif proc_t == 'mirror':
@@ -537,8 +547,7 @@ class SppTopo(object):
"vf:{}".format(sec["client-id"]),
self.SEC_COLORS[sec["client-id"]],
l_style)
- link_style = node_template + ' {} ' + \
- node_template + '{};'
+ link_style = node_temp + ' {} ' + node_temp + '{};'
rxport = comp['rx_port'][0]['port']
if self._is_valid_port(rxport):
@@ -547,8 +556,9 @@ class SppTopo(object):
if self._is_valid_port(txp['port']):
dst_type, dst_id = txp['port'].split(':')
- tmp = link_style.format(src_type, src_id, self.LINK_TYPE,
- dst_type, dst_id, attrs)
+ tmp = link_style.format(src_type, src_id,
+ self.LINK_TYPE,
+ dst_type, dst_id, attrs)
links.append(tmp)
elif proc_t == 'pcap':
@@ -560,15 +570,15 @@ class SppTopo(object):
"pcap:{}".format(sec["client-id"]),
self.SEC_COLORS[sec["client-id"]],
l_style)
- link_style = node_template + ' {} ' + node_template + '{};'
+ link_style = node_temp + ' {} ' + node_temp + '{};'
for c in sec['core']: # TODO consider change to component
if c['role'] == 'receive': # TODO change to receiver
rxport = c['rx_port'][0]['port']
if self._is_valid_port(rxport):
src_type, src_id = rxport.split(':')
- dst_type, dst_id = self.SPP_PCAP_LABEL, sec['client-id']
-
+ dst_type = self.SPP_PCAP_LABEL
+ dst_id = sec['client-id']
tmp = link_style.format(src_type, src_id, self.LINK_TYPE,
dst_type, dst_id, attrs)
links.append(tmp)
diff --git a/src/cli/shell.py b/src/cli/shell.py
index ebea911..925c231 100644
--- a/src/cli/shell.py
+++ b/src/cli/shell.py
@@ -614,7 +614,8 @@ class Shell(cmd.Cmd, object):
if key == 'prompt':
self.prompt = self.cli_config['prompt']['val']
elif key == 'topo_size':
- self.spp_topo.resize(self.cli_config['topo_size']['val'])
+ self.spp_topo.resize(
+ self.cli_config['topo_size']['val'])
def help_config(self):
"""Print help message of config command."""
--
2.17.1
next prev parent reply other threads:[~2019-08-12 7:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-12 7:12 [spp] [PATCH 0/8] Update topo to support other than spp_nfv Yasufumi Ogawa
2019-08-12 7:12 ` [spp] [PATCH 1/8] cli: remove topo_resize command Yasufumi Ogawa
2019-08-12 7:12 ` [spp] [PATCH 2/8] cli: revise composing dot script Yasufumi Ogawa
2019-08-12 7:12 ` [spp] [PATCH 3/8] cli: move style params for dot to config Yasufumi Ogawa
2019-08-12 7:12 ` [spp] [PATCH 4/8] cli: add to get sec ID and procs to SppCtlClient Yasufumi Ogawa
2019-08-12 7:12 ` [spp] [PATCH 5/8] cli: support other than spp_nfv in topo command Yasufumi Ogawa
2019-08-12 7:12 ` Yasufumi Ogawa [this message]
2019-08-12 7:12 ` [spp] [PATCH 7/8] cli: add checking JSON objs in topo Yasufumi Ogawa
2019-08-12 7:12 ` [spp] [PATCH 8/8] cli: revise description for imgcat Yasufumi Ogawa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190812071242.18934-7-yasufum.o@gmail.com \
--to=yasufum.o@gmail.com \
--cc=ferruh.yigit@intel.com \
--cc=spp@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).