Browse Source

Add Fuel OVS plugin demo script

Change-Id: I558e8ade392f7649ca938f8eb841de285b69bf6b
Signed-off-by: Guo Ruijing <ruijing.guo@intel.com>
tags/10.0-eol
Guo Ruijing 3 years ago
parent
commit
37cc96b2fa

+ 64
- 0
demo/01_setup_network.sh View File

@@ -0,0 +1,64 @@
1
+#!/bin/sh
2
+HTTP_PROXY=http://10.19.8.225:911
3
+DNS_SERVER=10.248.2.1
4
+SOCK5_IP=10.7.211.16
5
+SOCK5_PORT=1080
6
+
7
+cat <<EOF | sudo tee /etc/apt/apt.conf
8
+Acquire::http::Proxy "$HTTP_PROXY";
9
+EOF
10
+
11
+sudo apt-get update -y
12
+sudo apt-get install redsocks -y
13
+
14
+cat <<EOF | sudo tee /etc/redsocks.conf
15
+base {
16
+ log_debug = on;
17
+ log_info = on;
18
+ log = "file:/root/proxy.log";
19
+ daemon = on;
20
+ redirector = iptables;
21
+}
22
+
23
+redsocks {
24
+ local_ip = 0.0.0.0;
25
+ local_port = 6666;
26
+ ip = $SOCK5_IP;
27
+ port = $SOCK5_PORT;
28
+ type = socks5;
29
+}
30
+
31
+EOF
32
+
33
+sudo apt-get install iptables -y
34
+
35
+echo  1 | sudo tee /proc/sys/net/ipv4/ip_forward 
36
+
37
+sudo iptables -t filter -F
38
+sudo iptables -t mangle -F
39
+sudo iptables -t nat -F
40
+
41
+#DNS DNAT
42
+sudo iptables -t nat -A PREROUTING  -p udp --dport 53  -j DNAT --to-destination $DNS_SERVER
43
+
44
+#NTP DNAT
45
+sudo iptables -t nat -A PREROUTING  -p udp --dport 123 -j DNAT --to-destination 10.20.0.1
46
+
47
+sudo iptables -t nat -A POSTROUTING -s 10.20.0.0/24 -j MASQUERADE
48
+sudo iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -j MASQUERADE
49
+
50
+sudo iptables -t nat -N REDSOCKS
51
+sudo iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
52
+sudo iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
53
+sudo iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
54
+sudo iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
55
+sudo iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
56
+sudo iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
57
+sudo iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
58
+sudo iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN
59
+sudo iptables -t nat -A REDSOCKS -p tcp -j REDIRECT --to-ports 6666
60
+sudo iptables -t nat -A REDSOCKS -p udp -j REDIRECT --to-ports 9999
61
+sudo iptables -t nat -A OUTPUT -p tcp  -j REDSOCKS
62
+sudo iptables -t nat -A PREROUTING -p tcp  -j REDSOCKS
63
+
64
+sudo service redsocks restart

+ 28
- 0
demo/02_install_packages.sh View File

@@ -0,0 +1,28 @@
1
+#!/bin/sh
2
+
3
+cat << EOF | sudo tee /etc/sudoers.d/fuel
4
+fuel ALL = (root) NOPASSWD:ALL
5
+EOF
6
+
7
+sudo apt-get update -y
8
+sudo apt-get install openssh-server -y
9
+sudo apt-get autoremove gnome-settings-daemon-schemas -y
10
+sudo apt-get autoremove libmetacity-private0a metacity-common -y
11
+sudo apt-get install gnome-session gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal -y
12
+sudo apt-get install virt-manager libvirt-bin qemu-system -y
13
+sudo virsh net-destroy default
14
+sudo virsh net-undefine default
15
+sudo rm -rf /etc/libvirt/qemu/networks/autostart/default.xml
16
+sudo service libvirt-bin restart
17
+sudo ifconfig virbr0 down
18
+sudo brctl delbr virbr0
19
+sudo apt-get install putty-tools -y
20
+sudo service ntp stop
21
+sudo apt-get autoremove ntp -y
22
+sudo rm -rf /etc/ntp.conf.dpkg-old
23
+sudo rm -rf /etc/ntp.conf
24
+sudo apt-get install ntp -y --force-yes
25
+sudo bash -c 'cat << EOF >> /etc/ntp.conf
26
+server 127.127.1.0
27
+fudge  127.127.1.0 stratum 10
28
+EOF'

+ 25
- 0
demo/03_setup_vnc.sh View File

@@ -0,0 +1,25 @@
1
+#!/bin/sh
2
+rm -rf ~/.vnc; mkdir ~/.vnc
3
+echo "123456\n123456\n" | vncpasswd
4
+
5
+cat << EOF > ~/.vnc/xstartup
6
+#!/bin/bash
7
+DESK_TYPE=gnome
8
+export XKL_XMODMAP_DISABLE=1
9
+unset SESSION_MANAGER
10
+unset DBUS_SESSION_BUS_ADDRESS
11
+[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
12
+xsetroot -solid grey
13
+vncconfig -iconic &
14
+vncconfig -nowin &
15
+gnome-session &
16
+gnome-panel &
17
+gnome-settings-daemon &
18
+metacity &
19
+nautilus -n &
20
+gnome-terminal &
21
+EOF
22
+
23
+chmod 755 ~/.vnc/xstartup
24
+vnc4server -geometry 1650x950 -depth 16 &
25
+echo "vnc password is 123456"

+ 69
- 0
demo/04_setup_fuel.sh View File

@@ -0,0 +1,69 @@
1
+#!/bin/bash
2
+
3
+#setup ntp server
4
+sudo service ntp restart
5
+
6
+#setup network
7
+
8
+sudo ifconfig br-eth0 down
9
+sudo brctl delbr br-eth0
10
+sudo brctl addbr br-eth0
11
+sudo ifconfig br-eth0 10.20.0.1/24 up
12
+
13
+sudo ifconfig br-eth1 down
14
+sudo brctl delbr br-eth1
15
+sudo brctl addbr br-eth1
16
+sudo ifconfig br-eth1 172.16.0.1/24 up
17
+
18
+sudo ifconfig br-dpdk down
19
+sudo brctl delbr br-dpdk
20
+sudo brctl addbr br-dpdk
21
+
22
+#setup master
23
+
24
+sudo virt-manager
25
+sudo virsh destroy fuel-master
26
+sudo rm -rf /var/lib/libvirt/images/fuel-master.img
27
+sudo qemu-img create -f qcow2 /var/lib/libvirt/images/fuel-master.img 200G
28
+
29
+mkdir -p vms
30
+
31
+iso=`pwd`/`ls *.iso`
32
+sed  "s~ISO_FILE~$iso~g" fuel-master.xml > vms/fuel-master.xml
33
+
34
+sudo virsh create vms/fuel-master.xml
35
+
36
+#login fuel master
37
+sleep 30
38
+rm -rf ~/.ssh/known_hosts
39
+sudo rm -rf ~/.putty
40
+inprog=1
41
+while [ $inprog -ne 0 ]
42
+do
43
+   echo "y\n" | plink -ssh -pw r00tme root@10.20.0.2 "echo y" >& /dev/null
44
+   inprog=$?
45
+   sleep 20
46
+done
47
+
48
+#cat astute.yaml | plink -ssh  -pw r00tme root@10.20.0.2 "dd of=/etc/fuel/astute.yaml"
49
+#echo plink -ssh  -pw r00tme root@10.20.0.2 "pkill fuelmenu"
50
+
51
+inprog=1
52
+while [ $inprog -ne 0 ]
53
+do
54
+   echo "y\n" | plink -ssh -pw r00tme root@10.20.0.2 "grep 'Fuel node deployment complete' /var/log/puppet/bootstrap_admin_node.log "  >& /dev/null
55
+   inprog=$?
56
+   sleep 20
57
+done
58
+
59
+#setup slave
60
+for i in {1..4}; do
61
+    sudo virsh destroy fuel-slave-$i
62
+    sudo rm -rf /var/lib/libvirt/images/fuel-slave-${i}.img
63
+    sudo qemu-img create -f qcow2 /var/lib/libvirt/images/fuel-slave-${i}.img 200G
64
+    sed "s/FUEL_SLAVE/fuel-slave-$i/g" fuel-slave.xml > vms/fuel-slave-${i}.xml
65
+    sudo virsh create vms/fuel-slave-${i}.xml
66
+done
67
+
68
+#setup web browser
69
+firefox https://10.20.0.2:8443 >& /dev/null &

+ 13
- 0
demo/05_destroy_fuel.sh View File

@@ -0,0 +1,13 @@
1
+#!/bin/bash
2
+
3
+sudo virt-manager
4
+
5
+#destroy master
6
+sudo virsh destroy fuel-master
7
+sudo rm -rf /var/lib/libvirt/images/fuel-master.img
8
+
9
+#destroy slave
10
+for i in {1..4}; do
11
+    sudo virsh destroy fuel-slave-$i
12
+    sudo rm -rf /var/lib/libvirt/images/fuel-slave-${i}.img
13
+done

+ 42
- 0
demo/README.md View File

@@ -0,0 +1,42 @@
1
+Fuel OVS Plugin Demo Script
2
+===========================
3
+
4
+Overview
5
+--------
6
+
7
+This directory includes scripts to setup fuel ovs plugin demo.
8
+
9
+The scripts are ONLY tested in new installation of Ubuntu 14.04.03 Desktop
10
+64bit. Extra configuration or Extra packages such as virtualbox may break
11
+functionality. All packages or network configuration are provided by the
12
+the following scripts.
13
+
14
+Scripts
15
+-------
16
+
17
+1. 01_setup_network.sh
18
+
19
+The script is to setup socks5 proxy. You may change the script to support
20
+NAT. The following network setting is updated before running the script:
21
+
22
+a. HTTP_PROXY: proxy for package installation
23
+b. DNS_SERVER: DNS for fuel VM
24
+c. SOCK5_IP:  socks5 proxy for fuel VM
25
+d. SOCK5_PORT: socks5 proxy for fuel VM
26
+
27
+2. 02_install_packages.sh
28
+
29
+The script is to install all packages
30
+
31
+3. 03_setup_vnc.sh
32
+
33
+The script is to setup vnc. Default vnc password is 123456.
34
+
35
+4. 04_setup_fuel.sh
36
+
37
+The script is to create 1 master VM and 4 slave VMs. Fuel ISO is copied to this
38
+directory before running the script.
39
+
40
+5. 05_destroy_fuel.sh
41
+
42
+The script is to destroy 1 master VM and 4 slave VMs.

+ 94
- 0
demo/fuel-master.xml View File

@@ -0,0 +1,94 @@
1
+<domain type='kvm' id='5'>
2
+  <name>fuel-master</name>
3
+  <memory unit='KiB'>4194304</memory>
4
+  <currentMemory unit='KiB'>4194304</currentMemory>
5
+  <vcpu placement='static'>4</vcpu>
6
+  <resource>
7
+    <partition>/machine</partition>
8
+  </resource>
9
+  <os>
10
+    <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type>
11
+    <boot dev='hd'/>
12
+    <boot dev='cdrom'/>
13
+    <bootmenu enable='yes'/>
14
+  </os>
15
+  <features>
16
+    <acpi/>
17
+    <apic/>
18
+    <pae/>
19
+  </features>
20
+  <clock offset='utc'/>
21
+  <on_poweroff>destroy</on_poweroff>
22
+  <on_reboot>restart</on_reboot>
23
+  <on_crash>restart</on_crash>
24
+  <devices>
25
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
26
+    <disk type='file' device='disk'>
27
+      <driver name='qemu' type='qcow2'/>
28
+      <source file='/var/lib/libvirt/images/fuel-master.img'/>
29
+      <target dev='hda' bus='ide'/>
30
+      <alias name='ide0-0-0'/>
31
+      <address type='drive' controller='0' bus='0' target='0' unit='0'/>
32
+    </disk>
33
+    <disk type='file' device='cdrom'>
34
+      <driver name='qemu' type='raw'/>
35
+      <source file='ISO_FILE' />
36
+      <target dev='hdc' bus='ide'/>
37
+      <readonly/>
38
+      <alias name='ide0-1-0'/>
39
+      <address type='drive' controller='0' bus='1' target='0' unit='0'/>
40
+    </disk>
41
+    <controller type='usb' index='0'>
42
+      <alias name='usb0'/>
43
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
44
+    </controller>
45
+    <controller type='pci' index='0' model='pci-root'>
46
+      <alias name='pci.0'/>
47
+    </controller>
48
+    <controller type='ide' index='0'>
49
+      <alias name='ide0'/>
50
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
51
+    </controller>
52
+    <interface type='bridge'>
53
+      <source bridge='br-eth0'/>
54
+      <target dev='vnet0'/>
55
+      <model type='virtio'/>
56
+      <alias name='net0'/>
57
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
58
+    </interface>
59
+    <serial type='pty'>
60
+      <source path='/dev/pts/16'/>
61
+      <target port='0'/>
62
+      <alias name='serial0'/>
63
+    </serial>
64
+    <console type='pty' tty='/dev/pts/16'>
65
+      <source path='/dev/pts/16'/>
66
+      <target type='serial' port='0'/>
67
+      <alias name='serial0'/>
68
+    </console>
69
+    <input type='tablet' bus='usb'>
70
+      <alias name='input0'/>
71
+    </input>
72
+    <input type='mouse' bus='ps2'/>
73
+    <input type='keyboard' bus='ps2'/>
74
+    <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>
75
+      <listen type='address' address='127.0.0.1'/>
76
+    </graphics>
77
+    <sound model='ich6'>
78
+      <alias name='sound0'/>
79
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
80
+    </sound>
81
+    <video>
82
+      <model type='cirrus' vram='9216' heads='1'/>
83
+      <alias name='video0'/>
84
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
85
+    </video>
86
+    <memballoon model='virtio'>
87
+      <alias name='balloon0'/>
88
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
89
+    </memballoon>
90
+  </devices>
91
+  <seclabel type='dynamic' model='apparmor' relabel='yes'>
92
+  </seclabel>
93
+</domain>
94
+

+ 92
- 0
demo/fuel-slave.xml View File

@@ -0,0 +1,92 @@
1
+<domain type='kvm' id='75'>
2
+  <name>FUEL_SLAVE</name>
3
+  <memory unit='KiB'>4194304</memory>
4
+  <currentMemory unit='KiB'>4194304</currentMemory>
5
+  <vcpu placement='static'>4</vcpu>
6
+  <resource>
7
+    <partition>/machine</partition>
8
+  </resource>
9
+  <os>
10
+    <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type>
11
+    <boot dev='network'/>
12
+    <boot dev='hd'/>
13
+    <bootmenu enable='no' />
14
+  </os>
15
+  <features>
16
+    <acpi/>
17
+    <apic/>
18
+    <pae/>
19
+  </features>
20
+  <cpu mode='custom' match='exact'>
21
+    <model fallback='allow'>SandyBridge</model>
22
+    <vendor>Intel</vendor>
23
+    <feature policy='require' name='vmx'/>
24
+  </cpu>
25
+  <clock offset='utc'/>
26
+  <on_poweroff>destroy</on_poweroff>
27
+  <on_reboot>restart</on_reboot>
28
+  <on_crash>restart</on_crash>
29
+  <devices>
30
+    <emulator>/usr/bin/qemu-system-x86_64</emulator>
31
+    <disk type='file' device='disk'>
32
+      <driver name='qemu' type='qcow2'/>
33
+      <source file='/var/lib/libvirt/images/FUEL_SLAVE.img'/>
34
+      <target dev='vda' bus='virtio'/>
35
+      <alias name='virtio-disk0'/>
36
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>
37
+    </disk>
38
+    <controller type='usb' index='0'>
39
+      <alias name='usb0'/>
40
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
41
+    </controller>
42
+    <controller type='pci' index='0' model='pci-root'>
43
+      <alias name='pci.0'/>
44
+    </controller>
45
+    <interface type='bridge'>
46
+      <source bridge='br-eth0'/>
47
+      <model type='e1000' />
48
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
49
+    </interface>
50
+    <interface type='bridge'>
51
+      <source bridge='br-eth1'/>
52
+      <model type='e1000' />
53
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
54
+    </interface>
55
+    <interface type='bridge'>
56
+      <source bridge='br-dpdk'/>
57
+      <model type='e1000' />
58
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
59
+    </interface>
60
+    <serial type='pty'>
61
+      <source path='/dev/pts/20'/>
62
+      <target port='0'/>
63
+      <alias name='serial0'/>
64
+    </serial>
65
+    <console type='pty' tty='/dev/pts/20'>
66
+      <source path='/dev/pts/20'/>
67
+      <target type='serial' port='0'/>
68
+      <alias name='serial0'/>
69
+    </console>
70
+    <input type='mouse' bus='ps2'/>
71
+    <input type='keyboard' bus='ps2'/>
72
+    <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1'>
73
+      <listen type='address' address='127.0.0.1'/>
74
+    </graphics>
75
+    <sound model='ich6'>
76
+      <alias name='sound0'/>
77
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>
78
+    </sound>
79
+    <video>
80
+      <model type='cirrus' vram='9216' heads='1'/>
81
+      <alias name='video0'/>
82
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x02' function='0x0'/>
83
+    </video>
84
+    <memballoon model='virtio'>
85
+      <alias name='balloon0'/>
86
+      <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>
87
+    </memballoon>
88
+  </devices>
89
+  <seclabel type='dynamic' model='apparmor' relabel='yes'>
90
+  </seclabel>
91
+</domain>
92
+

Loading…
Cancel
Save