summaryrefslogtreecommitdiff
path: root/vymgmt
diff options
context:
space:
mode:
authorhochikong <1097225749@qq.com>2016-08-26 22:04:49 +0800
committerhochikong <1097225749@qq.com>2016-08-26 22:04:49 +0800
commitb6d33086cfecf091a1d4f2afc4bbf4607e4a327c (patch)
treea2bcea05297d6eba7dcaa312302ff77ace2c9150 /vymgmt
parenta9d1a18af94f3e0f0ac669c51f3acfb1c03058f0 (diff)
downloadpython-vyos-mgmt-b6d33086cfecf091a1d4f2afc4bbf4607e4a327c.tar.gz
python-vyos-mgmt-b6d33086cfecf091a1d4f2afc4bbf4607e4a327c.zip
Fix some logic error in logout()
Fix two mistakes may raise error exceptions in error_distinguish Add a quick start section to README
Diffstat (limited to 'vymgmt')
-rw-r--r--vymgmt/error_distinguish.py5
-rw-r--r--vymgmt/router.py9
2 files changed, 12 insertions, 2 deletions
diff --git a/vymgmt/error_distinguish.py b/vymgmt/error_distinguish.py
index d58db2f..1f889f8 100644
--- a/vymgmt/error_distinguish.py
+++ b/vymgmt/error_distinguish.py
@@ -7,7 +7,7 @@ def distinguish_for_set(message):
:param message: A error message string from VyOS
:return: The type of error
"""
- path_error_string = ['Configuration path:', 'is not valid']
+ path_error_string = ['Configuration path:', 'is not valid', 'already exists']
value_error_string = ['Value validation failed']
all_strings = [path_error_string, value_error_string]
condition = 0
@@ -31,7 +31,8 @@ def distinguish_for_delete(message):
:return: The type of error
"""
path_error_string = ['Configuration path:', 'is not valid', 'Delete failed']
- value_error_string = ['Nothing to delete', 'the specified value does not exist']
+ value_error_string = ['Nothing to delete', 'the specified value does not exist',
+ "the specified node does not exist"]
all_strings = [path_error_string, value_error_string]
condition = 0
diff --git a/vymgmt/router.py b/vymgmt/router.py
index f46955d..15fea9e 100644
--- a/vymgmt/router.py
+++ b/vymgmt/router.py
@@ -52,6 +52,15 @@ class Router(object):
:return: A message or an error
"""
try:
+ if self.__status["commit"] == "No":
+ return "Error : You should commit and exit configure mode first."
+
+ if self.__status["save"] == "No":
+ return "Error : You should save and exit configure mode first."
+
+ if self.__status["configure"] == "Yes":
+ return "Error : You should exit configure mode first."
+
self.__conn.close()
self.__status["status"] = "logout"
self.__status["configure"] = None