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 ) |
Thomas Vachuska | 4cfcc56 | 2015-06-03 09:51:02 -0700 | [diff] [blame] | 29 | ctrl_count = ctrl_count + 1 |
Thomas Vachuska | 3f06e08 | 2014-11-21 11:58:23 -0800 | [diff] [blame] | 30 | net.build() |
| 31 | net.start() |
| 32 | CLI( net ) |
| 33 | net.stop() |
| 34 | |
| 35 | if __name__ == '__main__': |
| 36 | if len( sys.argv ) > 1: |
| 37 | controllers = sys.argv[ 1: ] |
| 38 | else: |
| 39 | print 'Usage: att-onos.py <c0 IP> <c1 IP> ...' |
| 40 | exit( 1 ) |
| 41 | run( controllers ) |