Browse code

Separate out build_xva process so that it can be run on a machine besides dom0

Change-Id: I3a6e1ef874c83d79d09a8df1f086ec06d39db2df

Anthony Young authored on 2012/01/13 10:11:56
Showing 4 changed files
... ...
@@ -54,7 +54,16 @@ Of course, use real passwords if this machine is exposed.
54 54
     ACTIVE_TIMEOUT=45
55 55
     EOF
56 56
 
57
-Step 4: Run ./build_domU.sh
57
+Step 4: Run ./build_xva.sh
58
+--------------------------
59
+This script prpares your nova xva image.  This script can be run on a separate machine
60
+and copied to dom0.  If you run this on a different machine, copy the resulting xva
61
+file to tools/xen/xvas/[GUEST_NAME].xva (by default tools/xen/xvas/ALLINONE.xva)
62
+
63
+It is likely that for XS6 you will need to build_xva.sh on a separate machine due
64
+to dom0 space constraints.
65
+
66
+Step 5: Run ./build_domU.sh
58 67
 --------------------------
59 68
 This script does a lot of stuff, it is probably best to read it in its entirety.
60 69
 But in a nutshell, it performs the following:
... ...
@@ -63,7 +72,7 @@ But in a nutshell, it performs the following:
63 63
 * Creates and installs a OpenStack all-in-one domU in an HA-FlatDHCP configuration
64 64
 * A script to create a multi-domU (ie. head node separated from compute) configuration is coming soon!
65 65
 
66
-Step 5: Do cloudy stuff!
66
+Step 6: Do cloudy stuff!
67 67
 --------------------------
68 68
 * Play with horizon
69 69
 * Play with the CLI
... ...
@@ -10,42 +10,18 @@ fi
10 10
 # This directory
11 11
 TOP_DIR=$(cd $(dirname "$0") && pwd)
12 12
 
13
-# Source params
14
-cd ../.. && source ./stackrc && cd $TOP_DIR
13
+# Source params - override xenrc params in your localrc to suite your taste
14
+source xenrc
15 15
 
16 16
 # Echo commands
17 17
 set -o xtrace
18 18
 
19
-# Name of this guest
20
-GUEST_NAME=${GUEST_NAME:-ALLINONE}
21
-
22
-# dom0 ip
23
-HOST_IP=${HOST_IP:-`ifconfig xenbr0 | grep "inet addr" | cut -d ":" -f2 | sed "s/ .*//"`}
24
-
25
-# Our nova host's network info 
26
-VM_IP=${VM_IP:-10.255.255.255} # A host-only ip that let's the interface come up, otherwise unused
27
-MGT_IP=${MGT_IP:-172.16.100.55}
28
-PUB_IP=${PUB_IP:-192.168.1.55}
29
-
30
-# Public network
31
-PUB_BR=${PUB_BR:-xenbr0}
32
-PUB_NETMASK=${PUB_NETMASK:-255.255.255.0}
33
-
34
-# VM network params
35
-VM_NETMASK=${VM_NETMASK:-255.255.255.0}
36
-VM_BR=${VM_BR:-xapi1}
37
-VM_VLAN=${VM_VLAN:-100}
38
-
39
-# MGMT network params
40
-MGT_NETMASK=${MGT_NETMASK:-255.255.255.0}
41
-MGT_BR=${MGT_BR:-xapi2}
42
-MGT_VLAN=${MGT_VLAN:-101}
43
-
44
-# VM Password
45
-GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
46
-
47
-# Size of image
48
-VDI_MB=${VDI_MB:-2500}
19
+# Check for xva file
20
+if [ ! -e $XVA ]; then
21
+    echo "Missing xva file.  Please run build_xva.sh (ideally on a non dom0 host since the build can require lots of space)."
22
+    echo "Place the resulting xva file in $XVA"
23
+    exit 1
24
+fi
49 25
 
50 26
 # Make sure we have git
51 27
 if ! which git; then
... ...
@@ -95,6 +71,9 @@ function create_vlan() {
95 95
 create_vlan $PIF $VM_VLAN $VM_NET
96 96
 create_vlan $PIF $MGT_VLAN $MGT_NET
97 97
 
98
+# dom0 ip
99
+HOST_IP=${HOST_IP:-`ifconfig xenbr0 | grep "inet addr" | cut -d ":" -f2 | sed "s/ .*//"`}
100
+
98 101
 # Setup host-only nat rules
99 102
 HOST_NET=169.254.0.0/16
100 103
 if ! iptables -L -v -t nat | grep -q $HOST_NET; then
... ...
@@ -117,86 +96,9 @@ fi
117 117
 # Enable ip forwarding at runtime as well
118 118
 echo 1 > /proc/sys/net/ipv4/ip_forward
119 119
 
120
-# Directory where we stage the build
121
-STAGING_DIR=$TOP_DIR/stage
122
-
123
-# Option to clean out old stuff
124
-CLEAN=${CLEAN:-0}
125
-if [ "$CLEAN" = "1" ]; then
126
-    rm -rf $STAGING_DIR
127
-fi
128
-
129
-# Download our base image.  This image is made using prepare_guest.sh
130
-BASE_IMAGE_URL=${BASE_IMAGE_URL:-http://images.ansolabs.com/xen/stage.tgz}
131
-if [ ! -e $STAGING_DIR ]; then
132
-    if [ ! -e /tmp/stage.tgz ]; then
133
-        wget $BASE_IMAGE_URL -O /tmp/stage.tgz
134
-    fi
135
-    tar xfz /tmp/stage.tgz
136
-    cd $TOP_DIR
137
-fi
138
-
139
-# Free up precious disk space
140
-rm -f /tmp/stage.tgz
141
-
142
-# Make sure we have a stage
143
-if [ ! -d $STAGING_DIR/etc ]; then
144
-    echo "Stage is not properly set up!"
145
-    exit 1
146
-fi
147
-
148
-# Directory where our conf files are stored
149
-FILES_DIR=$TOP_DIR/files
150
-TEMPLATES_DIR=$TOP_DIR/templates
151
-
152
-# Directory for supporting script files
153
-SCRIPT_DIR=$TOP_DIR/scripts
154
-
155
-# Version of ubuntu with which we are working
156
-UBUNTU_VERSION=`cat $STAGING_DIR/etc/lsb-release | grep "DISTRIB_CODENAME=" | sed "s/DISTRIB_CODENAME=//"`
157
-KERNEL_VERSION=`ls $STAGING_DIR/boot/vmlinuz* | head -1 | sed "s/.*vmlinuz-//"`
158
-
159
-# Setup fake grub
160
-rm -rf $STAGING_DIR/boot/grub/
161
-mkdir -p $STAGING_DIR/boot/grub/
162
-cp $TEMPLATES_DIR/menu.lst.in $STAGING_DIR/boot/grub/menu.lst
163
-sed -e "s,@KERNEL_VERSION@,$KERNEL_VERSION,g" -i $STAGING_DIR/boot/grub/menu.lst
164
-
165
-# Setup fstab, tty, and other system stuff
166
-cp $FILES_DIR/fstab $STAGING_DIR/etc/fstab
167
-cp $FILES_DIR/hvc0.conf $STAGING_DIR/etc/init/
168
-
169
-# Put the VPX into UTC.
170
-rm -f $STAGING_DIR/etc/localtime
171
-
172
-# Configure dns (use same dns as dom0)
173
-cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
174
-
175
-# Copy over devstack
176
-rm -f /tmp/devstack.tar
177
-tar --exclude='stage' --exclude='xen/xvas' --exclude='xen/nova' -cvf /tmp/devstack.tar $TOP_DIR/../../../devstack
178
-cd $STAGING_DIR/opt/stack/
179
-tar xf /tmp/devstack.tar
180
-cd $TOP_DIR
181
-
182
-# Configure OVA
183
-VDI_SIZE=$(($VDI_MB*1024*1024))
184
-PRODUCT_BRAND=${PRODUCT_BRAND:-openstack}
185
-PRODUCT_VERSION=${PRODUCT_VERSION:-001}
186
-BUILD_NUMBER=${BUILD_NUMBER:-001}
187
-LABEL="$PRODUCT_BRAND $PRODUCT_VERSION-$BUILD_NUMBER"
188
-OVA=$STAGING_DIR/tmp/ova.xml
189
-cp $TEMPLATES_DIR/ova.xml.in  $OVA
190
-sed -e "s,@VDI_SIZE@,$VDI_SIZE,g" -i $OVA
191
-sed -e "s,@PRODUCT_BRAND@,$PRODUCT_BRAND,g" -i $OVA
192
-sed -e "s,@PRODUCT_VERSION@,$PRODUCT_VERSION,g" -i $OVA
193
-sed -e "s,@BUILD_NUMBER@,$BUILD_NUMBER,g" -i $OVA
194
-
195
-# Directory for xvas
196
-XVA_DIR=$TOP_DIR/xvas
197
-
198
-# Create xva dir
199
-mkdir -p $XVA_DIR
120
+# Set local storage il8n
121
+SR_UUID=`xe sr-list --minimal name-label="Local storage"`
122
+xe sr-param-set uuid=$SR_UUID other-config:i18n-key=local-storage
200 123
 
201 124
 # Clean nova if desired
202 125
 if [ "$CLEAN" = "1" ]; then
... ...
@@ -210,24 +112,12 @@ if [ ! -d $TOP_DIR/nova ]; then
210 210
     git checkout $NOVA_BRANCH
211 211
 fi 
212 212
 
213
-# Run devstack on launch
214
-cat <<EOF >$STAGING_DIR/etc/rc.local
215
-GUEST_PASSWORD=$GUEST_PASSWORD STAGING_DIR=/ DO_TGZ=0 bash /opt/stack/devstack/tools/xen/prepare_guest.sh
216
-su -c "/opt/stack/run.sh > /opt/stack/run.sh.log" stack
217
-exit 0
218
-EOF
219
-
220 213
 # Install plugins
221 214
 cp -pr $TOP_DIR/nova/plugins/xenserver/xenapi/etc/xapi.d /etc/
222 215
 chmod a+x /etc/xapi.d/plugins/*
223 216
 yum --enablerepo=base install -y parted
224 217
 mkdir -p /boot/guest
225 218
 
226
-# Set local storage il8n
227
-SR_UUID=`xe sr-list --minimal name-label="Local storage"`
228
-xe sr-param-set uuid=$SR_UUID other-config:i18n-key=local-storage
229
-
230
-
231 219
 # Shutdown previous runs
232 220
 DO_SHUTDOWN=${DO_SHUTDOWN:-1}
233 221
 if [ "$DO_SHUTDOWN" = "1" ]; then
... ...
@@ -248,68 +138,6 @@ if [ "$DO_SHUTDOWN" = "1" ]; then
248 248
     done
249 249
 fi
250 250
 
251
-# Path to head xva.  By default keep overwriting the same one to save space
252
-USE_SEPARATE_XVAS=${USE_SEPARATE_XVAS:-0}
253
-if [ "$USE_SEPARATE_XVAS" = "0" ]; then
254
-    XVA=$XVA_DIR/$UBUNTU_VERSION.xva 
255
-else
256
-    XVA=$XVA_DIR/$UBUNTU_VERSION.$GUEST_NAME.xva 
257
-fi
258
-
259
-# Clean old xva. In the future may not do this every time.
260
-rm -f $XVA
261
-
262
-# Configure the hostname
263
-echo $GUEST_NAME > $STAGING_DIR/etc/hostname
264
-
265
-# Hostname must resolve for rabbit
266
-cat <<EOF >$STAGING_DIR/etc/hosts
267
-$MGT_IP $GUEST_NAME
268
-127.0.0.1 localhost localhost.localdomain
269
-EOF
270
-
271
-# Configure the network
272
-INTERFACES=$STAGING_DIR/etc/network/interfaces
273
-cp $TEMPLATES_DIR/interfaces.in  $INTERFACES
274
-sed -e "s,@ETH1_IP@,$VM_IP,g" -i $INTERFACES
275
-sed -e "s,@ETH1_NETMASK@,$VM_NETMASK,g" -i $INTERFACES
276
-sed -e "s,@ETH2_IP@,$MGT_IP,g" -i $INTERFACES
277
-sed -e "s,@ETH2_NETMASK@,$MGT_NETMASK,g" -i $INTERFACES
278
-sed -e "s,@ETH3_IP@,$PUB_IP,g" -i $INTERFACES
279
-sed -e "s,@ETH3_NETMASK@,$PUB_NETMASK,g" -i $INTERFACES
280
-
281
-# Gracefully cp only if source file/dir exists
282
-function cp_it {
283
-    if [ -e $1 ] || [ -d $1 ]; then
284
-        cp -pRL $1 $2
285
-    fi
286
-}
287
-
288
-# Copy over your ssh keys and env if desired
289
-COPYENV=${COPYENV:-1}
290
-if [ "$COPYENV" = "1" ]; then
291
-    cp_it ~/.ssh $STAGING_DIR/opt/stack/.ssh
292
-    cp_it ~/.ssh/id_rsa.pub $STAGING_DIR/opt/stack/.ssh/authorized_keys
293
-    cp_it ~/.gitconfig $STAGING_DIR/opt/stack/.gitconfig
294
-    cp_it ~/.vimrc $STAGING_DIR/opt/stack/.vimrc
295
-    cp_it ~/.bashrc $STAGING_DIR/opt/stack/.bashrc
296
-fi
297
-
298
-# Configure run.sh
299
-cat <<EOF >$STAGING_DIR/opt/stack/run.sh
300
-#!/bin/bash
301
-cd /opt/stack/devstack
302
-killall screen
303
-UPLOAD_LEGACY_TTY=yes HOST_IP=$PUB_IP VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST=1 $STACKSH_PARAMS ./stack.sh
304
-EOF
305
-chmod 755 $STAGING_DIR/opt/stack/run.sh
306
-
307
-# Create xva
308
-if [ ! -e $XVA ]; then
309
-    rm -rf /tmp/mkxva*
310
-    UID=0 $SCRIPT_DIR/mkxva -o $XVA -t xva -x $OVA $STAGING_DIR $VDI_MB /tmp/
311
-fi
312
-
313 251
 # Start guest
314 252
 $TOP_DIR/scripts/install-os-vpx.sh -f $XVA -v $VM_BR -m $MGT_BR -p $PUB_BR
315 253
 
316 254
new file mode 100755
... ...
@@ -0,0 +1,164 @@
0
+#!/bin/bash
1
+
2
+# Abort if localrc is not set
3
+if [ ! -e ../../localrc ]; then
4
+    echo "You must have a localrc with ALL necessary passwords defined before proceeding."
5
+    echo "See the xen README for required passwords."
6
+    exit 1
7
+fi
8
+
9
+# This directory
10
+TOP_DIR=$(cd $(dirname "$0") && pwd)
11
+
12
+# Source params - override xenrc params in your localrc to suite your taste
13
+source xenrc
14
+
15
+# Echo commands
16
+set -o xtrace
17
+
18
+# Directory where we stage the build
19
+STAGING_DIR=$TOP_DIR/stage
20
+
21
+# Option to clean out old stuff
22
+CLEAN=${CLEAN:-0}
23
+if [ "$CLEAN" = "1" ]; then
24
+    rm -rf $STAGING_DIR
25
+fi
26
+
27
+# Download our base image.  This image is made using prepare_guest.sh
28
+BASE_IMAGE_URL=${BASE_IMAGE_URL:-http://images.ansolabs.com/xen/stage.tgz}
29
+if [ ! -e $STAGING_DIR ]; then
30
+    if [ ! -e /tmp/stage.tgz ]; then
31
+        wget $BASE_IMAGE_URL -O /tmp/stage.tgz
32
+    fi
33
+    tar xfz /tmp/stage.tgz
34
+    cd $TOP_DIR
35
+fi
36
+
37
+# Free up precious disk space
38
+rm -f /tmp/stage.tgz
39
+
40
+# Make sure we have a stage
41
+if [ ! -d $STAGING_DIR/etc ]; then
42
+    echo "Stage is not properly set up!"
43
+    exit 1
44
+fi
45
+
46
+# Directory where our conf files are stored
47
+FILES_DIR=$TOP_DIR/files
48
+TEMPLATES_DIR=$TOP_DIR/templates
49
+
50
+# Directory for supporting script files
51
+SCRIPT_DIR=$TOP_DIR/scripts
52
+
53
+# Version of ubuntu with which we are working
54
+UBUNTU_VERSION=`cat $STAGING_DIR/etc/lsb-release | grep "DISTRIB_CODENAME=" | sed "s/DISTRIB_CODENAME=//"`
55
+KERNEL_VERSION=`ls $STAGING_DIR/boot/vmlinuz* | head -1 | sed "s/.*vmlinuz-//"`
56
+
57
+# Directory for xvas
58
+XVA_DIR=$TOP_DIR/xvas
59
+
60
+# Create xva dir
61
+mkdir -p $XVA_DIR
62
+
63
+# Path to xva
64
+XVA=$XVA_DIR/$GUEST_NAME.xva 
65
+
66
+# Setup fake grub
67
+rm -rf $STAGING_DIR/boot/grub/
68
+mkdir -p $STAGING_DIR/boot/grub/
69
+cp $TEMPLATES_DIR/menu.lst.in $STAGING_DIR/boot/grub/menu.lst
70
+sed -e "s,@KERNEL_VERSION@,$KERNEL_VERSION,g" -i $STAGING_DIR/boot/grub/menu.lst
71
+
72
+# Setup fstab, tty, and other system stuff
73
+cp $FILES_DIR/fstab $STAGING_DIR/etc/fstab
74
+cp $FILES_DIR/hvc0.conf $STAGING_DIR/etc/init/
75
+
76
+# Put the VPX into UTC.
77
+rm -f $STAGING_DIR/etc/localtime
78
+
79
+# Configure dns (use same dns as dom0)
80
+cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
81
+
82
+# Copy over devstack
83
+rm -f /tmp/devstack.tar
84
+tar --exclude='stage' --exclude='xen/xvas' --exclude='xen/nova' -cvf /tmp/devstack.tar $TOP_DIR/../../../devstack
85
+cd $STAGING_DIR/opt/stack/
86
+tar xf /tmp/devstack.tar
87
+cd $TOP_DIR
88
+
89
+# Configure OVA
90
+VDI_SIZE=$(($VDI_MB*1024*1024))
91
+PRODUCT_BRAND=${PRODUCT_BRAND:-openstack}
92
+PRODUCT_VERSION=${PRODUCT_VERSION:-001}
93
+BUILD_NUMBER=${BUILD_NUMBER:-001}
94
+LABEL="$PRODUCT_BRAND $PRODUCT_VERSION-$BUILD_NUMBER"
95
+OVA=$STAGING_DIR/tmp/ova.xml
96
+cp $TEMPLATES_DIR/ova.xml.in  $OVA
97
+sed -e "s,@VDI_SIZE@,$VDI_SIZE,g" -i $OVA
98
+sed -e "s,@PRODUCT_BRAND@,$PRODUCT_BRAND,g" -i $OVA
99
+sed -e "s,@PRODUCT_VERSION@,$PRODUCT_VERSION,g" -i $OVA
100
+sed -e "s,@BUILD_NUMBER@,$BUILD_NUMBER,g" -i $OVA
101
+
102
+# Run devstack on launch
103
+cat <<EOF >$STAGING_DIR/etc/rc.local
104
+GUEST_PASSWORD=$GUEST_PASSWORD STAGING_DIR=/ DO_TGZ=0 bash /opt/stack/devstack/tools/xen/prepare_guest.sh
105
+su -c "/opt/stack/run.sh > /opt/stack/run.sh.log" stack
106
+exit 0
107
+EOF
108
+
109
+# Clean old xva. In the future may not do this every time.
110
+rm -f $XVA
111
+
112
+# Configure the hostname
113
+echo $GUEST_NAME > $STAGING_DIR/etc/hostname
114
+
115
+# Hostname must resolve for rabbit
116
+cat <<EOF >$STAGING_DIR/etc/hosts
117
+$MGT_IP $GUEST_NAME
118
+127.0.0.1 localhost localhost.localdomain
119
+EOF
120
+
121
+# Configure the network
122
+INTERFACES=$STAGING_DIR/etc/network/interfaces
123
+cp $TEMPLATES_DIR/interfaces.in  $INTERFACES
124
+sed -e "s,@ETH1_IP@,$VM_IP,g" -i $INTERFACES
125
+sed -e "s,@ETH1_NETMASK@,$VM_NETMASK,g" -i $INTERFACES
126
+sed -e "s,@ETH2_IP@,$MGT_IP,g" -i $INTERFACES
127
+sed -e "s,@ETH2_NETMASK@,$MGT_NETMASK,g" -i $INTERFACES
128
+sed -e "s,@ETH3_IP@,$PUB_IP,g" -i $INTERFACES
129
+sed -e "s,@ETH3_NETMASK@,$PUB_NETMASK,g" -i $INTERFACES
130
+
131
+# Gracefully cp only if source file/dir exists
132
+function cp_it {
133
+    if [ -e $1 ] || [ -d $1 ]; then
134
+        cp -pRL $1 $2
135
+    fi
136
+}
137
+
138
+# Copy over your ssh keys and env if desired
139
+COPYENV=${COPYENV:-1}
140
+if [ "$COPYENV" = "1" ]; then
141
+    cp_it ~/.ssh $STAGING_DIR/opt/stack/.ssh
142
+    cp_it ~/.ssh/id_rsa.pub $STAGING_DIR/opt/stack/.ssh/authorized_keys
143
+    cp_it ~/.gitconfig $STAGING_DIR/opt/stack/.gitconfig
144
+    cp_it ~/.vimrc $STAGING_DIR/opt/stack/.vimrc
145
+    cp_it ~/.bashrc $STAGING_DIR/opt/stack/.bashrc
146
+fi
147
+
148
+# Configure run.sh
149
+cat <<EOF >$STAGING_DIR/opt/stack/run.sh
150
+#!/bin/bash
151
+cd /opt/stack/devstack
152
+killall screen
153
+UPLOAD_LEGACY_TTY=yes HOST_IP=$PUB_IP VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST=1 $STACKSH_PARAMS ./stack.sh
154
+EOF
155
+chmod 755 $STAGING_DIR/opt/stack/run.sh
156
+
157
+# Create xva
158
+if [ ! -e $XVA ]; then
159
+    rm -rf /tmp/mkxva*
160
+    UID=0 $SCRIPT_DIR/mkxva -o $XVA -t xva -x $OVA $STAGING_DIR $VDI_MB /tmp/
161
+fi
162
+
163
+echo "Built $XVA.  If your dom0 is on a different machine, copy this to [devstackdir]/tools/xen/$XVA"
0 164
new file mode 100644
... ...
@@ -0,0 +1,38 @@
0
+#!/bin/bash
1
+
2
+# Name of this guest
3
+GUEST_NAME=${GUEST_NAME:-ALLINONE}
4
+
5
+# Size of image
6
+VDI_MB=${VDI_MB:-2500}
7
+
8
+# VM Password
9
+GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
10
+
11
+# Our nova host's network info 
12
+VM_IP=${VM_IP:-10.255.255.255} # A host-only ip that let's the interface come up, otherwise unused
13
+MGT_IP=${MGT_IP:-172.16.100.55}
14
+PUB_IP=${PUB_IP:-192.168.1.55}
15
+
16
+# Public network
17
+PUB_BR=${PUB_BR:-xenbr0}
18
+PUB_NETMASK=${PUB_NETMASK:-255.255.255.0}
19
+
20
+# VM network params
21
+VM_NETMASK=${VM_NETMASK:-255.255.255.0}
22
+VM_BR=${VM_BR:-xapi1}
23
+VM_VLAN=${VM_VLAN:-100}
24
+
25
+# MGMT network params
26
+MGT_NETMASK=${MGT_NETMASK:-255.255.255.0}
27
+MGT_BR=${MGT_BR:-xapi2}
28
+MGT_VLAN=${MGT_VLAN:-101}
29
+
30
+# XVA Directory
31
+XVA_DIR=${XVA_DIR:-xvas}
32
+
33
+# Path to xva file
34
+XVA=${XVA:-$XVA_DIR/$GUEST_NAME.xva }
35
+
36
+# Source params
37
+cd ../.. && source ./stackrc && cd $TOP_DIR