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