1 # Copyright (c) 2016 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
6 # http://www.apache.org/licenses/LICENSE-2.0
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
14 """Routing utilities library."""
16 from VatExecutor import VatTerminal
17 from topology import Topology
20 class Routing(object):
21 """Routing utilities."""
24 def vpp_route_add(node, network, prefix_len, gateway, interface):
25 """Add route to the VPP node.
27 :param node: Node to add route on.
28 :param network: Route destination network address.
29 :param prefix_len: Route destination network prefix length.
30 :param gateway: Route gateway address.
31 :param interface: Route interface.
38 sw_if_index = Topology.get_interface_sw_index(node, interface)
39 vat = VatTerminal(node)
40 vat.vat_terminal_exec_cmd_from_template('add_route.vat',
42 prefix_length=prefix_len,
44 sw_if_index=sw_if_index)
45 vat.vat_terminal_close()