blob: 0c9c7cf6a76aabc65107f84d9e9cb00e3880d699 [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
25from mininet.topo import SingleSwitchTopo
26from mininet.node import OVSSwitch, RemoteController
27from functools import partial
28from mininet.util import quietRun
29
30if __name__ == '__main__':
31 setLogLevel( 'info' )
32
33 info( '*** Installing required software' )
34 print quietRun( 'apt-get update' )
35 print quietRun( 'apt-get -y install dnsmasq ethtool' )
36
37 info( '*** Creating network\n' )
Andy Bavier6ca22c02019-04-02 14:03:49 -070038 print quietRun( 'ovs-vsctl set Open_vSwitch . other_config:vlan-limit={{ .Values.vlanMatchDepth }}' )
Andy Bavier7a080492018-08-30 14:26:09 -070039 OVSSwitch13 = partial( OVSSwitch, protocols='OpenFlow13' )
Andy Bavier8fef6102018-12-21 16:54:26 -070040 controllerIp = socket.gethostbyname( '{{ .Values.onosOpenflowSvc }}' )
Andy Bavier7a080492018-08-30 14:26:09 -070041 net = Mininet( topo=SingleSwitchTopo(1),
42 controller=lambda name: RemoteController( name, ip=controllerIp, port=6653 ),
43 switch=OVSSwitch13
44 )
45
46 switch = net.switches[ 0 ]
47 info( '*** Adding hardware interface eth1 to switch', switch.name, '\n' )
48 _intf = Intf( 'eth1', node=switch )
49
50 info( '*** Turning off checksum offloading for eth1\n' )
51 print quietRun( 'ethtool -K eth1 tx off rx off' )
52
53 bgphost = net.hosts [ 0 ]
54 info( '*** Adding VLAN interface to host\n')
Andy Bavier6ca22c02019-04-02 14:03:49 -070055 bgphost.cmd( 'ip link add link h1-eth0 name h1-eth0.222 type vlan proto 802.1Q id 222' )
56 bgphost.cmd( 'ip link add link h1-eth0.222 name h1-eth0.222.111 type vlan proto 802.1Q id 111' )
Andy Bavier7a080492018-08-30 14:26:09 -070057 bgphost.cmd( 'ifconfig h1-eth0.222 up' )
58 bgphost.cmd( 'ifconfig h1-eth0.222.111 up' )
59 bgphost.cmd( 'ifconfig h1-eth0.222.111 172.18.0.10/24' )
60 bgphost.cmd( 'dnsmasq --dhcp-range=172.18.0.50,172.18.0.150,12h' )
61
62 net.start()
63 CLI( net )
64 net.stop()