File: api-internet.py

package info (click to toggle)
exabgp 4.2.25-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,612 kB
  • sloc: python: 37,482; sh: 581; perl: 31; makefile: 23
file content (30 lines) | stat: -rwxr-xr-x 687 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python

import sys
import time


def write(data):
    sys.stdout.write(data + '\n')
    sys.stdout.flush()


def main():
    msg = 'announce attribute next-hop 1.2.3.4 med 100 as-path [ 100 101 102 103 104 105 106 107 108 109 110 ] nlri %s'
    write(msg % ' '.join('%d.0.0.0/8' % ip for ip in range(0, 224)))
    write(msg % ' '.join('10.%d.0.0/16' % ip for ip in range(0, 256)))

    time.sleep(2)

    write(
        'withdraw attribute next-hop 1.2.3.4 med 100 as-path [ 100 101 102 103 104 105 106 107 108 109 110 ] nlri 0.0.0.0/8 1.0.0.0/8'
    )

    time.sleep(10000)


if __name__ == '__main__':
    try:
        main()
    except KeyboardInterrupt:
        pass