* [spp] [PATCH 1/2] cli: enable to add pipe without forwarder
2020-04-12 23:02 [spp] [PATCH 0/2] enabel to add pipe withcout forwarder Itsuro Oda
@ 2020-04-12 23:02 ` Itsuro Oda
2020-04-12 23:02 ` [spp] [PATCH 2/2] cli: fix status display of pipes Itsuro Oda
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Itsuro Oda @ 2020-04-12 23:02 UTC (permalink / raw)
To: spp, ferruh.yigit, yasufum.o
Pipe port is independent of the forwarder but it can be added
only if the forwarder exists currently.
This patch enables to add pipe port even if the forwarder does
not exist.
Fixes: 427350f31cfe (cli: support pipe PMD)
Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
src/cli/commands/pri.py | 35 +++++++++++++++++++++++------------
1 file changed, 23 insertions(+), 12 deletions(-)
diff --git a/src/cli/commands/pri.py b/src/cli/commands/pri.py
index 6fc7f00..3f5da29 100644
--- a/src/cli/commands/pri.py
+++ b/src/cli/commands/pri.py
@@ -49,6 +49,9 @@ class SppPrimary(object):
self.flow = SppPrimaryFlow(spp_ctl_cli)
+ def _port_is_pipe(self, params):
+ return len(params) > 0 and params[0].startswith("pipe:")
+
def _do_if_forwarder_exists(self, status, func, params):
"""Execute command of func if forwarder thread is existing.
@@ -103,10 +106,16 @@ class SppPrimary(object):
print('Error: unknown response from status.')
elif subcmd == 'add':
- self._do_if_forwarder_exists(status, self._run_add, params)
+ if self._port_is_pipe(params):
+ self._run_add(params, is_pipe=True)
+ else:
+ self._do_if_forwarder_exists(status, self._run_add, params)
elif subcmd == 'del':
- self._do_if_forwarder_exists(status, self._run_del, params)
+ if self._port_is_pipe(params):
+ self._run_del(params, is_pipe=True)
+ else:
+ self._do_if_forwarder_exists(status, self._run_del, params)
elif subcmd == 'forward' or subcmd == 'stop':
self._do_if_forwarder_exists(status,
@@ -795,7 +804,7 @@ class SppPrimary(object):
index += 1
return opts_dict
- def _run_add(self, params):
+ def _run_add(self, params, is_pipe=False):
"""Run `add` command."""
if len(params) == 0:
@@ -819,12 +828,13 @@ class SppPrimary(object):
else:
print('Error: unknown response for add.')
- self.ports = self._get_ports() # update to current status
- if self.ports is None:
- print('Cannot retrieve ports from spp_primary')
- self.ports = []
+ if not is_pipe:
+ self.ports = self._get_ports() # update to current status
+ if self.ports is None:
+ print('Cannot retrieve ports from spp_primary')
+ self.ports = []
- def _run_del(self, params):
+ def _run_del(self, params, is_pipe=False):
"""Run `del` command."""
if len(params) == 0:
@@ -849,10 +859,11 @@ class SppPrimary(object):
else:
print('Error: unknown response for del.')
- self.patches = self._get_patches() # update to current status
- if self.patches is None:
- print('Cannot retrieve patches from spp_primary')
- self.patches = []
+ if not is_pipe:
+ self.patches = self._get_patches() # update to current status
+ if self.patches is None:
+ print('Cannot retrieve patches from spp_primary')
+ self.patches = []
def _run_forward_or_stop(self, cmd):
"""Run `forward` or `stop` command."""
--
2.17.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [spp] [PATCH 2/2] cli: fix status display of pipes
2020-04-12 23:02 [spp] [PATCH 0/2] enabel to add pipe withcout forwarder Itsuro Oda
2020-04-12 23:02 ` [spp] [PATCH 1/2] cli: enable to add pipe without forwarder Itsuro Oda
@ 2020-04-12 23:02 ` Itsuro Oda
2020-04-30 2:41 ` [spp] (x-fn-spp-ml 677) [PATCH 0/2] enabel to add pipe withcout forwarder Hideyuki Yamashita
2020-05-25 3:10 ` [spp] " Yasufumi Ogawa
3 siblings, 0 replies; 5+ messages in thread
From: Itsuro Oda @ 2020-04-12 23:02 UTC (permalink / raw)
To: spp, ferruh.yigit, yasufum.o
This patch fixes the indent of pipes in the status display of
the spp_primary. It should be the most left side because it
is a top attribute of json response.
Fixes: 427350f31cfe (cli: support pipe PMD)
Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
---
src/cli/commands/pri.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/cli/commands/pri.py b/src/cli/commands/pri.py
index 3f5da29..77297b3 100644
--- a/src/cli/commands/pri.py
+++ b/src/cli/commands/pri.py
@@ -239,9 +239,9 @@ class SppPrimary(object):
print(' - {} -> {}'.format(port, dst))
if ('pipes' in json_obj):
- print(' - pipes:')
+ print('- pipes:')
for pipe in json_obj['pipes']:
- print(' - pipe:{} ring:{} ring:{}'.format(pipe['id'],
+ print(' - pipe:{} ring:{} ring:{}'.format(pipe['id'],
pipe['rx'], pipe['tx']))
if ('phy_ports' in json_obj) or ('ring_ports' in json_obj):
--
2.17.0
^ permalink raw reply [flat|nested] 5+ messages in thread