diff options
author | hochikong <1097225749@qq.com> | 2016-07-24 22:44:49 +0800 |
---|---|---|
committer | hochikong <1097225749@qq.com> | 2016-07-24 22:44:49 +0800 |
commit | cf04bae19e80a39a62644d1b96f5f58302242280 (patch) | |
tree | 063533f5ec5152761bbdc856d79c7673dcda5b4b /vyroute/basic_function/DeleteRoute.py | |
parent | b07b336d6a674ae18636274e4dd78df1c372cf78 (diff) | |
download | python-vyos-mgmt-cf04bae19e80a39a62644d1b96f5f58302242280.tar.gz python-vyos-mgmt-cf04bae19e80a39a62644d1b96f5f58302242280.zip |
T86 Python management library methods give timeouts
Use pxssh replace exscript
Attention:When you execute the logout method,you can't use this object any more.You must create a new BasicRouter substance to login the former VyOS system.
Diffstat (limited to 'vyroute/basic_function/DeleteRoute.py')
-rw-r--r-- | vyroute/basic_function/DeleteRoute.py | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/vyroute/basic_function/DeleteRoute.py b/vyroute/basic_function/DeleteRoute.py index da3f8e9..048406c 100644 --- a/vyroute/basic_function/DeleteRoute.py +++ b/vyroute/basic_function/DeleteRoute.py @@ -1,8 +1,4 @@ # Copyright (c) 2016 Hochikong -from Exscript.protocols import SSH2 -from Exscript import Account - - def deleteroute(obj, data): """This method provide a router configuration delete function @@ -25,17 +21,33 @@ def deleteroute(obj, data): try: if data['config'] == "all": - obj.execute(delete_all_protocols) - return {"Result": "Delete successfully."} + obj.sendline(delete_all_protocols) + obj.prompt() + if len(obj.before) > obj.before.index('\r\n') + 2: + return obj.before + else: + return {"Result": "Delete successfully."} elif data['config'] == 'rip': - obj.execute(delete_basic_configuration % 'rip') - return {"Result": "Delete successfully."} + obj.sendline(delete_basic_configuration % 'rip') + obj.prompt() + if len(obj.before) > obj.before.index('\r\n') + 2: + return obj.before + else: + return {"Result": "Delete successfully."} elif data['config'] == 'static': - obj.execute(delete_basic_configuration % 'static') - return {"Result": "Delete successfully."} + obj.sendline(delete_basic_configuration % 'static') + obj.prompt() + if len(obj.before) > obj.before.index('\r\n') + 2: + return obj.before + else: + return {"Result": "Delete successfully."} elif data['config'] == 'ospf': - obj.execute(delete_basic_configuration % 'ospf') - return {"Result": "Delete successfully."} + obj.sendline(delete_basic_configuration % 'ospf') + obj.prompt() + if len(obj.before) > obj.before.index('\r\n') + 2: + return obj.before + else: + return {"Result": "Delete successfully."} else: return {"Error": "Nonsupport protocols type."} except Exception as e: |