blob: 9413c9807d2b93d0779d541bc7a67d92a4138c13 [file] [log] [blame]
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07001# !/usr/bin/env python
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07002"""
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -07003Copyright 2015 Open Networking Foundation ( ONF )
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -07004
5Please refer questions to either the onos test mailing list at <onos-test@onosproject.org>,
6the System Testing Plans and Results wiki page at <https://wiki.onosproject.org/x/voMg>,
7or 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 Ronquillo23fb2162017-09-15 14:59:57 -070012 ( at your option ) any later version.
Jeremy Ronquillob27ce4c2017-07-17 12:41:28 -070013
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 Songster5665f1b2016-06-20 14:38:22 -070023from mininet.net import Mininet
24from mininet.topo import Topo
25from mininet.node import Host, RemoteController
26from mininet.cli import CLI
27from mininet.log import setLogLevel
28
29from opticalUtils import LINCSwitch, LINCLink
30
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070031
Jeremy Songster5665f1b2016-06-20 14:38:22 -070032class OpticalTopo( Topo ):
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070033
Jeremy Songster5665f1b2016-06-20 14:38:22 -070034 """
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070035 A simple optical topology of three LINC nodes( OE* ), two OVS switches( ps* ), and two hosts:
Jeremy Songster5665f1b2016-06-20 14:38:22 -070036
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 Ronquillo23fb2162017-09-15 14:59:57 -070055 for i in range( 1, 4 ):
Jeremy Songster5665f1b2016-06-20 14:38:22 -070056 oean = { "optical.regens": 0 }
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070057 oel.append( self.addSwitch( 'OE%s' % i, dpid='0000ffffffffff0%s' % i, annotations=oean, cls=LINCSwitch ) )
Jeremy Songster5665f1b2016-06-20 14:38:22 -070058
59 # ROADM port numbers are built as: OE1 <-> OE2 = 1200
60 # leaving port number up to 100 open for use by Och port
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070061 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 Songster5665f1b2016-06-20 14:38:22 -070064
65 # cross-connects between OVSes and LINCs
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070066 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 Songster5665f1b2016-06-20 14:38:22 -070068
69
70def 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 Ronquillo23fb2162017-09-15 14:59:57 -070075 i += 1
Jeremy Songster5665f1b2016-06-20 14:38:22 -070076
77 net.start()
78 LINCSwitch.bootOE( net )
79 CLI( net )
80 net.stop()
81 LINCSwitch.shutdownOE()
82
83
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070084if __name__ == "__main__":
Jeremy Songster5665f1b2016-06-20 14:38:22 -070085 import sys
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070086 if len( sys.argv ) >= 2:
Jeremy Songster5665f1b2016-06-20 14:38:22 -070087 setLogLevel( 'info' )
88 ctls = sys.argv[ 1: ]
89 setup( ctls )
90 else:
Jeremy Ronquillo23fb2162017-09-15 14:59:57 -070091 print( './ectopo.py [IP1] [IP2]...\n' )