summaryrefslogtreecommitdiffhomepage
path: root/test/scenario_test/quagga_access.py
diff options
context:
space:
mode:
authorNaoto Hanaue <hanaue.naoto@po.ntts.co.jp>2015-01-21 19:22:53 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2015-01-22 20:31:35 +0900
commit9ab4bb000ae0fa2ebe15c088baa0abcf2e726c7c (patch)
tree5148c023c3886d84e7b4f924a20c2eeb8609303f /test/scenario_test/quagga_access.py
parent94ed82255d6d7cc9d5c7aee9f9c71837bfd2e907 (diff)
scenario_test: support test of best path selection and fixed following the display format of the rest
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
Diffstat (limited to 'test/scenario_test/quagga_access.py')
-rw-r--r--test/scenario_test/quagga_access.py45
1 files changed, 43 insertions, 2 deletions
diff --git a/test/scenario_test/quagga_access.py b/test/scenario_test/quagga_access.py
index 87152c02..df2eb938 100644
--- a/test/scenario_test/quagga_access.py
+++ b/test/scenario_test/quagga_access.py
@@ -17,17 +17,37 @@ import sys
import telnetlib
PASSWORD = "zebra"
+CONN_PASSWORD = "hogehoge"
QLPORT = 2605
+
def login(host):
tn = telnetlib.Telnet(host, QLPORT)
tn.read_until("Password: ")
tn.write(PASSWORD + "\n")
-
tn.write("enable\n")
- #print tn.read_all()
return tn
+
+def add_neighbor(tn, as_number, neighbor_address, remote_as):
+ tn.write("configure terminal\n")
+ tn.write("router bgp "+str(as_number)+"\n")
+ tn.write("neighbor " + neighbor_address + " remote-as " + remote_as + "\n")
+ tn.write("neighbor " + neighbor_address + " password " + CONN_PASSWORD + "\n")
+ tn.write("exit\n")
+ tn.write("exit\n")
+ tn.read_until("bgpd#")
+
+
+def add_neighbor_metric(tn, as_number, neighbor_address, metric):
+ tn.write("configure terminal\n")
+ tn.write("router bgp "+str(as_number)+"\n")
+ tn.write("neighbor " + neighbor_address + " route-map MED" + metric + " out\n")
+ tn.write("exit\n")
+ tn.write("exit\n")
+ tn.read_until("bgpd#")
+
+
def add_network(tn, as_number, network):
tn.write("configure terminal\n")
tn.write("router bgp "+str(as_number)+"\n")
@@ -36,12 +56,28 @@ def add_network(tn, as_number, network):
tn.write("exit\n")
print tn.read_until("bgpd#")
+
+def add_metric(tn, metric, network):
+ tn.write("configure terminal\n")
+ tn.write("access-list 1 permit " + network + " 0.0.0.255\n")
+ tn.write("route-map MED" + metric + " permit 10\n")
+ tn.write("match ip address 1\n")
+ tn.write("set metric " + metric + "\n")
+ tn.write("route-map MED" + metric + " permit 10\n")
+ tn.write("set metric\n")
+ tn.read_until("bgpd(config-route-map)#")
+ tn.write("exit\n")
+ tn.write("exit\n")
+ return tn
+
+
def show_config(tn):
tn.write("show run\n")
print tn.read_until("bgpd#")
tn.write("exit\n")
print tn.read_all()
+
def show_rib(tn):
tn.write("show ip bgp\n")
tn.read_until(" Network Next Hop Metric LocPrf Weight Path")
@@ -49,6 +85,11 @@ def show_rib(tn):
# print header
return rib_parser(rib)
+
+def clear_ip_bgp(tn):
+ tn.write("clear ip bgp *\n")
+ tn.read_until("bgpd#")
+
def rib_parser(rib):
lines = rib.split("\n")
paths = []