Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 2/5] spp-ctl: add exit cmd support for spp_nfv
Date: Thu, 25 Oct 2018 14:19:40 +0900	[thread overview]
Message-ID: <20181025051943.17129-3-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20181025051943.17129-1-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

Spp-ctl does not support exit spp_nfv and spp_vm, but it is required
using from `spp.py`. This update is to add a REST API for exiting the
process. It also add `do_exit()` method into spp-ctl to send `exit`
command to spp_nfv.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/spp-ctl/spp_ctl.py    | 9 +++++++++
 src/spp-ctl/spp_proc.py   | 4 ++++
 src/spp-ctl/spp_webapi.py | 5 +++++
 3 files changed, 18 insertions(+)

diff --git a/src/spp-ctl/spp_ctl.py b/src/spp-ctl/spp_ctl.py
index 80a78b6..81a2fe0 100644
--- a/src/spp-ctl/spp_ctl.py
+++ b/src/spp-ctl/spp_ctl.py
@@ -141,6 +141,15 @@ 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
+                break
+        if target_key is not None:
+            del self.procs[target_key]
+
 
 def main():
     parser = argparse.ArgumentParser(description="SPP Controller")
diff --git a/src/spp-ctl/spp_proc.py b/src/spp-ctl/spp_proc.py
index 3b01e3f..aa928f2 100644
--- a/src/spp-ctl/spp_proc.py
+++ b/src/spp-ctl/spp_proc.py
@@ -168,6 +168,10 @@ class NfvProc(SppProc):
     def stop(self):
         return "stop"
 
+    @exec_command
+    def do_exit(self):
+        return "exit"
+
 
 class PrimaryProc(SppProc):
 
diff --git a/src/spp-ctl/spp_webapi.py b/src/spp-ctl/spp_webapi.py
index b2fbe3b..8332cab 100644
--- a/src/spp-ctl/spp_webapi.py
+++ b/src/spp-ctl/spp_webapi.py
@@ -310,6 +310,7 @@ class V1NFVHandler(BaseHandler):
 
     def set_route(self):
         self.route('/<sec_id:int>', 'GET', callback=self.nfv_get)
+        self.route('/<sec_id:int>', 'DELETE', callback=self.nfv_exit)
         self.route('/<sec_id:int>/forward', 'PUT',
                    callback=self.nfv_forward)
         self.route('/<sec_id:int>/ports', 'PUT',
@@ -377,6 +378,10 @@ class V1NFVHandler(BaseHandler):
     def nfv_patch_del(self, proc):
         proc.patch_reset()
 
+    def nfv_exit(self, proc):
+        self.ctrl.do_exit(proc.type, proc.id)
+        proc.do_exit()
+
 
 class V1PrimaryHandler(BaseHandler):
 
-- 
2.7.4

  parent reply	other threads:[~2018-10-25  5:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25  5:19 [spp] [PATCH 0/5] Add exit command support for spp_nfv and spp_vm ogawa.yasufumi
2018-10-25  5:19 ` [spp] [PATCH 1/5] spp_nfv: chage to return msg of exit command ogawa.yasufumi
2018-10-25  5:19 ` ogawa.yasufumi [this message]
2018-10-25  5:19 ` [spp] [PATCH 3/5] spp_vm: " ogawa.yasufumi
2018-10-25  5:19 ` [spp] [PATCH 4/5] controller: update sec exit cmd to call REST API ogawa.yasufumi
2018-10-25  5:19 ` [spp] [PATCH 5/5] docs: add DELETE method for exiting spp_nfv 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=20181025051943.17129-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).