From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH v2 2/5] spp-ctl: add exit cmd support for spp_primary
Date: Fri, 9 Nov 2018 12:21:35 +0900 [thread overview]
Message-ID: <20181109032138.90520-3-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20181109032138.90520-1-ogawa.yasufumi@lab.ntt.co.jp>
From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Spp-ctl does not support to exit spp_primary, but it is required using
from `spp.py`. This update is to add a REST API for exiting the process.
This update is includes to change prefix of args of do_exit() in
`spp_ctl.py` from `sec_` to `proc_` because this method supports both
of primary and secondary by this change.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Reviewed-by: Itsuro Oda <oda@valinux.co.jp>
---
src/spp-ctl/spp_ctl.py | 14 +++++++-------
src/spp-ctl/spp_proc.py | 4 ++++
src/spp-ctl/spp_webapi.py | 6 ++++++
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/src/spp-ctl/spp_ctl.py b/src/spp-ctl/spp_ctl.py
index 81a2fe0..a22d589 100644
--- a/src/spp-ctl/spp_ctl.py
+++ b/src/spp-ctl/spp_ctl.py
@@ -141,14 +141,14 @@ class Controller(object):
procs.append(p)
return procs
- def do_exit(self, sec_type, sec_id):
- target_key = None
- for k, proc in self.procs.items():
- if proc.type == sec_type and proc.id == sec_id:
- target_key = k
+ def do_exit(self, proc_type, proc_id):
+ removed_id = None # remove proc info of ID from self.procs
+ for proc in self.procs.values():
+ if proc.type == proc_type and proc.id == proc_id:
+ removed_id = proc.id
break
- if target_key is not None:
- del self.procs[target_key]
+ if removed_id is not None:
+ del self.procs[removed_id]
def main():
diff --git a/src/spp-ctl/spp_proc.py b/src/spp-ctl/spp_proc.py
index aa928f2..83c59ea 100644
--- a/src/spp-ctl/spp_proc.py
+++ b/src/spp-ctl/spp_proc.py
@@ -189,3 +189,7 @@ class PrimaryProc(SppProc):
@exec_command
def clear(self):
return "clear"
+
+ @exec_command
+ def do_exit(self):
+ return "exit"
diff --git a/src/spp-ctl/spp_webapi.py b/src/spp-ctl/spp_webapi.py
index 8332cab..49ef971 100644
--- a/src/spp-ctl/spp_webapi.py
+++ b/src/spp-ctl/spp_webapi.py
@@ -395,6 +395,7 @@ class V1PrimaryHandler(BaseHandler):
def set_route(self):
self.route('/status', 'GET', callback=self.get_status)
self.route('/status', 'DELETE', callback=self.clear_status)
+ self.route('/', 'DELETE', callback=self.pri_exit)
def _get_proc(self):
proc = self.ctrl.procs.get(spp_proc.ID_PRIMARY)
@@ -417,3 +418,8 @@ class V1PrimaryHandler(BaseHandler):
def clear_status(self):
proc = self._get_proc()
proc.clear()
+
+ def pri_exit(self):
+ proc = self._get_proc()
+ self.ctrl.do_exit(proc.type, proc.id)
+ proc.do_exit()
--
2.7.4
next prev parent reply other threads:[~2018-11-09 3:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-25 5:20 [spp] [PATCH 0/5] Add exit command " ogawa.yasufumi
2018-10-25 5:20 ` [spp] [PATCH 1/5] primary: chage to return msg of exit command ogawa.yasufumi
2018-10-25 5:20 ` [spp] [PATCH 2/5] spp-ctl: add exit cmd support for spp_primary ogawa.yasufumi
2018-10-25 5:20 ` [spp] [PATCH 3/5] controller: change pri exit cmd to call REST API ogawa.yasufumi
2018-10-25 5:20 ` [spp] [PATCH 4/5] docs: add DELETE method for exiting spp_primary ogawa.yasufumi
2018-10-25 5:20 ` [spp] [PATCH 5/5] docs: remove exit from pri command ogawa.yasufumi
2018-11-09 3:21 ` [spp] [PATCH v2 0/5] Add exit command support for spp_primary ogawa.yasufumi
2018-11-09 3:21 ` [spp] [PATCH v2 1/5] primary: chage to return msg of exit command ogawa.yasufumi
2018-11-09 3:21 ` ogawa.yasufumi [this message]
2018-11-09 3:21 ` [spp] [PATCH v2 3/5] controller: change pri exit cmd to call REST API ogawa.yasufumi
2018-11-09 3:21 ` [spp] [PATCH v2 4/5] docs: add DELETE method for exiting spp_primary ogawa.yasufumi
2018-11-09 3:21 ` [spp] [PATCH v2 5/5] docs: remove exit from pri command 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=20181109032138.90520-3-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).