From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from tama500.ecl.ntt.co.jp (tama500.ecl.ntt.co.jp [129.60.39.148]) by dpdk.org (Postfix) with ESMTP id D33502C2F for ; Thu, 25 Oct 2018 07:19:54 +0200 (CEST) Received: from vc1.ecl.ntt.co.jp (vc1.ecl.ntt.co.jp [129.60.86.153]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id w9P5JrW9007520; Thu, 25 Oct 2018 14:19:53 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id BB50CEA7CFC; Thu, 25 Oct 2018 14:19:53 +0900 (JST) Received: from localhost.localdomain (unknown [129.60.13.51]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 9F735EA7CEC; Thu, 25 Oct 2018 14:19:53 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Date: Thu, 25 Oct 2018 14:19:40 +0900 Message-Id: <20181025051943.17129-3-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20181025051943.17129-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20181025051943.17129-1-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH 2/5] spp-ctl: add exit cmd support for spp_nfv X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Oct 2018 05:19:55 -0000 From: Yasufumi Ogawa 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 --- 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('/', 'GET', callback=self.nfv_get) + self.route('/', 'DELETE', callback=self.nfv_exit) self.route('//forward', 'PUT', callback=self.nfv_forward) self.route('//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