summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdministrator <michellehzg@gmail.com>2016-05-25 13:43:59 +0800
committerAdministrator <michellehzg@gmail.com>2016-05-25 13:43:59 +0800
commit3db61f05bd9a9b91195a37701bc13d8c872a9a9f (patch)
treecfc5adb895a207738caba8a3f654d00ec11eebad
parent76980aaf49f5e48f87400acf2c8aa5d0662e7689 (diff)
downloadpython-vyos-mgmt-3db61f05bd9a9b91195a37701bc13d8c872a9a9f.tar.gz
python-vyos-mgmt-3db61f05bd9a9b91195a37701bc13d8c872a9a9f.zip
add deleteroute
-rw-r--r--README.md10
-rw-r--r--vyroute/Router.py34
2 files changed, 43 insertions, 1 deletions
diff --git a/README.md b/README.md
index 07e8fee..83c87a5 100644
--- a/README.md
+++ b/README.md
@@ -1,3 +1,11 @@
-# vyroute
+# VyRoute
A python library for VyOS routing setting
+这是一个用于设置VyOS路由功能的Python库,目前仅仅提供了静态路由,RIP和OSPF的功能,以后有需要会增加BGP的部分,如果你有兴趣,可以试着clone一份增加你想要的功能,比如BGP和网络接口设置。
+
+在后面我还会继续开发实现VyOS的防火墙、VPN配置的库。
+
+#文档
+在这里我会给出这个库的使用说明和注意事项
+
+
diff --git a/vyroute/Router.py b/vyroute/Router.py
index 12629ff..9999d7e 100644
--- a/vyroute/Router.py
+++ b/vyroute/Router.py
@@ -5,6 +5,7 @@ from vyroute.basic_function import Modifylo
from vyroute.basic_function import StaticRoute
from vyroute.basic_function import RIPRoute
from vyroute.basic_function import OSPFRoute
+from vyroute.basic_function import DeleteRoute
class Router(object):
@@ -236,6 +237,39 @@ class BasicRouter(Router):
except Exception, e:
return {"Error": e}
+ def delete_route(self, data):
+ """Delete router setting
+
+ Parameter data example:
+ {'config':'rip'/'static'/'ospf'/'all'
+ }
+
+ :param data: a python dictionary
+ :return: a python dictionary
+ """
+ try:
+ if self.status["object"] == "login":
+ if self.status["configure"] == "Yes":
+ res = DeleteRoute.deleteroute(self.__conn, data)
+ if "Result" in res:
+ if self.status["commit"] == "No":
+ pass
+ else:
+ self.status["commit"] = "No"
+ if self.status["save"] == "No":
+ pass
+ else:
+ self.status["save"] = "No"
+ return res
+ else:
+ return res
+ else:
+ return {"Error": "You are not in configure mode."}
+ else:
+ return {"Error": "Router object not connect to a router."}
+ except Exception, e:
+ return {"Error": e}
+
def static_route(self, data):
"""Static router setting