[spp] [PATCH 5/7] cli: fix terminated if spp_primary is not running
Yasufumi Ogawa
yasufum.o at gmail.com
Thu Jan 16 13:02:33 CET 2020
If there is no spp_primary is running, SPP CLI is terminated when it
requests something to spp-ctl. This update is to fix the issue.
Signed-off-by: Yasufumi Ogawa <yasufum.o at gmail.com>
---
src/cli/commands/pri.py | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/cli/commands/pri.py b/src/cli/commands/pri.py
index f7d86bb..b39f911 100644
--- a/src/cli/commands/pri.py
+++ b/src/cli/commands/pri.py
@@ -77,7 +77,17 @@ class SppPrimary(object):
# Get status here for inspecting if forwarder exists. Do not run
# command such as `add` or `del` if forwarder does not exist.
res = self.spp_ctl_cli.get('primary/status')
- status = res.json()
+
+ # Check if spp_primary is running.
+ error_codes = self.spp_ctl_cli.rest_common_error_codes
+ if res.status_code in error_codes:
+ if res.status_code == 404:
+ print('No spp_primary is running.')
+ else:
+ print('Error: spp_primary is not running normaly.')
+ return None
+ else:
+ status = res.json()
if subcmd == 'status':
if res is not None:
--
2.17.1
More information about the spp
mailing list