File: openvswitch-init-example

package info (click to toggle)
os-autoinst 4.3%2Bgit20160919-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 10,860 kB
  • ctags: 665
  • sloc: perl: 7,624; cpp: 1,584; python: 216; makefile: 188; sh: 63
file content (47 lines) | stat: -rwxr-xr-x 1,481 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/sh -x
# this script configures openvswitch for use with os-autoinst:
# * create the bridge
# * add (existing) tap devices
# * configure connection to 10.0.2.2 that works across VLANs
#

# delete existing configuration
ovs-vsctl --if-exists del-br br0

#create bridge
ovs-vsctl add-br br0

# connect with other hosts
#ovs-vsctl add-port br0 gre0 -- set interface gre0 type=gre options:remote_ip=<IP address of other host>


# add tap devices, use vlan 999 by default, the vlan number is supposed to be changed when the vm starts
ovs-vsctl add-port br0 tap0 tag=999
ovs-vsctl add-port br0 tap1 tag=999
ovs-vsctl add-port br0 tap2 tag=999
ovs-vsctl add-port br0 tap3 tag=999
ovs-vsctl add-port br0 tap4 tag=999


# the VM have unique MAC that differs in the last 16 bits (see /usr/lib/os-autoinst/backend/qemu.pm)
# the IP can conflict across vlans
# to allow connection from VM  to host os-autoinst (10.0.2.2), we have to do some IP translation
# we use simple scheme:
# MAC 52:54:00:12:XX:YY -> IP 10.1.XX.YY

# br0 has IP 10.0.2.2 and netmask /15 that covers 10.0.0.0 and 10.1.0.0 ranges
# this should be also configured permanently in /etc/sysconfig/network
ip addr add 10.0.2.2/15 dev br0
ip route add 10.0.0.0/15 dev br0
ip link set br0 up

#
# configure NAT between br0 and eth0 (SuSEfirewall)

# start os-autoinst-openvswitch.service
systemctl restart os-autoinst-openvswitch.service

# show the configuration
ovs-vsctl show
ovs-ofctl show br0
ovs-ofctl dump-flows br0