summaryrefslogtreecommitdiff
path: root/vyroute/basic_function/StaticRoute.py
blob: b76e451fbb70062f1df8c59e76ea46fd33f82181 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# author=hochikong
def staticroute(obj, data):
    """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'},
    }

    :param obj: a connection object
    :param data: a python dictionary
    :return:a python dictionary
    """
    static_basic_configuration = "set protocols static route %s next-hop %s distance %s"

    try:
        # Configure static router
        obj.execute(static_basic_configuration % (data['config']['target'],
                                                  data['config']['next-hop'],
                                                  data['config']['distance']))
        return {"Result": "Configured successfully"}
    except Exception, e:
        return {'Error': e}