Soft Patch Panel
 help / color / mirror / Atom feed
* [spp] [PATCH 0/3] Fix updating status in SPP CLI
@ 2019-02-20  8:54 ogawa.yasufumi
  2019-02-20  8:55 ` [spp] [PATCH 1/3] controller: correct status update of processes ogawa.yasufumi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: ogawa.yasufumi @ 2019-02-20  8:54 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

SPP CLI updates list of primary and secondary processes everytime after
running command. However, it is not updated for some of commands. This
update is to fix the issue.

Yasufumi Ogawa (3):
  controller: correct status update of processes
  controller: change to wait for launching sec
  controller: change wait for launch configurable

 src/controller/commands/pri.py    | 11 ++++++++---
 src/controller/config/default.yml | 19 +++++++++++++++----
 src/controller/shell.py           | 10 +++++-----
 3 files changed, 28 insertions(+), 12 deletions(-)

-- 
2.17.1

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

* [spp] [PATCH 1/3] controller: correct status update of processes
  2019-02-20  8:54 [spp] [PATCH 0/3] Fix updating status in SPP CLI ogawa.yasufumi
@ 2019-02-20  8:55 ` ogawa.yasufumi
  2019-02-20  8:55 ` [spp] [PATCH 2/3] controller: change to wait for launching sec ogawa.yasufumi
  2019-02-20  8:55 ` [spp] [PATCH 3/3] controller: change wait for launch configurable ogawa.yasufumi
  2 siblings, 0 replies; 4+ messages in thread
From: ogawa.yasufumi @ 2019-02-20  8:55 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

For getting the latest status of all of primary and secondaries, SPP CLI
calls init_spp_procs() after command run, but hook method is
inappripriate. This update is to change the hook from precmd() to
postcmd() to correct.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/controller/shell.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/controller/shell.py b/src/controller/shell.py
index 21543d1..e4685c7 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -70,7 +70,7 @@ class Shell(cmd.Cmd, object):
         """Initialize delegators of SPP processes.
 
         Delegators accept a command and sent it to SPP proesses. This method
-        is also called from `precmd()` method to update it to the latest
+        is also called from `postcmd()` method to update it to the latest
         status.
         """
 
@@ -101,6 +101,9 @@ class Shell(cmd.Cmd, object):
     # method and SPP CLI is terminated if it is True. It means that only
     # `do_bye` and  `do_exit` return True.
     def postcmd(self, stop, line):
+        if self.use_cache is False:
+            self.init_spp_procs()
+
         # TODO(yasufum) do not add to history if command is failed.
         if line.strip().split(' ')[0] not in self.HIST_EXCEPT:
             readline.write_history_file(self.hist_file)
@@ -217,9 +220,6 @@ class Shell(cmd.Cmd, object):
         It is called for checking a contents of command line.
         """
 
-        if self.use_cache is False:
-            self.init_spp_procs()
-
         if self.recorded_file:
             if not (
                     ('playback' in line) or
-- 
2.17.1

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

* [spp] [PATCH 2/3] controller: change to wait for launching sec
  2019-02-20  8:54 [spp] [PATCH 0/3] Fix updating status in SPP CLI ogawa.yasufumi
  2019-02-20  8:55 ` [spp] [PATCH 1/3] controller: correct status update of processes ogawa.yasufumi
@ 2019-02-20  8:55 ` ogawa.yasufumi
  2019-02-20  8:55 ` [spp] [PATCH 3/3] controller: change wait for launch configurable ogawa.yasufumi
  2 siblings, 0 replies; 4+ messages in thread
From: ogawa.yasufumi @ 2019-02-20  8:55 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

SPP CLI updates list of secondaries after `pri launch` command
immediately. However, secondary is not launched when list is updated
yet.

This update is to add sleep() to wait 0.5 sec before updating. This 0.5
sec is best effort, but should be enough on almost of environment.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/controller/commands/pri.py | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/controller/commands/pri.py b/src/controller/commands/pri.py
index 7043c2f..4124a12 100644
--- a/src/controller/commands/pri.py
+++ b/src/controller/commands/pri.py
@@ -4,6 +4,7 @@
 from .. import spp_common
 from ..shell_lib import common
 from ..spp_common import logger
+import time
 
 
 class SppPrimary(object):
@@ -19,6 +20,9 @@ class SppPrimary(object):
     # All of primary commands used for validation and completion.
     PRI_CMDS = ['status', 'launch', 'clear']
 
+    # Wait for launched secondary as best effort. 0.5 sec is enough.
+    WAIT_LAUNCH_SEC = 0.5
+
     def __init__(self, spp_ctl_cli):
         self.spp_ctl_cli = spp_ctl_cli
 
@@ -425,6 +429,9 @@ class SppPrimary(object):
         if res is not None:
             error_codes = self.spp_ctl_cli.rest_common_error_codes
             if res.status_code == 204:
+                # Wait for launch sec as best effort
+                time.sleep(self.WAIT_LAUNCH_SEC)
+
                 print('Send request to launch {ptype}:{sid}.'.format(
                     ptype=proc_type, sid=sec_id))
             elif res.status_code in error_codes:
-- 
2.17.1

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

* [spp] [PATCH 3/3] controller: change wait for launch configurable
  2019-02-20  8:54 [spp] [PATCH 0/3] Fix updating status in SPP CLI ogawa.yasufumi
  2019-02-20  8:55 ` [spp] [PATCH 1/3] controller: correct status update of processes ogawa.yasufumi
  2019-02-20  8:55 ` [spp] [PATCH 2/3] controller: change to wait for launching sec ogawa.yasufumi
@ 2019-02-20  8:55 ` ogawa.yasufumi
  2 siblings, 0 replies; 4+ messages in thread
From: ogawa.yasufumi @ 2019-02-20  8:55 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

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

This update is to change wait time for launching secondary from fixed
0.5 sec to one of config values. It is changed with `config` command.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/controller/commands/pri.py    | 14 ++++++--------
 src/controller/config/default.yml | 19 +++++++++++++++----
 src/controller/shell.py           |  2 +-
 3 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/src/controller/commands/pri.py b/src/controller/commands/pri.py
index 4124a12..15bdb12 100644
--- a/src/controller/commands/pri.py
+++ b/src/controller/commands/pri.py
@@ -20,9 +20,6 @@ class SppPrimary(object):
     # All of primary commands used for validation and completion.
     PRI_CMDS = ['status', 'launch', 'clear']
 
-    # Wait for launched secondary as best effort. 0.5 sec is enough.
-    WAIT_LAUNCH_SEC = 0.5
-
     def __init__(self, spp_ctl_cli):
         self.spp_ctl_cli = spp_ctl_cli
 
@@ -38,7 +35,7 @@ class SppPrimary(object):
         temp = temp + "__VHOST_CLI__"
         self.launch_template = temp
 
-    def run(self, cmd):
+    def run(self, cmd, cli_config):
         """Called from do_pri() to Send command to primary process."""
 
         tmpary = cmd.split(' ')
@@ -64,7 +61,8 @@ class SppPrimary(object):
                     print('Error: unknown response.')
 
         elif subcmd == 'launch':
-            self._run_launch(params)
+            wait_time = float(cli_config['sec_wait_launch']['val'])
+            self._run_launch(params, wait_time)
 
         elif subcmd == 'clear':
             res = self.spp_ctl_cli.delete('primary/status')
@@ -333,7 +331,7 @@ class SppPrimary(object):
                     prekey = None
         return opts_dict
 
-    def _run_launch(self, params):
+    def _run_launch(self, params, wait_time):
         """Launch secondary process.
 
         Parse `launch` command and send request to spp-ctl. Params of the
@@ -429,8 +427,8 @@ class SppPrimary(object):
         if res is not None:
             error_codes = self.spp_ctl_cli.rest_common_error_codes
             if res.status_code == 204:
-                # Wait for launch sec as best effort
-                time.sleep(self.WAIT_LAUNCH_SEC)
+                # Wait for launch secondary as best effort
+                time.sleep(wait_time)
 
                 print('Send request to launch {ptype}:{sid}.'.format(
                     ptype=proc_type, sid=sec_id))
diff --git a/src/controller/config/default.yml b/src/controller/config/default.yml
index 223359e..7625451 100644
--- a/src/controller/config/default.yml
+++ b/src/controller/config/default.yml
@@ -9,28 +9,39 @@ topo_size:
     val: 60%
     desc: Percentage or ratio of topo
 
-# Secondary
+# Secondary common config
 sec_mem:
     val: -m 512
     desc: Mem size
 sec_base_lcore:
     val: 1
     desc: Shared lcore among secondaries
+sec_wait_launch:
+    val: 0.5
+    desc: Wait for launching secondary process in sec
+sec_vhost_cli:
+    val: ""
+    desc: Vhost client mode, activated if set any of values
+
+# spp_nfv
 sec_nfv_nof_lcores:
     val: 1
     desc: Default num of lcores for workers of spp_nfv
+
+# spp_vf
 sec_vf_nof_lcores:
     val: 3
     desc: Default num of lcores for workers of spp_vf
+
+# spp_mirror
 sec_mirror_nof_lcores:
     val: 2
     desc: Default num of lcores for workers of spp_mirror
+
+# spp_pcap
 sec_pcap_nof_lcores:
     val: 2
     desc: Default num of lcores for workers of spp_pcap
-sec_vhost_cli:
-    val: ""
-    desc: Vhost client mode, activated if set any of values
 sec_pcap_port:
     val: "phy:0"
     desc: Default captured port
diff --git a/src/controller/shell.py b/src/controller/shell.py
index e4685c7..43ef991 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -308,7 +308,7 @@ class Shell(cmd.Cmd, object):
         if logger is not None:
             logger.info("Receive pri command: '%s'" % command)
 
-        self.primary.run(command)
+        self.primary.run(command, self.cli_config)
 
     def complete_pri(self, text, line, begidx, endidx):
         """Completion for primary process commands."""
-- 
2.17.1

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

end of thread, other threads:[~2019-02-20  8:57 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-20  8:54 [spp] [PATCH 0/3] Fix updating status in SPP CLI ogawa.yasufumi
2019-02-20  8:55 ` [spp] [PATCH 1/3] controller: correct status update of processes ogawa.yasufumi
2019-02-20  8:55 ` [spp] [PATCH 2/3] controller: change to wait for launching sec ogawa.yasufumi
2019-02-20  8:55 ` [spp] [PATCH 3/3] controller: change wait for launch configurable 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).