blob: 8a89515ed9db9cbed24ec69f4af21815892cc0dc [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' )
38 OVSSwitch13 = partial( OVSSwitch, protocols='OpenFlow13' )
Andy Bavier8fef6102018-12-21 16:54:26 -070039 controllerIp = socket.gethostbyname( '{{ .Values.onosOpenflowSvc }}' )
Andy Bavier7a080492018-08-30 14:26:09 -070040 net = Mininet( topo=SingleSwitchTopo(1),
41 controller=lambda name: RemoteController( name, ip=controllerIp, port=6653 ),
42 switch=OVSSwitch13
43 )
44
45 switch = net.switches[ 0 ]
46 info( '*** Adding hardware interface eth1 to switch', switch.name, '\n' )
47 _intf = Intf( 'eth1', node=switch )
48
49 info( '*** Turning off checksum offloading for eth1\n' )
50 print quietRun( 'ethtool -K eth1 tx off rx off' )
51
52 bgphost = net.hosts [ 0 ]
53 info( '*** Adding VLAN interface to host\n')
54 bgphost.cmd( 'ip link add link h1-eth0 name h1-eth0.222 type vlan id 222' )
55 bgphost.cmd( 'ip link add link h1-eth0.222 name h1-eth0.222.111 type vlan id 111' )
56 bgphost.cmd( 'ifconfig h1-eth0.222 up' )
57 bgphost.cmd( 'ifconfig h1-eth0.222.111 up' )
58 bgphost.cmd( 'ifconfig h1-eth0.222.111 172.18.0.10/24' )
59 bgphost.cmd( 'dnsmasq --dhcp-range=172.18.0.50,172.18.0.150,12h' )
60
61 net.start()
62 CLI( net )
63 net.stop()