Thomas Vachuska | 3f06e08 | 2014-11-21 11:58:23 -0800 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import sys |
| 4 | |
| 5 | from mininet.net import Mininet |
| 6 | from mininet.cli import CLI |
| 7 | from mininet.log import setLogLevel |
| 8 | from mininet.node import RemoteController |
| 9 | from mininet.link import TCLink |
| 10 | |
| 11 | from attmpls import AttMplsTopo |
| 12 | |
| 13 | setLogLevel( 'info' ) |
| 14 | |
Thomas Vachuska | 82041f5 | 2014-11-30 22:14:02 -0800 | [diff] [blame] | 15 | def pingloop( net ): |
| 16 | setLogLevel( 'error' ) |
| 17 | try: |
| 18 | while True: |
| 19 | net.ping() |
| 20 | finally: |
| 21 | setLogLevel( 'info' ) |
| 22 | |
Thomas Vachuska | 3f06e08 | 2014-11-21 11:58:23 -0800 | [diff] [blame] | 23 | def run(controllers=[ '127.0.0.1' ]): |
Thomas Vachuska | 82041f5 | 2014-11-30 22:14:02 -0800 | [diff] [blame] | 24 | Mininet.pingloop = pingloop |
Thomas Vachuska | 3f06e08 | 2014-11-21 11:58:23 -0800 | [diff] [blame] | 25 | net = Mininet( topo=AttMplsTopo(), link=TCLink, build=False, autoSetMacs=True ) |
| 26 | ctrl_count = 0 |
| 27 | for controllerIP in controllers: |
| 28 | net.addController( 'c%d' % ctrl_count, RemoteController, ip=controllerIP ) |
| 29 | net.build() |
| 30 | net.start() |
| 31 | CLI( net ) |
| 32 | net.stop() |
| 33 | |
| 34 | if __name__ == '__main__': |
| 35 | if len( sys.argv ) > 1: |
| 36 | controllers = sys.argv[ 1: ] |
| 37 | else: |
| 38 | print 'Usage: att-onos.py <c0 IP> <c1 IP> ...' |
| 39 | exit( 1 ) |
| 40 | run( controllers ) |