Soft Patch Panel
 help / color / mirror / Atom feed
* [spp] [PATCH 0/5] Add exit command support for spp_primary
@ 2018-10-25  5:20 ogawa.yasufumi
  2018-10-25  5:20 ` [spp] [PATCH 1/5] primary: chage to return msg of exit command ogawa.yasufumi
                   ` (5 more replies)
  0 siblings, 6 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-10-25  5:20 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

Hi,

SPP controller does not support `exit` command after it is changed to
request via `spp-ctl` because REST APIs for `exit` command is not
implemented. This series of patches is to add `exit' command for
spp_primary.

Thanks,
Yasufumi

Yasufumi Ogawa (5):
  primary: chage to return msg of exit command
  spp-ctl: add exit cmd support for spp_primary
  controller: change pri exit cmd to call REST API
  docs: add DELETE method for exiting spp_primary
  docs: remove exit from pri command

 docs/guides/commands/primary.rst      | 16 ----------------
 docs/guides/spp-ctl/api-reference.rst | 22 +++++++++++++++++++++-
 src/controller/commands/bye.py        |  2 +-
 src/controller/commands/pri.py        | 16 ++++++++++++----
 src/primary/main.c                    | 10 ++++++----
 src/spp-ctl/spp_proc.py               |  4 ++++
 src/spp-ctl/spp_webapi.py             |  6 ++++++
 7 files changed, 50 insertions(+), 26 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [spp] [PATCH 1/5] primary: chage to return msg of exit command
  2018-10-25  5:20 [spp] [PATCH 0/5] Add exit command support for spp_primary ogawa.yasufumi
@ 2018-10-25  5:20 ` ogawa.yasufumi
  2018-10-25  5:20 ` [spp] [PATCH 2/5] spp-ctl: add exit cmd support for spp_primary ogawa.yasufumi
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-10-25  5:20 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

This patch is to fix error of receiving data of PrimaryProc in spp-ctl.
Spp_primary returns no message after exit command while spp-ctl expects
to get any of message as a result. To fix, change to return empty
message.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/primary/main.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/primary/main.c b/src/primary/main.c
index 33f4143..d991bca 100644
--- a/src/primary/main.c
+++ b/src/primary/main.c
@@ -383,6 +383,7 @@ main(int argc, char *argv[])
 	int sock = SOCK_RESET;
 	int connected = 0;
 	char str[MSG_SIZE];
+	int flg_exit;  // used as res of parse_command() to exit if -1
 	int ret;
 
 	/* Register signals */
@@ -413,13 +414,14 @@ main(int argc, char *argv[])
 
 		RTE_LOG(DEBUG, APP, "Received string: %s\n", str);
 
-		ret = parse_command(str);
-		if (ret < 0)
-			break;
+		flg_exit = parse_command(str);
 
 		/* Send the message back to client */
 		ret = do_send(&connected, &sock, str);
-		if (ret < 0)
+
+		if (flg_exit < 0)  /* terminate process if exit is called */
+			break;
+		else if (ret < 0)
 			continue;
 	}
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [spp] [PATCH 2/5] spp-ctl: add exit cmd support for spp_primary
  2018-10-25  5:20 [spp] [PATCH 0/5] Add exit command support for spp_primary ogawa.yasufumi
  2018-10-25  5:20 ` [spp] [PATCH 1/5] primary: chage to return msg of exit command ogawa.yasufumi
@ 2018-10-25  5:20 ` ogawa.yasufumi
  2018-10-25  5:20 ` [spp] [PATCH 3/5] controller: change pri exit cmd to call REST API ogawa.yasufumi
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-10-25  5:20 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

Spp-ctl does not support to exit spp_primary, but it is required using
from `spp.py`. This update is to add a REST API for exiting the process.

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

diff --git a/src/spp-ctl/spp_proc.py b/src/spp-ctl/spp_proc.py
index aa928f2..83c59ea 100644
--- a/src/spp-ctl/spp_proc.py
+++ b/src/spp-ctl/spp_proc.py
@@ -189,3 +189,7 @@ class PrimaryProc(SppProc):
     @exec_command
     def clear(self):
         return "clear"
+
+    @exec_command
+    def do_exit(self):
+        return "exit"
diff --git a/src/spp-ctl/spp_webapi.py b/src/spp-ctl/spp_webapi.py
index 8332cab..8d0510c 100644
--- a/src/spp-ctl/spp_webapi.py
+++ b/src/spp-ctl/spp_webapi.py
@@ -395,6 +395,7 @@ class V1PrimaryHandler(BaseHandler):
     def set_route(self):
         self.route('/status', 'GET', callback=self.get_status)
         self.route('/status', 'DELETE', callback=self.clear_status)
+        self.route('/', 'DELETE', callback=self.do_exit)
 
     def _get_proc(self):
         proc = self.ctrl.procs.get(spp_proc.ID_PRIMARY)
@@ -417,3 +418,8 @@ class V1PrimaryHandler(BaseHandler):
     def clear_status(self):
         proc = self._get_proc()
         proc.clear()
+
+    def do_exit(self):
+        proc = self._get_proc()
+        self.ctrl.do_exit(proc.type, proc.id)
+        proc.do_exit()
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [spp] [PATCH 3/5] controller: change pri exit cmd to call REST API
  2018-10-25  5:20 [spp] [PATCH 0/5] Add exit command support for spp_primary ogawa.yasufumi
  2018-10-25  5:20 ` [spp] [PATCH 1/5] primary: chage to return msg of exit command ogawa.yasufumi
  2018-10-25  5:20 ` [spp] [PATCH 2/5] spp-ctl: add exit cmd support for spp_primary ogawa.yasufumi
@ 2018-10-25  5:20 ` ogawa.yasufumi
  2018-10-25  5:20 ` [spp] [PATCH 4/5] docs: add DELETE method for exiting spp_primary ogawa.yasufumi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-10-25  5:20 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

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 <ogawa.yasufumi@lab.ntt.co.jp>
---
 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [spp] [PATCH 4/5] docs: add DELETE method for exiting spp_primary
  2018-10-25  5:20 [spp] [PATCH 0/5] Add exit command support for spp_primary ogawa.yasufumi
                   ` (2 preceding siblings ...)
  2018-10-25  5:20 ` [spp] [PATCH 3/5] controller: change pri exit cmd to call REST API ogawa.yasufumi
@ 2018-10-25  5:20 ` ogawa.yasufumi
  2018-10-25  5:20 ` [spp] [PATCH 5/5] docs: remove exit from pri command ogawa.yasufumi
  2018-11-09  3:21 ` [spp] [PATCH v2 0/5] Add exit command support for spp_primary ogawa.yasufumi
  5 siblings, 0 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-10-25  5:20 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

To support `bye` command of `spp.py`, add DELETE method for
spp_primary.

  $ curl -X DELETE http://127.0.0.1:7777/v1/primary

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 docs/guides/spp-ctl/api-reference.rst | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/docs/guides/spp-ctl/api-reference.rst b/docs/guides/spp-ctl/api-reference.rst
index f0661c8..3c22cb9 100644
--- a/docs/guides/spp-ctl/api-reference.rst
+++ b/docs/guides/spp-ctl/api-reference.rst
@@ -253,7 +253,27 @@ Request example
 Response
 ^^^^^^^^
 
-There is no body content for the response of a successful ``PUT`` request.
+There is no body content for the response of a successful ``DELETE`` request.
+
+DELETE /v1/primary
+~~~~~~~~~~~~~~~~~~
+
+Terminate primary process.
+
+* Normal response codes: 204
+
+Request example
+^^^^^^^^^^^^^^^
+
+.. code-block:: console
+
+    curl -X DELETE -H 'application/json' \
+    http://127.0.0.1:7777/v1/primary
+
+Response
+^^^^^^^^
+
+There is no body content for the response of a successful ``DELETE`` request.
 
 
 API for spp_nfv/spp_vm
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [spp] [PATCH 5/5] docs: remove exit from pri command
  2018-10-25  5:20 [spp] [PATCH 0/5] Add exit command support for spp_primary ogawa.yasufumi
                   ` (3 preceding siblings ...)
  2018-10-25  5:20 ` [spp] [PATCH 4/5] docs: add DELETE method for exiting spp_primary ogawa.yasufumi
@ 2018-10-25  5:20 ` ogawa.yasufumi
  2018-11-09  3:21 ` [spp] [PATCH v2 0/5] Add exit command support for spp_primary ogawa.yasufumi
  5 siblings, 0 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-10-25  5:20 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

Update command reference for removing `exit` sub command of `pri` which
is not recommended to use.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 docs/guides/commands/primary.rst | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/docs/guides/commands/primary.rst b/docs/guides/commands/primary.rst
index e49f990..590461f 100644
--- a/docs/guides/commands/primary.rst
+++ b/docs/guides/commands/primary.rst
@@ -24,22 +24,6 @@ Show forwarding statistics of each of ports.
        1        9208        9203           0           5
        ...
 
-exit
-----
-
-Terminate primary process.
-
-.. code-block:: console
-
-    spp > pri; exit
-
-.. note::
-
-    You should not use this command if one or more secondary processes
-    are still running because terminating primary before secondaries may
-    cause an error. You shold use ``bye`` command instead of
-    ``pri; exit``.
-
 clear
 -----
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [spp] [PATCH v2 0/5] Add exit command support for spp_primary
  2018-10-25  5:20 [spp] [PATCH 0/5] Add exit command support for spp_primary ogawa.yasufumi
                   ` (4 preceding siblings ...)
  2018-10-25  5:20 ` [spp] [PATCH 5/5] docs: remove exit from pri command ogawa.yasufumi
@ 2018-11-09  3:21 ` ogawa.yasufumi
  2018-11-09  3:21   ` [spp] [PATCH v2 1/5] primary: chage to return msg of exit command ogawa.yasufumi
                     ` (4 more replies)
  5 siblings, 5 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-11-09  3:21 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

Hi,

This series of patches is to revise the names of methods and arguments
for the first patches.

* Refactor prefix of args of do_exit() from `sec_` to `proc_` because
  this method is changed to support not only sec but also pri.

* Change method name `do_exit()` in each of handlers defined in
  `spp_webapi.py` to avoid to be used the same name. It is more
  understandalbe `nfv_exit()' in V1NFVHandler than `do_exit()`.

Thanks,
Yasufumi

Yasufumi Ogawa (5):
  primary: chage to return msg of exit command
  spp-ctl: add exit cmd support for spp_primary
  controller: change pri exit cmd to call REST API
  docs: add DELETE method for exiting spp_primary
  docs: remove exit from pri command

 docs/guides/commands/primary.rst      | 16 ----------------
 docs/guides/spp-ctl/api-reference.rst | 22 +++++++++++++++++++++-
 src/controller/commands/bye.py        |  2 +-
 src/controller/commands/pri.py        | 16 ++++++++++++----
 src/primary/main.c                    | 10 ++++++----
 src/spp-ctl/spp_ctl.py                | 14 +++++++-------
 src/spp-ctl/spp_proc.py               |  4 ++++
 src/spp-ctl/spp_webapi.py             |  6 ++++++
 8 files changed, 57 insertions(+), 33 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [spp] [PATCH v2 1/5] primary: chage to return msg of exit command
  2018-11-09  3:21 ` [spp] [PATCH v2 0/5] Add exit command support for spp_primary ogawa.yasufumi
@ 2018-11-09  3:21   ` ogawa.yasufumi
  2018-11-09  3:21   ` [spp] [PATCH v2 2/5] spp-ctl: add exit cmd support for spp_primary ogawa.yasufumi
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-11-09  3:21 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

This patch is to fix error of receiving data of PrimaryProc in spp-ctl.
Spp_primary returns no message after exit command while spp-ctl expects
to get any of message as a result. To fix, change to return empty
message.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/primary/main.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/primary/main.c b/src/primary/main.c
index 33f4143..d991bca 100644
--- a/src/primary/main.c
+++ b/src/primary/main.c
@@ -383,6 +383,7 @@ main(int argc, char *argv[])
 	int sock = SOCK_RESET;
 	int connected = 0;
 	char str[MSG_SIZE];
+	int flg_exit;  // used as res of parse_command() to exit if -1
 	int ret;
 
 	/* Register signals */
@@ -413,13 +414,14 @@ main(int argc, char *argv[])
 
 		RTE_LOG(DEBUG, APP, "Received string: %s\n", str);
 
-		ret = parse_command(str);
-		if (ret < 0)
-			break;
+		flg_exit = parse_command(str);
 
 		/* Send the message back to client */
 		ret = do_send(&connected, &sock, str);
-		if (ret < 0)
+
+		if (flg_exit < 0)  /* terminate process if exit is called */
+			break;
+		else if (ret < 0)
 			continue;
 	}
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [spp] [PATCH v2 2/5] spp-ctl: add exit cmd support for spp_primary
  2018-11-09  3:21 ` [spp] [PATCH v2 0/5] Add exit command support for spp_primary ogawa.yasufumi
  2018-11-09  3:21   ` [spp] [PATCH v2 1/5] primary: chage to return msg of exit command ogawa.yasufumi
@ 2018-11-09  3:21   ` ogawa.yasufumi
  2018-11-09  3:21   ` [spp] [PATCH v2 3/5] controller: change pri exit cmd to call REST API ogawa.yasufumi
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-11-09  3:21 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

Spp-ctl does not support to exit spp_primary, but it is required using
from `spp.py`. This update is to add a REST API for exiting the process.

This update is includes to change prefix of args of do_exit() in
`spp_ctl.py` from `sec_` to `proc_` because this method supports both
of primary and secondary by this change.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
Reviewed-by: Itsuro Oda <oda@valinux.co.jp>
---
 src/spp-ctl/spp_ctl.py    | 14 +++++++-------
 src/spp-ctl/spp_proc.py   |  4 ++++
 src/spp-ctl/spp_webapi.py |  6 ++++++
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/spp-ctl/spp_ctl.py b/src/spp-ctl/spp_ctl.py
index 81a2fe0..a22d589 100644
--- a/src/spp-ctl/spp_ctl.py
+++ b/src/spp-ctl/spp_ctl.py
@@ -141,14 +141,14 @@ 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
+    def do_exit(self, proc_type, proc_id):
+            removed_id = None  # remove proc info of ID from self.procs
+        for proc in self.procs.values():
+            if proc.type == proc_type and proc.id == proc_id:
+                removed_id = proc.id
                 break
-        if target_key is not None:
-            del self.procs[target_key]
+        if removed_id is not None:
+            del self.procs[removed_id]
 
 
 def main():
diff --git a/src/spp-ctl/spp_proc.py b/src/spp-ctl/spp_proc.py
index aa928f2..83c59ea 100644
--- a/src/spp-ctl/spp_proc.py
+++ b/src/spp-ctl/spp_proc.py
@@ -189,3 +189,7 @@ class PrimaryProc(SppProc):
     @exec_command
     def clear(self):
         return "clear"
+
+    @exec_command
+    def do_exit(self):
+        return "exit"
diff --git a/src/spp-ctl/spp_webapi.py b/src/spp-ctl/spp_webapi.py
index 8332cab..49ef971 100644
--- a/src/spp-ctl/spp_webapi.py
+++ b/src/spp-ctl/spp_webapi.py
@@ -395,6 +395,7 @@ class V1PrimaryHandler(BaseHandler):
     def set_route(self):
         self.route('/status', 'GET', callback=self.get_status)
         self.route('/status', 'DELETE', callback=self.clear_status)
+        self.route('/', 'DELETE', callback=self.pri_exit)
 
     def _get_proc(self):
         proc = self.ctrl.procs.get(spp_proc.ID_PRIMARY)
@@ -417,3 +418,8 @@ class V1PrimaryHandler(BaseHandler):
     def clear_status(self):
         proc = self._get_proc()
         proc.clear()
+
+    def pri_exit(self):
+        proc = self._get_proc()
+        self.ctrl.do_exit(proc.type, proc.id)
+        proc.do_exit()
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [spp] [PATCH v2 3/5] controller: change pri exit cmd to call REST API
  2018-11-09  3:21 ` [spp] [PATCH v2 0/5] Add exit command support for spp_primary ogawa.yasufumi
  2018-11-09  3:21   ` [spp] [PATCH v2 1/5] primary: chage to return msg of exit command ogawa.yasufumi
  2018-11-09  3:21   ` [spp] [PATCH v2 2/5] spp-ctl: add exit cmd support for spp_primary ogawa.yasufumi
@ 2018-11-09  3:21   ` ogawa.yasufumi
  2018-11-09  3:21   ` [spp] [PATCH v2 4/5] docs: add DELETE method for exiting spp_primary ogawa.yasufumi
  2018-11-09  3:21   ` [spp] [PATCH v2 5/5] docs: remove exit from pri command ogawa.yasufumi
  4 siblings, 0 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-11-09  3:21 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

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 <ogawa.yasufumi@lab.ntt.co.jp>
---
 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [spp] [PATCH v2 4/5] docs: add DELETE method for exiting spp_primary
  2018-11-09  3:21 ` [spp] [PATCH v2 0/5] Add exit command support for spp_primary ogawa.yasufumi
                     ` (2 preceding siblings ...)
  2018-11-09  3:21   ` [spp] [PATCH v2 3/5] controller: change pri exit cmd to call REST API ogawa.yasufumi
@ 2018-11-09  3:21   ` ogawa.yasufumi
  2018-11-09  3:21   ` [spp] [PATCH v2 5/5] docs: remove exit from pri command ogawa.yasufumi
  4 siblings, 0 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-11-09  3:21 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

To support `bye` command of `spp.py`, add DELETE method for
spp_primary.

  $ curl -X DELETE http://127.0.0.1:7777/v1/primary

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 docs/guides/spp-ctl/api-reference.rst | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/docs/guides/spp-ctl/api-reference.rst b/docs/guides/spp-ctl/api-reference.rst
index f0661c8..3c22cb9 100644
--- a/docs/guides/spp-ctl/api-reference.rst
+++ b/docs/guides/spp-ctl/api-reference.rst
@@ -253,7 +253,27 @@ Request example
 Response
 ^^^^^^^^
 
-There is no body content for the response of a successful ``PUT`` request.
+There is no body content for the response of a successful ``DELETE`` request.
+
+DELETE /v1/primary
+~~~~~~~~~~~~~~~~~~
+
+Terminate primary process.
+
+* Normal response codes: 204
+
+Request example
+^^^^^^^^^^^^^^^
+
+.. code-block:: console
+
+    curl -X DELETE -H 'application/json' \
+    http://127.0.0.1:7777/v1/primary
+
+Response
+^^^^^^^^
+
+There is no body content for the response of a successful ``DELETE`` request.
 
 
 API for spp_nfv/spp_vm
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [spp] [PATCH v2 5/5] docs: remove exit from pri command
  2018-11-09  3:21 ` [spp] [PATCH v2 0/5] Add exit command support for spp_primary ogawa.yasufumi
                     ` (3 preceding siblings ...)
  2018-11-09  3:21   ` [spp] [PATCH v2 4/5] docs: add DELETE method for exiting spp_primary ogawa.yasufumi
@ 2018-11-09  3:21   ` ogawa.yasufumi
  4 siblings, 0 replies; 12+ messages in thread
From: ogawa.yasufumi @ 2018-11-09  3:21 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

Update command reference for removing `exit` sub command of `pri` which
is not recommended to use.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 docs/guides/commands/primary.rst | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/docs/guides/commands/primary.rst b/docs/guides/commands/primary.rst
index e49f990..590461f 100644
--- a/docs/guides/commands/primary.rst
+++ b/docs/guides/commands/primary.rst
@@ -24,22 +24,6 @@ Show forwarding statistics of each of ports.
        1        9208        9203           0           5
        ...
 
-exit
-----
-
-Terminate primary process.
-
-.. code-block:: console
-
-    spp > pri; exit
-
-.. note::
-
-    You should not use this command if one or more secondary processes
-    are still running because terminating primary before secondaries may
-    cause an error. You shold use ``bye`` command instead of
-    ``pri; exit``.
-
 clear
 -----
 
-- 
2.7.4

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2018-11-09  3:21 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-25  5:20 [spp] [PATCH 0/5] Add exit command support for spp_primary ogawa.yasufumi
2018-10-25  5:20 ` [spp] [PATCH 1/5] primary: chage to return msg of exit command ogawa.yasufumi
2018-10-25  5:20 ` [spp] [PATCH 2/5] spp-ctl: add exit cmd support for spp_primary ogawa.yasufumi
2018-10-25  5:20 ` [spp] [PATCH 3/5] controller: change pri exit cmd to call REST API ogawa.yasufumi
2018-10-25  5:20 ` [spp] [PATCH 4/5] docs: add DELETE method for exiting spp_primary ogawa.yasufumi
2018-10-25  5:20 ` [spp] [PATCH 5/5] docs: remove exit from pri command ogawa.yasufumi
2018-11-09  3:21 ` [spp] [PATCH v2 0/5] Add exit command support for spp_primary ogawa.yasufumi
2018-11-09  3:21   ` [spp] [PATCH v2 1/5] primary: chage to return msg of exit command ogawa.yasufumi
2018-11-09  3:21   ` [spp] [PATCH v2 2/5] spp-ctl: add exit cmd support for spp_primary ogawa.yasufumi
2018-11-09  3:21   ` [spp] [PATCH v2 3/5] controller: change pri exit cmd to call REST API ogawa.yasufumi
2018-11-09  3:21   ` [spp] [PATCH v2 4/5] docs: add DELETE method for exiting spp_primary ogawa.yasufumi
2018-11-09  3:21   ` [spp] [PATCH v2 5/5] docs: remove exit from pri command ogawa.yasufumi

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).