[spp] [PATCH 7/7] cli: fix parsing forward and stop commands

Yasufumi Ogawa yasufum.o at gmail.com
Thu Jan 16 13:02:35 CET 2020


This update is to fix a bug in which _run_forward_or_stop() expects a
str type argument, but passed a list.

Fixes: 17c6d451fa60 ("cli: add filter for running pri commands")

Signed-off-by: Yasufumi Ogawa <yasufum.o at gmail.com>
---
 src/cli/commands/pri.py   | 6 +++---
 src/cli/spp_ctl_client.py | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/cli/commands/pri.py b/src/cli/commands/pri.py
index b39f911..a13137d 100644
--- a/src/cli/commands/pri.py
+++ b/src/cli/commands/pri.py
@@ -105,9 +105,9 @@ class SppPrimary(object):
         elif subcmd == 'del':
             self._do_if_forwarder_exists(status, self._run_del, params)
 
-        elif subcmd == 'forward' or cmd == 'stop':
+        elif subcmd == 'forward' or subcmd == 'stop':
             self._do_if_forwarder_exists(status,
-                                         self._run_forward_or_stop, params)
+                                         self._run_forward_or_stop, subcmd)
 
         elif subcmd == 'patch':
             self._do_if_forwarder_exists(status, self._run_patch, params)
@@ -818,7 +818,7 @@ class SppPrimary(object):
         elif cmd == 'stop':
             req_params = {'action': 'stop'}
         else:
-            print('Unknown command. "forward" or "stop"?')
+            print('Unknown command {}. "forward" or "stop"?'.format(cmd))
 
         res = self.spp_ctl_cli.put('primary/forward', req_params)
 
diff --git a/src/cli/spp_ctl_client.py b/src/cli/spp_ctl_client.py
index 7418353..7b366b2 100644
--- a/src/cli/spp_ctl_client.py
+++ b/src/cli/spp_ctl_client.py
@@ -31,10 +31,10 @@ class SppCtlClient(object):
                 # for spp.py.
                 if res.status_code == 400:
                     logger.info('Syntax or lexical error, or SPP '
-                                    'returns error for the request.')
+                                'returns error for the request.')
                 elif res.status_code == 404:
                     logger.info('URL is not supported, or no SPP '
-                                    'process of client-id in a URL.')
+                                'process of client-id in a URL.')
                 elif res.status_code == 500:
                     logger.info('System error occured in spp-ctl.')
 
-- 
2.17.1



More information about the spp mailing list