]>
Commit | Line | Data |
---|---|---|
ac1087fa MW |
1 | #!/usr/bin/env python |
2 | ||
3 | """ | |
4 | exa-send.py: Send a few testroutes with ExaBGP | |
5 | """ | |
6 | ||
787e7624 | 7 | from sys import stdout, argv |
ac1087fa MW |
8 | from time import sleep |
9 | ||
10 | sleep(5) | |
11 | ||
12 | # 1st arg is peer number | |
13 | # 2nd arg is number of routes to send | |
14 | peer = int(argv[1]) | |
15 | numRoutes = int(argv[2]) | |
787e7624 | 16 | if peer <= 10: |
ac1087fa MW |
17 | asnum = 99 |
18 | else: | |
787e7624 | 19 | asnum = peer + 100 |
ac1087fa MW |
20 | |
21 | # Announce numRoutes equal routes per PE - different neighbor AS | |
22 | for i in range(0, numRoutes): | |
787e7624 | 23 | stdout.write( |
24 | "announce route 10.201.%s.0/24 med 100 next-hop 10.0.%i.%i origin igp\n" | |
25 | % (i, (((peer - 1) / 5) + 1), peer + 100) | |
26 | ) | |
ac1087fa MW |
27 | stdout.flush() |
28 | ||
29 | # Announce numRoutes equal routes per PE - different neighbor AS, but same source AS | |
30 | for i in range(0, numRoutes): | |
787e7624 | 31 | stdout.write( |
32 | "announce route 10.202.%s.0/24 med 100 next-hop 10.0.%i.%i origin igp as-path [ %i 200 ]\n" | |
33 | % (i, (((peer - 1) / 5) + 1), peer + 100, asnum) | |
34 | ) | |
ac1087fa MW |
35 | stdout.flush() |
36 | ||
37 | # Announce numRoutes equal routes with different med per PE and different neighbor AS | |
38 | for i in range(0, numRoutes): | |
787e7624 | 39 | stdout.write( |
40 | "announce route 10.203.%s.0/24 med %i next-hop 10.0.%i.%i origin igp\n" | |
41 | % (i, peer, (((peer - 1) / 5) + 1), peer + 100) | |
42 | ) | |
ac1087fa MW |
43 | stdout.flush() |
44 | ||
45 | # Announce numRoutes equal routes with different med per PE and different neighbor AS, but same source AS | |
46 | for i in range(0, numRoutes): | |
787e7624 | 47 | stdout.write( |
48 | "announce route 10.204.%s.0/24 med %i next-hop 10.0.%i.%i origin igp as-path [ %i 200 ]\n" | |
49 | % (i, peer, (((peer - 1) / 5) + 1), peer + 100, asnum) | |
50 | ) | |
ac1087fa MW |
51 | stdout.flush() |
52 | ||
53 | # Announce 2 different route per peer | |
787e7624 | 54 | stdout.write( |
55 | "announce route 10.205.%i.0/24 next-hop 10.0.%i.%i origin igp\n" | |
56 | % (peer, (((peer - 1) / 5) + 1), peer + 100) | |
57 | ) | |
58 | stdout.write( | |
59 | "announce route 10.206.%i.0/24 next-hop 10.0.%i.%i origin igp as-path [ %i 200 ]\n" | |
60 | % (peer, (((peer - 1) / 5) + 1), peer + 100, asnum) | |
61 | ) | |
ac1087fa MW |
62 | stdout.flush() |
63 | ||
787e7624 | 64 | # Loop endlessly to allow ExaBGP to continue running |
ac1087fa MW |
65 | while True: |
66 | sleep(1) |