11#! /bin/bash
22
3+ # Exit on errors
4+ set -o errexit
5+
36# Abort if localrc is not set
47if [ ! -e ../../localrc ]; then
58 echo " You must have a localrc with ALL necessary passwords defined before proceeding."
@@ -19,25 +22,29 @@ source xenrc
1922# Echo commands
2023set -o xtrace
2124
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
25+ xe_min ()
26+ {
27+ local cmd= " $1 "
28+ shift
29+ xe " $cmd " --minimal " $@ "
30+ }
2831
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
32+ cd $TOP_DIR
33+ if [ -f ./master ]
34+ then
35+ rm -rf ./master
36+ rm -rf ./nova
4037fi
38+ wget https://github.com/openstack/nova/zipball/master --no-check-certificate
39+ unzip -o master -d ./nova
40+ cp -pr ./nova/* /plugins/xenserver/xenapi/etc/xapi.d /etc/
41+ chmod a+x /etc/xapi.d/plugins/*
42+
43+ mkdir -p /boot/guest
44+
45+ GUEST_NAME=${GUEST_NAME:- " DevStackOSDomU" }
46+ SNAME=" ubuntusnapshot"
47+ TNAME=" ubuntuready"
4148
4249# Helper to create networks
4350# Uses echo trickery to return network uuid
@@ -48,23 +55,23 @@ function create_network() {
4855 netname=$4
4956 if [ -z $br ]
5057 then
51- pif=$( xe pif-list --minimal device=$dev VLAN=$vlan )
58+ pif=$( xe_min pif-list device=$dev VLAN=$vlan )
5259 if [ -z $pif ]
5360 then
5461 net=$( xe network-create name-label=$netname )
5562 else
56- net=$( xe network-list --minimal PIF-uuids=$pif )
63+ net=$( xe_min network-list PIF-uuids=$pif )
5764 fi
5865 echo $net
5966 return 0
6067 fi
61- if [ ! $( xe network-list --minimal params=bridge | grep -w --only-matching $br ) ]
68+ if [ ! $( xe_min network-list params=bridge | grep -w --only-matching $br ) ]
6269 then
6370 echo " Specified bridge $br does not exist"
6471 echo " If you wish to use defaults, please keep the bridge name empty"
6572 exit 1
6673 else
67- net=$( xe network-list --minimal bridge=$br )
74+ net=$( xe_min network-list bridge=$br )
6875 echo $net
6976 fi
7077}
@@ -95,13 +102,13 @@ function create_vlan() {
95102 then
96103 return
97104 fi
98- if [ -z $( xe vlan-list --minimal tag=$vlan ) ]
105+ if [ -z $( xe_min vlan-list tag=$vlan ) ]
99106 then
100- pif=$( xe pif-list --minimal network-uuid=$net )
107+ pif=$( xe_min pif-list network-uuid=$net )
101108 # We created a brand new network this time
102109 if [ -z $pif ]
103110 then
104- pif=$( xe pif-list --minimal device=$dev VLAN=-1)
111+ pif=$( xe_min pif-list device=$dev VLAN=-1)
105112 xe vlan-create pif-uuid=$pif vlan=$vlan network-uuid=$net
106113 else
107114 echo " VLAN does not exist but PIF attached to this network"
133140# Enable ip forwarding at runtime as well
134141echo 1 > /proc/sys/net/ipv4/ip_forward
135142
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-
149143# Shutdown previous runs
150144DO_SHUTDOWN=${DO_SHUTDOWN:- 1}
151145if [ " $DO_SHUTDOWN " = " 1" ]; then
152146 # Shutdown all domU's that created previously
153- xe vm-list --minimal name-label=" $LABEL " | xargs ./scripts/uninstall-os-vpx.sh
147+ xe_min vm-list name-label=" $GUEST_NAME " | xargs ./scripts/uninstall-os-vpx.sh
154148
155149 # Destroy any instances that were launched
156150 for uuid in ` xe vm-list | grep -1 instance | grep uuid | sed " s/.*\: //g" ` ; do
168162
169163# Start guest
170164if [ -z $VM_BR ]; then
171- VM_BR=$( xe network-list --minimal uuid=$VM_NET params=bridge)
165+ VM_BR=$( xe_min network-list uuid=$VM_NET params=bridge)
172166fi
173167if [ -z $MGT_BR ]; then
174- MGT_BR=$( xe network-list --minimal uuid=$MGT_NET params=bridge)
168+ MGT_BR=$( xe_min network-list uuid=$MGT_NET params=bridge)
175169fi
176170if [ -z $PUB_BR ]; then
177- PUB_BR=$( xe network-list --minimal uuid=$PUB_NET params=bridge)
171+ PUB_BR=$( xe_min network-list uuid=$PUB_NET params=bridge)
178172fi
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} "
173+
174+ templateuuid=$( xe template-list name-label=" $TNAME " )
175+ if [ -n " $templateuuid " ]
176+ then
177+ vm_uuid=$( xe vm-install template=" $TNAME " new-name-label=" $GUEST_NAME " )
178+ else
179+ template=$( xe_min template-list name-label=" Ubuntu 11.10 (64-bit)" )
180+ if [ -z " $template " ]
181+ then
182+ $TOP_DIR /scripts/xenoneirictemplate.sh
183+ fi
184+ $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} "
185+
186+ # Wait for install to finish
187+ while true
188+ do
189+ state=$( xe_min vm-list name-label=" $GUEST_NAME " power-state=halted)
190+ if [ -n " $state " ]
191+ then
192+ break
193+ else
194+ echo " Waiting for " $GUEST_NAME " to finish installation..."
195+ sleep 30
196+ fi
197+ done
198+
199+ vm_uuid=$( xe_min vm-list name-label=" $GUEST_NAME " )
200+ xe vm-param-set actions-after-reboot=Restart uuid=" $vm_uuid "
201+
202+ # Make template from VM
203+ snuuid=$( xe vm-snapshot vm=" $GUEST_NAME " new-name-label=" $SNAME " )
204+ template_uuid=$( xe snapshot-clone uuid=$snuuid new-name-label=" $TNAME " )
205+ fi
206+
207+ $TOP_DIR /build_xva.sh " $GUEST_NAME "
208+
209+ xe vm-start vm=" $GUEST_NAME "
180210
181211if [ $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' )
212+ PUB_IP=$( xe_min vm-list name-label=$GUEST_NAME params=networks | sed -ne ' s,^.*3/ip: \([0-9.]*\).*$,\1,p' )
183213fi
184214
185215# If we have copied our ssh credentials, use ssh to monitor while the installation runs
0 commit comments