blob: a65085d5e3db97b7fa16058b76ad450d96995044 [file] [log] [blame]
Andy Bavier7a080492018-08-30 14:26:09 -07001#!/usr/bin/python
2
3# Copyright 2017-present Open Networking Foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17import re
18import sys
19import socket
20
21from mininet.cli import CLI
22from mininet.log import setLogLevel, info, error
23from mininet.net import Mininet
24from mininet.link import Intf
Andy Baviered9c5842019-05-20 09:53:48 -070025from mininet.topo import Topo, SingleSwitchTopo
26from mininet.node import OVSSwitch, Controller, RemoteController
27from mininet.nodelib import LinuxBridge
Andy Bavier7a080492018-08-30 14:26:09 -070028from functools import partial
29from mininet.util import quietRun
30
31if __name__ == '__main__':
32 setLogLevel( 'info' )
33
Andy Baviered9c5842019-05-20 09:53:48 -070034 info( '*** Installing required software\n' )
Andy Bavier7a080492018-08-30 14:26:09 -070035 print quietRun( 'apt-get update' )
Andy Baviered9c5842019-05-20 09:53:48 -070036 print quietRun( 'apt-get -y install dnsmasq ethtool wget pimd bridge-utils' )
37 print quietRun( 'wget https://github.com/troglobit/mcjoin/releases/download/v2.4/mcjoin_2.4_amd64.deb' )
38 print quietRun( 'dpkg -i mcjoin_2.4_amd64.deb' )
Andy Bavier7a080492018-08-30 14:26:09 -070039
Andy Bavier6ca22c02019-04-02 14:03:49 -070040 print quietRun( 'ovs-vsctl set Open_vSwitch . other_config:vlan-limit={{ .Values.vlanMatchDepth }}' )
Andy Bavier7a080492018-08-30 14:26:09 -070041 OVSSwitch13 = partial( OVSSwitch, protocols='OpenFlow13' )
Andy Bavier8fef6102018-12-21 16:54:26 -070042 controllerIp = socket.gethostbyname( '{{ .Values.onosOpenflowSvc }}' )
Andy Bavier7a080492018-08-30 14:26:09 -070043
Andy Baviered9c5842019-05-20 09:53:48 -070044 net = Mininet( topo=None )
45
46 info( '*** Adding controllers\n' )
47 onos = net.addController( name='onos', controller=RemoteController, ip=controllerIp, port=6653 )
48
49 info( '*** Adding switches\n' )
50 s1 = net.addSwitch( name='s1', cls=OVSSwitch13 )
51 s2 = net.addSwitch( 's2', cls=LinuxBridge )
52
53 info( '*** Creating hosts\n' )
54 h1 = net.addHost( 'h1', ip='10.0.0.1/24')
55 h2 = net.addHost( 'h2', ip='10.1.0.2/24')
56
57 # Topology: pon1 - eth1 - s1 - h1 - s2 - h2
58 net.addLink( h1, s1 )
59 net.addLink( h1, s2 )
60 net.addLink( h2, s2 )
61
62 info( '*** Adding hardware interface eth1 to switch %s\n' % s1.name)
63 _intf = Intf( 'eth1', node=s1 )
Andy Bavier7a080492018-08-30 14:26:09 -070064
65 info( '*** Turning off checksum offloading for eth1\n' )
66 print quietRun( 'ethtool -K eth1 tx off rx off' )
67
Andy Baviered9c5842019-05-20 09:53:48 -070068 info( '*** Adding VLAN interface to host %s\n' % h1.name)
69 base = "%s-eth0" % h1.name
70 h1.cmd( 'ifconfig %s-eth1 10.1.0.1/24 up' % h1.name)
71 h1.cmd( 'ip link add link %s name %s.222 type vlan proto 802.1Q id 222' % (base, base))
72 h1.cmd( 'ip link add link %s.222 name %s.222.111 type vlan proto 802.1Q id 111' % (base, base))
73 h1.cmd( 'ifconfig %s.222 up' % base)
74 h1.cmd( 'ifconfig %s.222.111 up' % base)
75 h1.cmd( 'ifconfig %s.222.111 172.18.0.10/24' % base)
76 h1.cmd( 'dnsmasq --dhcp-range=172.18.0.50,172.18.0.150,12h' )
77
78 onos.start()
79 s1.start( [onos] )
Andy Bavier7a080492018-08-30 14:26:09 -070080
81 net.start()
82 CLI( net )
83 net.stop()