From: ogawa.yasufumi@lab.ntt.co.jp
To: ferruh.yigit@intel.com, spp@dpdk.org, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 1/2] controller: add exit command to vf and mirror
Date: Fri, 21 Dec 2018 18:26:18 +0900 [thread overview]
Message-ID: <1545384379-12389-2-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1545384379-12389-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Since `exit` is added to spp_vf and spp_mirror, add `exit` command to
CLI. `bye` command is also updated to terminate all of secondaries
including spp_vf and spp_mirror at once.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/controller/commands/bye.py | 6 ++----
src/controller/commands/mirror.py | 16 ++++++++++++++++
src/controller/commands/vf.py | 16 ++++++++++++++++
3 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/src/controller/commands/bye.py b/src/controller/commands/bye.py
index af77b08..cd14961 100644
--- a/src/controller/commands/bye.py
+++ b/src/controller/commands/bye.py
@@ -45,7 +45,5 @@ class SppBye(object):
"""Terminate all secondary processes."""
for sec_type, spp_procs in spp_secondaries.items():
- # TODO(yasufum) Remove if they support exit command.
- if not (sec_type in ['vf', 'mirror']):
- for sec in spp_procs.values():
- sec.run('exit')
+ for sec in spp_procs.values():
+ sec.run('exit')
diff --git a/src/controller/commands/mirror.py b/src/controller/commands/mirror.py
index fcc630a..a01e1eb 100644
--- a/src/controller/commands/mirror.py
+++ b/src/controller/commands/mirror.py
@@ -69,6 +69,9 @@ class SppMirror(object):
elif cmd == 'port':
self._run_port(params)
+ elif cmd == 'exit':
+ self._run_exit()
+
else:
print('Invalid command "%s".' % cmd)
@@ -272,6 +275,19 @@ class SppMirror(object):
else:
print('Error: unknown response.')
+ def _run_exit(self):
+ """Run `exit` command."""
+
+ res = self.spp_ctl_cli.delete('mirrors/%d' % self.sec_id)
+ if res is not None:
+ error_codes = self.spp_ctl_cli.rest_common_error_codes
+ if res.status_code == 204:
+ print('Exit mirror %d.' % self.sec_id)
+ elif res.status_code in error_codes:
+ pass
+ else:
+ print('Error: unknown response.')
+
def _compl_component(self, sub_tokens):
if len(sub_tokens) < 6:
subsub_cmds = ['start', 'stop']
diff --git a/src/controller/commands/vf.py b/src/controller/commands/vf.py
index 8828110..01795a5 100644
--- a/src/controller/commands/vf.py
+++ b/src/controller/commands/vf.py
@@ -73,6 +73,9 @@ class SppVf(object):
elif cmd == 'classifier_table':
self._run_cls_table(params)
+ elif cmd == 'exit':
+ self._run_exit()
+
else:
print('Invalid command "%s".' % cmd)
@@ -347,6 +350,19 @@ class SppVf(object):
else:
print('Error: unknown response.')
+ def _run_exit(self):
+ """Run `exit` command."""
+
+ res = self.spp_ctl_cli.delete('vfs/%d' % self.sec_id)
+ if res is not None:
+ error_codes = self.spp_ctl_cli.rest_common_error_codes
+ if res.status_code == 204:
+ print('Exit vf %d.' % self.sec_id)
+ elif res.status_code in error_codes:
+ pass
+ else:
+ print('Error: unknown response.')
+
def _compl_component(self, sub_tokens):
if len(sub_tokens) < 6:
subsub_cmds = ['start', 'stop']
--
2.7.4
next prev parent reply other threads:[~2018-12-21 9:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-21 9:26 [spp] [PATCH 0/2] Update SPP controller ogawa.yasufumi
2018-12-21 9:26 ` ogawa.yasufumi [this message]
2018-12-21 9:26 ` [spp] [PATCH 2/2] spp-ctl: add spp_pcap APIs ogawa.yasufumi
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=1545384379-12389-2-git-send-email-ogawa.yasufumi@lab.ntt.co.jp \
--to=ogawa.yasufumi@lab.ntt.co.jp \
--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).