4 Copyright (c) 2018 Xoriant Corporation and others. All rights reserved.
6 This program and the accompanying materials are made available under
7 the terms of the Eclipse Public License v1.0 which accompanies this distribution,
8 and is available at http://www.eclipse.org/legal/epl-v10.html
17 from mininet.cli import CLI
18 from mininet.log import setLogLevel, info, error
19 from mininet.net import Mininet
20 from mininet.link import Intf
21 from mininet.util import quietRun
22 from mininet.node import Controller, RemoteController
23 from mininet.topo import Topo
24 from mininet.node import Node
25 from mininet.util import waitListening
26 from functools import partial
27 from mininet.node import OVSSwitch
29 class PocTopo( Topo ):
30 "Topology prepared for Presto NRP tutorial"
37 # Add hosts and switches
38 h1 = self.addHost( 'h1' )
39 h2 = self.addHost( 'h2' )
40 h3 = self.addHost( 'h3' )
42 s1 = self.addSwitch( 's1' )
43 s2 = self.addSwitch( 's2' )
44 s3 = self.addSwitch( 's3' )
45 s4 = self.addSwitch( 's4' )
47 self.addLink( h1, s1 )
48 self.addLink( h2, s2 )
49 self.addLink( h3, s3 )
50 self.addLink( s1, s4 )
51 self.addLink( s2, s4 )
52 self.addLink( s3, s4 )
55 #topos = { 'poctopo': ( lambda: PocTopo() ) }
57 if __name__ == '__main__':
60 os.system('ovs-vsctl set-manager ptcp:6640')
65 # defaultIF4 = 'enp0s10'
66 defaultControllerIP = '127.0.0.1'
67 defaultInputSwitch = 0
68 defaultOutputSwitch = 1
70 # try to get hw intfs from the command line; by default, use eth1 and eth2
71 odl_controller_ip = sys.argv[ 1 ] if len( sys.argv ) > 1 else defaultControllerIP
72 intfName = sys.argv[ 2 ] if len( sys.argv ) > 2 else ""
73 intfName2 = sys.argv[ 3 ] if len( sys.argv ) > 3 else ""
74 intfName3 = sys.argv[ 4 ] if len( sys.argv ) > 4 else ""
75 intfName4 = sys.argv[ 5 ] if len( sys.argv ) > 5 else ""
81 OVSSwitch13 = partial( OVSSwitch, protocols='OpenFlow13' )
85 net = Mininet(topo, switch=OVSSwitch13, controller=partial( RemoteController, ip=odl_controller_ip, port=6633 ) )
88 switch = net.switches[ input_switch0 ]
89 info( '*** Adding hardware interface', intfName, 'to switch', switch.name, '\n' )
90 Intf( intfName, node=switch )
93 switch2 = net.switches[ input_switch1 ]
94 info( '*** Adding hardware interface', intfName2, 'to switch', switch2.name, '\n' )
95 Intf(intfName2, node=switch2)
98 switch3 = net.switches[ input_switch2 ]
99 info( '*** Adding hardware interface', intfName3, 'to switch', switch3.name, '\n' )
100 Intf(intfName3, node=switch3)
105 # os.system('ovs-ofctl -O OpenFlow13 del-flows s'+str(input_switch+1))
106 # os.system('ovs-ofctl -O OpenFlow13 del-flows s'+str(output_switch+1))