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 365201BDB5 for ; Fri, 21 Dec 2018 10:28:37 +0100 (CET) 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 wBL9Sbb0019735; Fri, 21 Dec 2018 18:28:37 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id 05C28EA83F2; Fri, 21 Dec 2018 18:28:37 +0900 (JST) Received: from localhost.localdomain (lobster.nslab.ecl.ntt.co.jp [129.60.13.95]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id E47C8EA8300; Fri, 21 Dec 2018 18:28:36 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: ferruh.yigit@intel.com, spp@dpdk.org, ogawa.yasufumi@lab.ntt.co.jp Date: Fri, 21 Dec 2018 18:26:18 +0900 Message-Id: <1545384379-12389-2-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1545384379-12389-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> References: <1545384379-12389-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH 1/2] controller: add exit command to vf and mirror 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: Fri, 21 Dec 2018 09:28:38 -0000 From: Yasufumi Ogawa 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 --- 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