summaryrefslogtreecommitdiff
path: root/vyroute/basic_function/StaticRoute.py
diff options
context:
space:
mode:
authorhochikong <1097225749@qq.com>2016-08-18 16:26:43 +0800
committerhochikong <1097225749@qq.com>2016-08-18 16:26:43 +0800
commit2584bea48c4c243fdf694cb21505bfbde6834a7f (patch)
tree228a44cb97f93b3972507d9c2054c324da3e9503 /vyroute/basic_function/StaticRoute.py
parent74de52cceec95ee3de95180ee1f1660c75eb5210 (diff)
downloadpython-vyos-mgmt-2584bea48c4c243fdf694cb21505bfbde6834a7f.tar.gz
python-vyos-mgmt-2584bea48c4c243fdf694cb21505bfbde6834a7f.zip
T86 Python management library methods give timeoutsOLD_VERSION
Fix some problem and add BGP support
Diffstat (limited to 'vyroute/basic_function/StaticRoute.py')
-rw-r--r--vyroute/basic_function/StaticRoute.py25
1 files changed, 13 insertions, 12 deletions
diff --git a/vyroute/basic_function/StaticRoute.py b/vyroute/basic_function/StaticRoute.py
index 9bdf378..d210785 100644
--- a/vyroute/basic_function/StaticRoute.py
+++ b/vyroute/basic_function/StaticRoute.py
@@ -1,26 +1,27 @@
# Copyright (c) 2016 Hochikong
-def staticroute(obj, data):
+def staticroute(obj, network_range, next_hop, distance):
"""This method provide a basic static router configuration function
- Parameter data example:
- {'config':{'target':'10.20.10.0/24','next-hop':'10.20.10.1','distance':'1'},
- }
+ Parameter example:
+ 'network_range':'10.20.10.0/24'
+ 'next-hop':'10.20.10.1'
+ 'distance':'1'
- :param obj: a connection object
- :param data: a python dictionary
- :return:a python dictionary
+ :param obj: A connection object
+ :param network_range: The target network,don't forget the netmask
+ :param next_hop: The next hop
+ :param distance: The distance
+ :return: A message or an error
"""
static_basic_configuration = "set protocols static route %s next-hop %s distance %s"
try:
# Configure static router
- obj.sendline(static_basic_configuration % (data['config']['target'],
- data['config']['next-hop'],
- data['config']['distance']))
+ obj.sendline(static_basic_configuration % (network_range, next_hop, distance))
obj.prompt()
if len(obj.before) > obj.before.index('\r\n') + 2:
return obj.before
else:
- return {"Result": "Configured successfully"}
+ return "Result : Configured successfully"
except Exception as e:
- return {'Error': e}
+ return e