Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 1 | # !/usr/bin/env python |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 2 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 3 | Copyright 2015 Open Networking Foundation ( ONF ) |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 4 | |
| 5 | Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>, |
| 6 | the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>, |
| 7 | or the System Testing Guide page at <https://wiki.onosproject.org/x/WYQg> |
| 8 | |
| 9 | TestON is free software: you can redistribute it and/or modify |
| 10 | it under the terms of the GNU General Public License as published by |
| 11 | the Free Software Foundation, either version 2 of the License, or |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 12 | ( at your option ) any later version. |
Jeremy Ronquillo | b27ce4c | 2017-07-17 12:41:28 -0700 | [diff] [blame] | 13 | |
| 14 | TestON is distributed in the hope that it will be useful, |
| 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | GNU General Public License for more details. |
| 18 | |
| 19 | You should have received a copy of the GNU General Public License |
| 20 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
| 21 | """ |
| 22 | |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 23 | from mininet.net import Mininet |
| 24 | from mininet.topo import Topo |
| 25 | from mininet.node import Host, RemoteController |
| 26 | from mininet.cli import CLI |
| 27 | from mininet.log import setLogLevel |
| 28 | |
| 29 | from opticalUtils import LINCSwitch, LINCLink |
| 30 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 31 | |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 32 | class OpticalTopo( Topo ): |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 33 | |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 34 | """ |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 35 | A simple optical topology of three LINC nodes( OE* ), two OVS switches( ps* ), and two hosts: |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 36 | |
| 37 | OE3 |
| 38 | /\ |
| 39 | h1-ps1-OE1--OE2-ps2-h2 |
| 40 | |
| 41 | """ |
| 42 | def build( self ): |
| 43 | |
| 44 | # set up packet layer - OVS + hosts |
| 45 | s1 = self.addSwitch( 'ps1' ) |
| 46 | s2 = self.addSwitch( 'ps2' ) |
| 47 | h1 = self.addHost( 'h1' ) |
| 48 | h2 = self.addHost( 'h2' ) |
| 49 | self.addLink( s1, h1 ) |
| 50 | self.addLink( s2, h2 ) |
| 51 | |
| 52 | # set up ROADMs, add them to oel[] |
| 53 | oel = [] |
| 54 | an = { "durable": "true" } |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 55 | for i in range( 1, 4 ): |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 56 | oean = { "optical.regens": 0 } |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 57 | oel.append( self.addSwitch( 'OE%s' % i, dpid='0000ffffffffff0%s' % i, annotations=oean, cls=LINCSwitch ) ) |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 58 | |
| 59 | # ROADM port numbers are built as: OE1 <-> OE2 = 1200 |
| 60 | # leaving port number up to 100 open for use by Och port |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 61 | self.addLink( oel[ 0 ], oel[ 1 ], port1=1200, port2=2100, annotations=an, cls=LINCLink ) |
| 62 | self.addLink( oel[ 1 ], oel[ 2 ], port1=2300, port2=3200, annotations=an, cls=LINCLink ) |
| 63 | self.addLink( oel[ 2 ], oel[ 0 ], port1=3100, port2=1300, annotations=an, cls=LINCLink ) |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 64 | |
| 65 | # cross-connects between OVSes and LINCs |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 66 | self.addLink( s1, oel[ 0 ], port1=2, port2=1, annotations=an, cls=LINCLink ) |
| 67 | self.addLink( s2, oel[ 1 ], port1=2, port2=1, annotations=an, cls=LINCLink ) |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 68 | |
| 69 | |
| 70 | def setup( ctls ): |
| 71 | net = Mininet( topo=OpticalTopo(), controller=None ) |
| 72 | i = 1 |
| 73 | for ctl in ctls: |
| 74 | net.addController( RemoteController( 'c%d' % i, ip=ctl ) ) |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 75 | i += 1 |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 76 | |
| 77 | net.start() |
| 78 | LINCSwitch.bootOE( net ) |
| 79 | CLI( net ) |
| 80 | net.stop() |
| 81 | LINCSwitch.shutdownOE() |
| 82 | |
| 83 | |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 84 | if __name__ == "__main__": |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 85 | import sys |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 86 | if len( sys.argv ) >= 2: |
Jeremy Songster | 5665f1b | 2016-06-20 14:38:22 -0700 | [diff] [blame] | 87 | setLogLevel( 'info' ) |
| 88 | ctls = sys.argv[ 1: ] |
| 89 | setup( ctls ) |
| 90 | else: |
Jeremy Ronquillo | 23fb216 | 2017-09-15 14:59:57 -0700 | [diff] [blame] | 91 | print( './ectopo.py [IP1] [IP2]...\n' ) |