Browse code

XenServer: new build and install scripts

Change-Id: Ia13a9c8073e59edf98415ba5b9f3a9cbd1453d32

Renuka Apte authored on 2012/04/03 07:46:53
Showing 7 changed files
... ...
@@ -313,7 +313,7 @@ function read_password {
313 313
 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
314 314
     PUBLIC_INTERFACE_DEFAULT=eth3
315 315
     # allow build_domU.sh to specify the flat network bridge via kernel args
316
-    FLAT_NETWORK_BRIDGE_DEFAULT=$(grep -o 'flat_network_bridge=[^.]*' /proc/cmdline | cut -d= -f 2)
316
+    FLAT_NETWORK_BRIDGE_DEFAULT=$(grep -o 'flat_network_bridge=[[:alnum:]]*' /proc/cmdline | cut -d= -f 2 | sort -u)
317 317
     GUEST_INTERFACE_DEFAULT=eth1
318 318
 else
319 319
     PUBLIC_INTERFACE_DEFAULT=br100
320 320
deleted file mode 100755
... ...
@@ -1,244 +0,0 @@
1
-#!/bin/bash
2
-
3
-# Abort if localrc is not set
4
-if [ ! -e ../../localrc ]; then
5
-    echo "You must have a localrc with ALL necessary passwords defined before proceeding."
6
-    echo "See the xen README for required passwords."
7
-    exit 1
8
-fi
9
-
10
-# This directory
11
-TOP_DIR=$(cd $(dirname "$0") && pwd)
12
-
13
-# Source lower level functions
14
-. $TOP_DIR/../../functions
15
-
16
-# Source params - override xenrc params in your localrc to suit your taste
17
-source xenrc
18
-
19
-# Echo commands
20
-set -o xtrace
21
-
22
-# Check for xva file
23
-if [ ! -e $XVA ]; then
24
-    echo "Missing xva file.  Please run build_xva.sh (ideally on a non dom0 host since the build can require lots of space)."
25
-    echo "Place the resulting xva file in $XVA"
26
-    exit 1
27
-fi
28
-
29
-# Make sure we have git
30
-if ! which git; then
31
-    GITDIR=/tmp/git-1.7.7
32
-    cd /tmp
33
-    rm -rf $GITDIR*
34
-    wget http://git-core.googlecode.com/files/git-1.7.7.tar.gz
35
-    tar xfv git-1.7.7.tar.gz
36
-    cd $GITDIR
37
-    ./configure --with-curl --with-expat
38
-    make install
39
-    cd $TOP_DIR
40
-fi
41
-
42
-# Helper to create networks
43
-# Uses echo trickery to return network uuid
44
-function create_network() {
45
-    br=$1
46
-    dev=$2
47
-    vlan=$3
48
-    netname=$4
49
-    if [ -z $br ]
50
-    then
51
-        pif=$(xe pif-list --minimal device=$dev VLAN=$vlan)
52
-        if [ -z $pif ]
53
-        then
54
-            net=$(xe network-create name-label=$netname)
55
-        else
56
-            net=$(xe network-list --minimal PIF-uuids=$pif)
57
-        fi
58
-        echo $net
59
-        return 0
60
-    fi
61
-    if [ ! $(xe network-list --minimal params=bridge | grep -w --only-matching $br) ]
62
-    then
63
-        echo "Specified bridge $br does not exist"
64
-        echo "If you wish to use defaults, please keep the bridge name empty"
65
-        exit 1
66
-    else
67
-        net=$(xe network-list --minimal bridge=$br)
68
-        echo $net
69
-    fi
70
-}
71
-
72
-function errorcheck() {
73
-    rc=$?
74
-    if [ $rc -ne 0 ]
75
-    then
76
-        exit $rc
77
-    fi
78
-}
79
-
80
-# Create host, vm, mgmt, pub networks
81
-VM_NET=$(create_network "$VM_BR" "$VM_DEV" "$VM_VLAN" "vmbr")
82
-errorcheck
83
-MGT_NET=$(create_network "$MGT_BR" "$MGT_DEV" "$MGT_VLAN" "mgtbr")
84
-errorcheck
85
-PUB_NET=$(create_network "$PUB_BR" "$PUB_DEV" "$PUB_VLAN" "pubbr")
86
-errorcheck
87
-
88
-# Helper to create vlans
89
-function create_vlan() {
90
-    dev=$1
91
-    vlan=$2
92
-    net=$3
93
-    # VLAN -1 refers to no VLAN (physical network)
94
-    if [ $vlan -eq -1 ]
95
-    then
96
-        return
97
-    fi
98
-    if [ -z $(xe vlan-list --minimal tag=$vlan) ]
99
-    then
100
-        pif=$(xe pif-list --minimal network-uuid=$net)
101
-        # We created a brand new network this time
102
-        if [ -z $pif ]
103
-        then
104
-            pif=$(xe pif-list --minimal device=$dev VLAN=-1)
105
-            xe vlan-create pif-uuid=$pif vlan=$vlan network-uuid=$net
106
-        else
107
-            echo "VLAN does not exist but PIF attached to this network"
108
-            echo "How did we reach here?"
109
-            exit 1
110
-        fi
111
-    fi
112
-}
113
-
114
-# Create vlans for vm and management
115
-create_vlan $PUB_DEV $PUB_VLAN $PUB_NET
116
-create_vlan $VM_DEV $VM_VLAN $VM_NET
117
-create_vlan $MGT_DEV $MGT_VLAN $MGT_NET
118
-
119
-# dom0 ip
120
-HOST_IP=${HOST_IP:-`ifconfig xenbr0 | grep "inet addr" | cut -d ":" -f2 | sed "s/ .*//"`}
121
-
122
-# Set up ip forwarding
123
-if ! grep -q "FORWARD_IPV4=YES" /etc/sysconfig/network; then
124
-    # FIXME: This doesn't work on reboot!
125
-    echo "FORWARD_IPV4=YES" >> /etc/sysconfig/network
126
-fi
127
-
128
-# Also, enable ip forwarding in rc.local, since the above trick isn't working
129
-if ! grep -q  "echo 1 >/proc/sys/net/ipv4/ip_forward" /etc/rc.local; then
130
-    echo "echo 1 >/proc/sys/net/ipv4/ip_forward" >> /etc/rc.local
131
-fi
132
-
133
-# Enable ip forwarding at runtime as well
134
-echo 1 > /proc/sys/net/ipv4/ip_forward
135
-
136
-# Set local storage il8n
137
-SR_UUID=`xe sr-list --minimal name-label="Local storage"`
138
-xe sr-param-set uuid=$SR_UUID other-config:i18n-key=local-storage
139
-
140
-# Checkout nova
141
-git_clone $NOVA_REPO $TOP_DIR/nova $NOVA_BRANCH
142
-
143
-# Install plugins
144
-cp -pr $TOP_DIR/nova/plugins/xenserver/xenapi/etc/xapi.d /etc/
145
-chmod a+x /etc/xapi.d/plugins/*
146
-yum --enablerepo=base install -y parted
147
-mkdir -p /boot/guest
148
-
149
-# Shutdown previous runs
150
-DO_SHUTDOWN=${DO_SHUTDOWN:-1}
151
-if [ "$DO_SHUTDOWN" = "1" ]; then
152
-    # Shutdown all domU's that created previously
153
-    xe vm-list --minimal name-label="$LABEL" | xargs ./scripts/uninstall-os-vpx.sh
154
-
155
-    # Destroy any instances that were launched
156
-    for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do
157
-        echo "Shutting down nova instance $uuid"
158
-        xe vm-unpause uuid=$uuid || true
159
-        xe vm-shutdown uuid=$uuid
160
-        xe vm-destroy uuid=$uuid
161
-    done
162
-
163
-    # Destroy orphaned vdis
164
-    for uuid in `xe vdi-list | grep -1 Glance | grep uuid | sed "s/.*\: //g"`; do
165
-        xe vdi-destroy uuid=$uuid
166
-    done
167
-fi
168
-
169
-# Start guest
170
-if [ -z $VM_BR ]; then
171
-    VM_BR=$(xe network-list --minimal uuid=$VM_NET params=bridge)
172
-fi
173
-if [ -z $MGT_BR ]; then
174
-    MGT_BR=$(xe network-list --minimal uuid=$MGT_NET params=bridge)
175
-fi
176
-if [ -z $PUB_BR ]; then
177
-    PUB_BR=$(xe network-list --minimal uuid=$PUB_NET params=bridge)
178
-fi
179
-$TOP_DIR/scripts/install-os-vpx.sh -f $XVA -v $VM_BR -m $MGT_BR -p $PUB_BR -l $GUEST_NAME -w -k "flat_network_bridge=${VM_BR}"
180
-
181
-if [ $PUB_IP == "dhcp" ]; then
182
-    PUB_IP=$(xe vm-list --minimal name-label=$GUEST_NAME params=networks |  sed -ne 's,^.*3/ip: \([0-9.]*\).*$,\1,p')
183
-fi
184
-
185
-# If we have copied our ssh credentials, use ssh to monitor while the installation runs
186
-WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1}
187
-if [ "$WAIT_TILL_LAUNCH" = "1" ]  && [ -e ~/.ssh/id_rsa.pub  ] && [ "$COPYENV" = "1" ]; then
188
-    # Done creating the container, let's tail the log
189
-    echo
190
-    echo "============================================================="
191
-    echo "                          -- YAY! --"
192
-    echo "============================================================="
193
-    echo
194
-    echo "We're done launching the vm, about to start tailing the"
195
-    echo "stack.sh log. It will take a second or two to start."
196
-    echo
197
-    echo "Just CTRL-C at any time to stop tailing."
198
-
199
-    set +o xtrace
200
-
201
-    while ! ssh -q stack@$PUB_IP "[ -e run.sh.log ]"; do
202
-      sleep 1
203
-    done
204
-
205
-    ssh stack@$PUB_IP 'tail -f run.sh.log' &
206
-
207
-    TAIL_PID=$!
208
-
209
-    function kill_tail() {
210
-        kill $TAIL_PID
211
-        exit 1
212
-    }
213
-
214
-    # Let Ctrl-c kill tail and exit
215
-    trap kill_tail SIGINT
216
-
217
-    echo "Waiting stack.sh to finish..."
218
-    while ! ssh -q stack@$PUB_IP "grep -q 'stack.sh completed in' run.sh.log"; do
219
-        sleep 1
220
-    done
221
-
222
-    kill $TAIL_PID
223
-
224
-    if ssh -q stack@$PUB_IP "grep -q 'stack.sh failed' run.sh.log"; then
225
-        exit 1
226
-    fi
227
-    echo ""
228
-    echo "Finished - Zip-a-dee Doo-dah!"
229
-    echo "You can then visit the OpenStack Dashboard"
230
-    echo "at http://$PUB_IP, and contact other services at the usual ports."
231
-else
232
-    echo "################################################################################"
233
-    echo ""
234
-    echo "All Finished!"
235
-    echo "Now, you can monitor the progress of the stack.sh installation by "
236
-    echo "tailing /opt/stack/run.sh.log from within your domU."
237
-    echo ""
238
-    echo "ssh into your domU now: 'ssh stack@$PUB_IP' using your password"
239
-    echo "and then do: 'tail -f /opt/stack/run.sh.log'"
240
-    echo ""
241
-    echo "When the script completes, you can then visit the OpenStack Dashboard"
242
-    echo "at http://$PUB_IP, and contact other services at the usual ports."
243
-
244
-fi
... ...
@@ -1,5 +1,27 @@
1 1
 #!/bin/bash
2 2
 
3
+set -e
4
+
5
+declare -a on_exit_hooks
6
+
7
+on_exit()
8
+{
9
+    for i in $(seq $((${#on_exit_hooks[*]} - 1)) -1 0)
10
+    do
11
+        eval "${on_exit_hooks[$i]}"
12
+    done
13
+}
14
+
15
+add_on_exit()
16
+{
17
+    local n=${#on_exit_hooks[*]}
18
+    on_exit_hooks[$n]="$*"
19
+    if [[ $n -eq 0 ]]
20
+    then
21
+        trap on_exit EXIT
22
+    fi
23
+}
24
+
3 25
 # Abort if localrc is not set
4 26
 if [ ! -e ../../localrc ]; then
5 27
     echo "You must have a localrc with ALL necessary passwords defined before proceeding."
... ...
@@ -16,27 +38,11 @@ source xenrc
16 16
 # Echo commands
17 17
 set -o xtrace
18 18
 
19
-# Directory where we stage the build
20
-STAGING_DIR=$TOP_DIR/stage
21
-
22
-# Option to clean out old stuff
23
-CLEAN=${CLEAN:-0}
24
-if [ "$CLEAN" = "1" ]; then
25
-    rm -rf $STAGING_DIR
26
-fi
27
-
28
-# Download our base image.  This image is made using prepare_guest.sh
29
-BASE_IMAGE_URL=${BASE_IMAGE_URL:-http://images.ansolabs.com/xen/stage.tgz}
30
-if [ ! -e $STAGING_DIR ]; then
31
-    if [ ! -e /tmp/stage.tgz ]; then
32
-        wget $BASE_IMAGE_URL -O /tmp/stage.tgz
33
-    fi
34
-    tar xfz /tmp/stage.tgz
35
-    cd $TOP_DIR
36
-fi
19
+GUEST_NAME="$1"
37 20
 
38
-# Free up precious disk space
39
-rm -f /tmp/stage.tgz
21
+# Directory where we stage the build
22
+STAGING_DIR=$($TOP_DIR/scripts/manage-vdi open $GUEST_NAME 0 1 | grep -o "/tmp/tmp.[[:alnum:]]*")
23
+add_on_exit "$TOP_DIR/scripts/manage-vdi close $GUEST_NAME 0 1"
40 24
 
41 25
 # Make sure we have a stage
42 26
 if [ ! -d $STAGING_DIR/etc ]; then
... ...
@@ -55,63 +61,26 @@ SCRIPT_DIR=$TOP_DIR/scripts
55 55
 UBUNTU_VERSION=`cat $STAGING_DIR/etc/lsb-release | grep "DISTRIB_CODENAME=" | sed "s/DISTRIB_CODENAME=//"`
56 56
 KERNEL_VERSION=`ls $STAGING_DIR/boot/vmlinuz* | head -1 | sed "s/.*vmlinuz-//"`
57 57
 
58
-# Directory for xvas
59
-XVA_DIR=$TOP_DIR/xvas
60
-
61
-# Create xva dir
62
-mkdir -p $XVA_DIR
63
-
64
-# Path to xva
65
-XVA=$XVA_DIR/$GUEST_NAME.xva
66
-
67
-# Setup fake grub
68
-rm -rf $STAGING_DIR/boot/grub/
69
-mkdir -p $STAGING_DIR/boot/grub/
70
-cp $TEMPLATES_DIR/menu.lst.in $STAGING_DIR/boot/grub/menu.lst
71
-sed -e "s,@KERNEL_VERSION@,$KERNEL_VERSION,g" -i $STAGING_DIR/boot/grub/menu.lst
72
-
73
-# Setup fstab, tty, and other system stuff
74
-cp $FILES_DIR/fstab $STAGING_DIR/etc/fstab
75
-cp $FILES_DIR/hvc0.conf $STAGING_DIR/etc/init/
76
-
77
-# Put the VPX into UTC.
78
-rm -f $STAGING_DIR/etc/localtime
79
-
80 58
 # Configure dns (use same dns as dom0)
81 59
 cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
82 60
 
83 61
 # Copy over devstack
84 62
 rm -f /tmp/devstack.tar
85
-tar --exclude='stage' --exclude='xen/xvas' --exclude='xen/nova' -cvf /tmp/devstack.tar $TOP_DIR/../../../devstack
86
-cd $STAGING_DIR/opt/stack/
87
-tar xf /tmp/devstack.tar
63
+cd $TOP_DIR/../../
64
+tar --exclude='stage' --exclude='xen/xvas' --exclude='xen/nova' -cvf /tmp/devstack.tar .
65
+mkdir -p $STAGING_DIR/opt/stack/devstack
66
+tar xf /tmp/devstack.tar -C $STAGING_DIR/opt/stack/devstack
88 67
 cd $TOP_DIR
89 68
 
90
-# Configure OVA
91
-VDI_SIZE=$(($VDI_MB*1024*1024))
92
-PRODUCT_BRAND=${PRODUCT_BRAND:-openstack}
93
-PRODUCT_VERSION=${PRODUCT_VERSION:-001}
94
-BUILD_NUMBER=${BUILD_NUMBER:-001}
95
-LABEL="$PRODUCT_BRAND $PRODUCT_VERSION-$BUILD_NUMBER"
96
-OVA=$STAGING_DIR/tmp/ova.xml
97
-cp $TEMPLATES_DIR/ova.xml.in  $OVA
98
-sed -e "s,@VDI_SIZE@,$VDI_SIZE,g" -i $OVA
99
-sed -e "s,@PRODUCT_BRAND@,$PRODUCT_BRAND,g" -i $OVA
100
-sed -e "s,@PRODUCT_VERSION@,$PRODUCT_VERSION,g" -i $OVA
101
-sed -e "s,@BUILD_NUMBER@,$BUILD_NUMBER,g" -i $OVA
102
-
103 69
 # Run devstack on launch
104 70
 cat <<EOF >$STAGING_DIR/etc/rc.local
105 71
 # network restart required for getting the right gateway
106 72
 /etc/init.d/networking restart
107 73
 GUEST_PASSWORD=$GUEST_PASSWORD STAGING_DIR=/ DO_TGZ=0 bash /opt/stack/devstack/tools/xen/prepare_guest.sh > /opt/stack/prepare_guest.log 2>&1
108
-su -c "/opt/stack/run.sh > /opt/stack/run.sh.log" stack
74
+su -c "/opt/stack/run.sh > /opt/stack/run.sh.log 2>&1" stack
109 75
 exit 0
110 76
 EOF
111 77
 
112
-# Clean old xva. In the future may not do this every time.
113
-rm -f $XVA
114
-
115 78
 # Configure the hostname
116 79
 echo $GUEST_NAME > $STAGING_DIR/etc/hostname
117 80
 
... ...
@@ -151,10 +120,6 @@ else
151 151
     sed -e "s,@ETH3_NETMASK@,$PUB_NETMASK,g" -i $INTERFACES
152 152
 fi
153 153
 
154
-if [ -h $STAGING_DIR/sbin/dhclient3 ]; then
155
-    rm -f $STAGING_DIR/sbin/dhclient3
156
-fi
157
-
158 154
 # Gracefully cp only if source file/dir exists
159 155
 function cp_it {
160 156
     if [ -e $1 ] || [ -d $1 ]; then
... ...
@@ -181,11 +146,4 @@ UPLOAD_LEGACY_TTY=yes HOST_IP=$PUB_IP VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST
181 181
 EOF
182 182
 chmod 755 $STAGING_DIR/opt/stack/run.sh
183 183
 
184
-# Create xva
185
-if [ ! -e $XVA ]; then
186
-    rm -rf /tmp/mkxva*
187
-    UID=0 $SCRIPT_DIR/mkxva -o $XVA -t xva -x $OVA $STAGING_DIR $VDI_MB /tmp/
188
-fi
189
-
190
-echo "Built $(basename $XVA).  If your dom0 is on a different machine, copy this to [devstackdir]/tools/xen/$(basename $XVA)"
191
-echo "Also copy your localrc to [devstackdir]"
184
+echo "Done"
192 185
new file mode 100755
... ...
@@ -0,0 +1,274 @@
0
+#!/bin/bash
1
+
2
+# Exit on errors
3
+set -o errexit
4
+
5
+# Abort if localrc is not set
6
+if [ ! -e ../../localrc ]; then
7
+    echo "You must have a localrc with ALL necessary passwords defined before proceeding."
8
+    echo "See the xen README for required passwords."
9
+    exit 1
10
+fi
11
+
12
+# This directory
13
+TOP_DIR=$(cd $(dirname "$0") && pwd)
14
+
15
+# Source lower level functions
16
+. $TOP_DIR/../../functions
17
+
18
+# Source params - override xenrc params in your localrc to suit your taste
19
+source xenrc
20
+
21
+# Echo commands
22
+set -o xtrace
23
+
24
+xe_min()
25
+{
26
+  local cmd="$1"
27
+  shift
28
+  xe "$cmd" --minimal "$@"
29
+}
30
+
31
+cd $TOP_DIR
32
+if [ -f ./master ]
33
+then
34
+    rm -rf ./master
35
+    rm -rf ./nova
36
+fi
37
+wget https://github.com/openstack/nova/zipball/master --no-check-certificate
38
+unzip -o master -d ./nova
39
+cp -pr ./nova/*/plugins/xenserver/xenapi/etc/xapi.d /etc/
40
+chmod a+x /etc/xapi.d/plugins/*
41
+
42
+mkdir -p /boot/guest
43
+
44
+GUEST_NAME=${GUEST_NAME:-"DevStackOSDomU"}
45
+SNAME="ubuntusnapshot"
46
+TNAME="ubuntuready"
47
+
48
+# Helper to create networks
49
+# Uses echo trickery to return network uuid
50
+function create_network() {
51
+    br=$1
52
+    dev=$2
53
+    vlan=$3
54
+    netname=$4
55
+    if [ -z $br ]
56
+    then
57
+        pif=$(xe_min pif-list device=$dev VLAN=$vlan)
58
+        if [ -z $pif ]
59
+        then
60
+            net=$(xe network-create name-label=$netname)
61
+        else
62
+            net=$(xe_min network-list  PIF-uuids=$pif)
63
+        fi
64
+        echo $net
65
+        return 0
66
+    fi
67
+    if [ ! $(xe_min network-list  params=bridge | grep -w --only-matching $br) ]
68
+    then
69
+        echo "Specified bridge $br does not exist"
70
+        echo "If you wish to use defaults, please keep the bridge name empty"
71
+        exit 1
72
+    else
73
+        net=$(xe_min network-list  bridge=$br)
74
+        echo $net
75
+    fi
76
+}
77
+
78
+function errorcheck() {
79
+    rc=$?
80
+    if [ $rc -ne 0 ]
81
+    then
82
+        exit $rc
83
+    fi
84
+}
85
+
86
+# Create host, vm, mgmt, pub networks
87
+VM_NET=$(create_network "$VM_BR" "$VM_DEV" "$VM_VLAN" "vmbr")
88
+errorcheck
89
+MGT_NET=$(create_network "$MGT_BR" "$MGT_DEV" "$MGT_VLAN" "mgtbr")
90
+errorcheck
91
+PUB_NET=$(create_network "$PUB_BR" "$PUB_DEV" "$PUB_VLAN" "pubbr")
92
+errorcheck
93
+
94
+# Helper to create vlans
95
+function create_vlan() {
96
+    dev=$1
97
+    vlan=$2
98
+    net=$3
99
+    # VLAN -1 refers to no VLAN (physical network)
100
+    if [ $vlan -eq -1 ]
101
+    then
102
+        return
103
+    fi
104
+    if [ -z $(xe_min vlan-list  tag=$vlan) ]
105
+    then
106
+        pif=$(xe_min pif-list  network-uuid=$net)
107
+        # We created a brand new network this time
108
+        if [ -z $pif ]
109
+        then
110
+            pif=$(xe_min pif-list  device=$dev VLAN=-1)
111
+            xe vlan-create pif-uuid=$pif vlan=$vlan network-uuid=$net
112
+        else
113
+            echo "VLAN does not exist but PIF attached to this network"
114
+            echo "How did we reach here?"
115
+            exit 1
116
+        fi
117
+    fi
118
+}
119
+
120
+# Create vlans for vm and management
121
+create_vlan $PUB_DEV $PUB_VLAN $PUB_NET
122
+create_vlan $VM_DEV $VM_VLAN $VM_NET
123
+create_vlan $MGT_DEV $MGT_VLAN $MGT_NET
124
+
125
+# dom0 ip
126
+HOST_IP=${HOST_IP:-`ifconfig xenbr0 | grep "inet addr" | cut -d ":" -f2 | sed "s/ .*//"`}
127
+
128
+# Set up ip forwarding
129
+if ! grep -q "FORWARD_IPV4=YES" /etc/sysconfig/network; then
130
+    # FIXME: This doesn't work on reboot!
131
+    echo "FORWARD_IPV4=YES" >> /etc/sysconfig/network
132
+fi
133
+
134
+# Also, enable ip forwarding in rc.local, since the above trick isn't working
135
+if ! grep -q  "echo 1 >/proc/sys/net/ipv4/ip_forward" /etc/rc.local; then
136
+    echo "echo 1 >/proc/sys/net/ipv4/ip_forward" >> /etc/rc.local
137
+fi
138
+
139
+# Enable ip forwarding at runtime as well
140
+echo 1 > /proc/sys/net/ipv4/ip_forward
141
+
142
+# Shutdown previous runs
143
+DO_SHUTDOWN=${DO_SHUTDOWN:-1}
144
+if [ "$DO_SHUTDOWN" = "1" ]; then
145
+    # Shutdown all domU's that created previously
146
+    xe_min vm-list  name-label="$GUEST_NAME" | xargs ./scripts/uninstall-os-vpx.sh
147
+
148
+    # Destroy any instances that were launched
149
+    for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do
150
+        echo "Shutting down nova instance $uuid"
151
+        xe vm-unpause uuid=$uuid || true
152
+        xe vm-shutdown uuid=$uuid
153
+        xe vm-destroy uuid=$uuid
154
+    done
155
+
156
+    # Destroy orphaned vdis
157
+    for uuid in `xe vdi-list | grep -1 Glance | grep uuid | sed "s/.*\: //g"`; do
158
+        xe vdi-destroy uuid=$uuid
159
+    done
160
+fi
161
+
162
+# Start guest
163
+if [ -z $VM_BR ]; then
164
+    VM_BR=$(xe_min network-list  uuid=$VM_NET params=bridge)
165
+fi
166
+if [ -z $MGT_BR ]; then
167
+    MGT_BR=$(xe_min network-list  uuid=$MGT_NET params=bridge)
168
+fi
169
+if [ -z $PUB_BR ]; then
170
+    PUB_BR=$(xe_min network-list  uuid=$PUB_NET params=bridge)
171
+fi
172
+
173
+templateuuid=$(xe template-list name-label="$TNAME")
174
+if [ -n "$templateuuid" ]
175
+then
176
+        vm_uuid=$(xe vm-install template="$TNAME" new-name-label="$GUEST_NAME")
177
+else
178
+    template=$(xe_min template-list name-label="Ubuntu 11.10 (64-bit)")
179
+    if [ -z "$template" ]
180
+    then
181
+        $TOP_DIR/scripts/xenoneirictemplate.sh
182
+    fi
183
+    $TOP_DIR/scripts/install-os-vpx.sh -t "Ubuntu 11.10 (64-bit)" -v $VM_BR -m $MGT_BR -p $PUB_BR -l $GUEST_NAME -r $OSDOMU_MEM_MB -k "flat_network_bridge=${VM_BR}"
184
+
185
+    # Wait for install to finish
186
+    while true
187
+    do
188
+        state=$(xe_min vm-list name-label="$GUEST_NAME" power-state=halted)
189
+        if [ -n "$state" ]
190
+        then
191
+            break
192
+        else
193
+            echo "Waiting for "$GUEST_NAME" to finish installation..."
194
+            sleep 30
195
+        fi
196
+    done
197
+
198
+    vm_uuid=$(xe_min vm-list name-label="$GUEST_NAME")
199
+    xe vm-param-set actions-after-reboot=Restart uuid="$vm_uuid"
200
+
201
+    # Make template from VM
202
+    snuuid=$(xe vm-snapshot vm="$GUEST_NAME" new-name-label="$SNAME")
203
+    template_uuid=$(xe snapshot-clone uuid=$snuuid new-name-label="$TNAME")
204
+fi
205
+
206
+$TOP_DIR/build_xva.sh "$GUEST_NAME"
207
+
208
+xe vm-start vm="$GUEST_NAME"
209
+
210
+if [ $PUB_IP == "dhcp" ]; then
211
+    PUB_IP=$(xe_min vm-list  name-label=$GUEST_NAME params=networks |  sed -ne 's,^.*3/ip: \([0-9.]*\).*$,\1,p')
212
+fi
213
+
214
+# If we have copied our ssh credentials, use ssh to monitor while the installation runs
215
+WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1}
216
+if [ "$WAIT_TILL_LAUNCH" = "1" ]  && [ -e ~/.ssh/id_rsa.pub  ] && [ "$COPYENV" = "1" ]; then
217
+    # Done creating the container, let's tail the log
218
+    echo
219
+    echo "============================================================="
220
+    echo "                          -- YAY! --"
221
+    echo "============================================================="
222
+    echo
223
+    echo "We're done launching the vm, about to start tailing the"
224
+    echo "stack.sh log. It will take a second or two to start."
225
+    echo
226
+    echo "Just CTRL-C at any time to stop tailing."
227
+
228
+    set +o xtrace
229
+
230
+    while ! ssh -q stack@$PUB_IP "[ -e run.sh.log ]"; do
231
+      sleep 1
232
+    done
233
+
234
+    ssh stack@$PUB_IP 'tail -f run.sh.log' &
235
+
236
+    TAIL_PID=$!
237
+
238
+    function kill_tail() {
239
+        kill $TAIL_PID
240
+        exit 1
241
+    }
242
+
243
+    # Let Ctrl-c kill tail and exit
244
+    trap kill_tail SIGINT
245
+
246
+    echo "Waiting stack.sh to finish..."
247
+    while ! ssh -q stack@$PUB_IP "grep -q 'stack.sh completed in' run.sh.log"; do
248
+        sleep 1
249
+    done
250
+
251
+    kill $TAIL_PID
252
+
253
+    if ssh -q stack@$PUB_IP "grep -q 'stack.sh failed' run.sh.log"; then
254
+        exit 1
255
+    fi
256
+    echo ""
257
+    echo "Finished - Zip-a-dee Doo-dah!"
258
+    echo "You can then visit the OpenStack Dashboard"
259
+    echo "at http://$PUB_IP, and contact other services at the usual ports."
260
+else
261
+    echo "################################################################################"
262
+    echo ""
263
+    echo "All Finished!"
264
+    echo "Now, you can monitor the progress of the stack.sh installation by "
265
+    echo "tailing /opt/stack/run.sh.log from within your domU."
266
+    echo ""
267
+    echo "ssh into your domU now: 'ssh stack@$PUB_IP' using your password"
268
+    echo "and then do: 'tail -f /opt/stack/run.sh.log'"
269
+    echo ""
270
+    echo "When the script completes, you can then visit the OpenStack Dashboard"
271
+    echo "at http://$PUB_IP, and contact other services at the usual ports."
272
+
273
+fi
0 274
old mode 100644
1 275
new mode 100755
... ...
@@ -6,13 +6,6 @@ set -x
6 6
 GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
7 7
 STAGING_DIR=${STAGING_DIR:-stage}
8 8
 DO_TGZ=${DO_TGZ:-1}
9
-KERNEL_VERSION=3.0.0-12-virtual
10
-
11
-# Debootstrap base system
12
-if [ ! -d $STAGING_DIR ]; then
13
-    apt-get install debootstrap
14
-    debootstrap --arch amd64 oneiric $STAGING_DIR http://us.archive.ubuntu.com/ubuntu/
15
-fi
16 9
 
17 10
 # Sources.list
18 11
 cat <<EOF >$STAGING_DIR/etc/apt/sources.list
... ...
@@ -28,7 +21,6 @@ EOF
28 28
 
29 29
 # Install basics
30 30
 chroot $STAGING_DIR apt-get update
31
-chroot $STAGING_DIR apt-get install -y linux-image-$KERNEL_VERSION
32 31
 chroot $STAGING_DIR apt-get install -y cracklib-runtime curl wget ssh openssh-server tcpdump ethtool
33 32
 chroot $STAGING_DIR apt-get install -y curl wget ssh openssh-server python-pip git vim-nox sudo
34 33
 chroot $STAGING_DIR pip install xenapi
... ...
@@ -332,17 +332,11 @@ set_kernel_params()
332 332
 {
333 333
   local v="$1"
334 334
   local args=$KERNEL_PARAMS
335
-  local cmdline=$(cat /proc/cmdline)
336
-  for word in $cmdline
337
-  do
338
-    if echo "$word" | grep -q "geppetto"
339
-    then
340
-      args="$word $args"
341
-    fi
342
-  done
343 335
   if [ "$args" != "" ]
344 336
   then
345 337
     echo "Passing Geppetto args to VPX: $args."
338
+    pvargs=$(xe vm-param-get param-name=PV-args uuid="$v")
339
+    args="$pvargs $args"
346 340
     xe vm-param-set PV-args="$args" uuid="$v"
347 341
   fi
348 342
 }
... ...
@@ -429,13 +423,17 @@ then
429 429
 elif [ "$TEMPLATE_NAME" ]
430 430
 then
431 431
   echo $TEMPLATE_NAME
432
-  vm_uuid=$(xe_min vm-install template="$TEMPLATE_NAME" new-name-label="DevstackOSDomu")
432
+  vm_uuid=$(xe_min vm-install template="$TEMPLATE_NAME" new-name-label="$NAME_LABEL")
433 433
   destroy_vifs "$vm_uuid"
434 434
   set_auto_start "$vm_uuid"
435 435
   create_gi_vif "$vm_uuid"
436 436
   create_vm_vif "$vm_uuid"
437 437
   create_management_vif "$vm_uuid"
438 438
   create_public_vif "$vm_uuid"
439
+  set_kernel_params "$vm_uuid"
440
+  xe vm-param-set other-config:os-vpx=true uuid="$vm_uuid"
441
+  xe vm-param-set actions-after-reboot=Destroy uuid="$vm_uuid"
442
+  set_memory "$vm_uuid"
439 443
 else
440 444
   if [ ! -f "$VPX_FILE" ]
441 445
   then
... ...
@@ -1,10 +1,10 @@
1 1
 #!/bin/bash
2 2
 
3 3
 # Name of this guest
4
-GUEST_NAME=${GUEST_NAME:-ALLINONE}
4
+GUEST_NAME=${GUEST_NAME:-DevStackOSDomU}
5 5
 
6 6
 # Size of image
7
-VDI_MB=${VDI_MB:-2500}
7
+VDI_MB=${VDI_MB:-5000}
8 8
 
9 9
 # VM Password
10 10
 GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
... ...
@@ -35,11 +35,7 @@ MGT_BR=${MGT_BR:-""}
35 35
 MGT_VLAN=${MGT_VLAN:-101}
36 36
 MGT_DEV=${MGT_DEV:-eth0}
37 37
 
38
-# XVA Directory
39
-XVA_DIR=${XVA_DIR:-`pwd`/xvas}
40
-
41
-# Path to xva file
42
-XVA=${XVA:-$XVA_DIR/$GUEST_NAME.xva }
38
+OSDOMU_MEM_MB=1024
43 39
 
44 40
 # Source params
45 41
 cd ../.. && source ./stackrc && cd $TOP_DIR