[spp] [PATCH 1/2] cli: enable to add pipe without forwarder
Itsuro Oda
oda at valinux.co.jp
Mon Apr 13 01:02:20 CEST 2020
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 at 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
More information about the spp
mailing list