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 E4E15293B for ; Thu, 25 Oct 2018 07:20:38 +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 w9P5Kbi4007557; Thu, 25 Oct 2018 14:20:37 +0900 Received: from vc1.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id D4B07EA7CFC; Thu, 25 Oct 2018 14:20:37 +0900 (JST) Received: from localhost.localdomain (unknown [129.60.13.51]) by vc1.ecl.ntt.co.jp (Postfix) with ESMTP id BD3F9EA7C7B; Thu, 25 Oct 2018 14:20:37 +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:20:21 +0900 Message-Id: <20181025052023.17190-4-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20181025052023.17190-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20181025052023.17190-1-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH 3/5] controller: change pri exit cmd to call REST API 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:20:39 -0000 From: Yasufumi Ogawa To send `exit` command to spp_primary, change to call REST API of spp-ctl. This patch includes update for removing `exit` from `pri` command to avoid terminating spp_primary while running secondary processes. Use `bye all` command for graceful terminating. Signed-off-by: Yasufumi Ogawa --- src/controller/commands/bye.py | 2 +- src/controller/commands/pri.py | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/controller/commands/bye.py b/src/controller/commands/bye.py index e5ca3bb..3ffc259 100644 --- a/src/controller/commands/bye.py +++ b/src/controller/commands/bye.py @@ -28,7 +28,7 @@ class SppBye(object): print('Closing secondary ...') self.close_all_secondary(sec_ids) print('Closing primary ...') - self.spp_primary.run('exit') + self.spp_primary.do_exit() def complete(self, text, line, begidx, endidx): diff --git a/src/controller/commands/pri.py b/src/controller/commands/pri.py index b51138d..51da7ab 100644 --- a/src/controller/commands/pri.py +++ b/src/controller/commands/pri.py @@ -13,7 +13,7 @@ class SppPrimary(object): """ # All of primary commands used for validation and completion. - PRI_CMDS = ['status', 'exit', 'clear'] + PRI_CMDS = ['status', 'clear'] def __init__(self, spp_ctl_cli): self.spp_ctl_cli = spp_ctl_cli @@ -46,12 +46,20 @@ class SppPrimary(object): else: print('Error: unknown response.') - elif cmd == 'exit': - print('"pri; exit" is deprecated.') - else: print('Invalid pri command!') + def do_exit(self): + res = self.spp_ctl_cli.delete('primary') + if res is not None: + error_codes = self.spp_ctl_cli.rest_common_error_codes + if res.status_code == 204: + print('Exit primary') + elif res.status_code in error_codes: + pass + else: + print('Error: unknown response.') + def print_status(self, json_obj): """Parse SPP primary's status and print. -- 2.7.4