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 748091BE0 for ; Fri, 9 Nov 2018 04:21:51 +0100 (CET) Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama500.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id wA93LoSZ030425; Fri, 9 Nov 2018 12:21:50 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 4B65F6384B7; Fri, 9 Nov 2018 12:21:50 +0900 (JST) Received: from localhost.localdomain (unknown [129.60.13.51]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 33A12638493; Fri, 9 Nov 2018 12:21:50 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Date: Fri, 9 Nov 2018 12:21:36 +0900 Message-Id: <20181109032138.90520-4-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20181109032138.90520-1-ogawa.yasufumi@lab.ntt.co.jp> References: <20181025052023.17190-1-ogawa.yasufumi@lab.ntt.co.jp> <20181109032138.90520-1-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH v2 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: Fri, 09 Nov 2018 03:21:52 -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