summaryrefslogtreecommitdiffhomepage
path: root/test/scenario_test/quagga_access.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/scenario_test/quagga_access.py')
-rw-r--r--test/scenario_test/quagga_access.py32
1 files changed, 30 insertions, 2 deletions
diff --git a/test/scenario_test/quagga_access.py b/test/scenario_test/quagga_access.py
index a42e5eab..f29cb301 100644
--- a/test/scenario_test/quagga_access.py
+++ b/test/scenario_test/quagga_access.py
@@ -27,6 +27,7 @@ def login(host):
tn.read_until("Password: ")
tn.write(PASSWORD + "\n")
tn.write("enable\n")
+ tn.read_until("bgpd#")
return tn
@@ -54,10 +55,16 @@ def add_neighbor_metric(tn, as_number, neighbor_address, metric):
tn.read_until("bgpd#")
-def add_network(tn, as_number, network):
+def add_network(tn, as_number, network, use_ipv6=False):
tn.write("configure terminal\n")
tn.write("router bgp "+str(as_number)+"\n")
- tn.write("network "+ network + " \n")
+ if use_ipv6:
+ tn.write("address-family ipv6\n")
+ tn.write("network "+ network + " \n")
+ tn.write("exit\n")
+ else:
+ tn.write("network "+ network + " \n")
+
tn.write("exit\n")
tn.write("exit\n")
tn.read_until("bgpd#")
@@ -115,3 +122,24 @@ def rib_parser(rib):
paths.append(path)
return paths
+
+def lookup_prefix(tn, prefix, af):
+ if af == IPv4:
+ tn.write("show ip bgp " + prefix + "\n")
+ elif af == IPv6:
+ tn.write("show bgp ipv6 " + prefix + "\n")
+ else:
+ print "invalid af: ", af
+ return
+
+ info = tn.read_until("bgpd#")
+ paths = []
+ for line in info.split("\n"):
+ path = {}
+ if "from" in line:
+ nexthop = line.split()[0]
+ path['Network'] = prefix
+ path['Next Hop'] = nexthop
+ paths.append(path)
+
+ return paths \ No newline at end of file