From 314750af29226259aceb27dfa39e1ef7aee67563 Mon Sep 17 00:00:00 2001 From: hochikong <1097225749@qq.com> Date: Sun, 31 Jul 2016 14:08:52 +0800 Subject: T86 Python management library methods give timeouts Fix a error in exit_config():When a user login and enter configure mode but change nothing and exit.It return a message "You should commit first!" Fix the problem when you logout you should create a new instance.Now you can reuse the BasicRouter instance --- vyroute/Router.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/vyroute/Router.py b/vyroute/Router.py index 86f3c78..476414a 100644 --- a/vyroute/Router.py +++ b/vyroute/Router.py @@ -113,6 +113,7 @@ class BasicRouter(Router): self.__conn.close() self.__status["status"] = "logout" self.__status["configure"] = None + self.__conn = pxssh() return {"Result": "Logout successfully."} except Exception as e: return {"Error": e} @@ -215,6 +216,10 @@ class BasicRouter(Router): return {"Result": "Exit configure mode successfully."} else: return {"Error": "You should save first."} + elif self.__status["commit"] is None: + self.__conn.sendline("exit") + self.__conn.prompt() + return {"Result": "Exit configure mode successfully."} else: return {"Error": "You should commit first."} else: -- cgit v1.2.3