Browse code

Backport new style XenServer install to essex

Change-Id: I1db76796a59f8040e88215fc452f6bb30037cf15

John Garbutt authored on 2012/05/22 21:11:54
Showing 17 changed files
... ...
@@ -293,7 +293,7 @@ function read_password {
293 293
 if [ "$VIRT_DRIVER" = 'xenserver' ]; then
294 294
     PUBLIC_INTERFACE_DEFAULT=eth3
295 295
     # allow build_domU.sh to specify the flat network bridge via kernel args
296
-    FLAT_NETWORK_BRIDGE_DEFAULT=$(grep -o 'flat_network_bridge=[^.]*' /proc/cmdline | cut -d= -f 2)
296
+    FLAT_NETWORK_BRIDGE_DEFAULT=$(grep -o 'flat_network_bridge=[[:alnum:]]*' /proc/cmdline | cut -d= -f 2 | sort -u)
297 297
     GUEST_INTERFACE_DEFAULT=eth1
298 298
 else
299 299
     PUBLIC_INTERFACE_DEFAULT=br100
... ...
@@ -1,7 +1,7 @@
1 1
 Getting Started With XenServer 5.6 and Devstack
2 2
 ===============================================
3 3
 The purpose of the code in this directory it to help developers bootstrap
4
-a XenServer 5.6 + Openstack development environment.  This file gives
4
+a XenServer 5.6 (or greater) + Openstack development environment.  This file gives
5 5
 some pointers on how to get started.
6 6
 
7 7
 Xenserver is a Type 1 hypervisor, so it needs to be installed on bare metal.
... ...
@@ -25,36 +25,25 @@ getting started (I use settings like this with a lappy + cheap wifi router):
25 25
 * XenServer Gateway: 192.168.1.1
26 26
 * XenServer DNS: 192.168.1.1
27 27
 
28
-Note:
29
-It is advisable (and necessary if you are using Xenserver 6.0, due to space
30
-limitations), to create the above mentioned OS domU, on a separate dev machine.
31
-To do this, you will need to run Steps 2 on the dev machine (if required) as
32
-well as the Xenserver host. Steps 3 and 4 should be run on the dev machine.
33
-This process requires you to be root on the dev machine.
34
-
35
-Step 2: Prepare DOM0
36
-At this point, your host is missing some critical software that you will
37
-need to run devstack (like git).  Do this to install required software:
38
-
39
-    wget --no-check-certificate https://raw.github.com/openstack-dev/devstack/master/tools/xen/prepare_dom0.sh
40
-    chmod 755 prepare_dom0.sh
41
-    ./prepare_dom0.sh
28
+Step 2: Download devstack
29
+--------------------------
30
+On your XenServer host, run the following commands as root:
42 31
 
43
-This step will also clone devstack in $DEVSTACKSRCROOT/devstack.
44
-$DEVSTACKSRCROOT=/root by default.
32
+wget --no-check-certificate https://github.com/openstack-dev/devstack/zipball/master
33
+unzip -o master -d ./devstack
34
+cd devstack/*/
45 35
 
46
-Step 3: Configure your localrc
36
+Step 3: Configure your localrc inside the devstack directory
37
+------------------------------------------------------------
47 38
 Devstack uses a localrc for user-specific configuration.  Note that
48 39
 the XENAPI_PASSWORD must be your dom0 root password.
49 40
 Of course, use real passwords if this machine is exposed.
50 41
 
51
-    cat > $DEVSTACKSRCROOT/devstack/localrc <<EOF
42
+    cat > ./localrc <<EOF
52 43
     MYSQL_PASSWORD=my_super_secret
53 44
     SERVICE_TOKEN=my_super_secret
54 45
     ADMIN_PASSWORD=my_super_secret
46
+    SERVICE_PASSWORD=$ADMIN_PASSWORD
55 47
     RABBIT_PASSWORD=my_super_secret
56 48
     # This is the password for your guest (for both stack and root users)
57 49
     GUEST_PASSWORD=my_super_secret
... ...
@@ -70,33 +59,31 @@ Of course, use real passwords if this machine is exposed.
70 70
     ACTIVE_TIMEOUT=45
71 71
     # Interface on which you would like to access services
72 72
     HOST_IP_IFACE=ethX
73
+    # First time Ubuntu network install params
74
+    NETINSTALLIP="dhcp"
75
+    NAMESERVERS=""
76
+    NETMASK=""
77
+    GATEWAY=""
73 78
     EOF
74 79
 
75
-Step 4: Run ./build_xva.sh
76
-This script prepares your nova xva image. If you run this on a different machine,
77
-copy the resulting xva file to tools/xen/xvas/[GUEST_NAME].xva
78
-(by default tools/xen/xvas/ALLINONE.xva) on the Xenserver host.
80
+Step 4: Run ./install_os_domU.sh from the tools/xen directory
81
+-------------------------------------------------------------
82
+cd tools/xen
83
+./install_os_domU.sh
79 84
 
80
-cd $DEVSTACKSRCROOT/devstack/tools/xen
81
-./build_xva.sh
85
+Once this script finishes executing, log into the VM (openstack domU)
86
+that it installed and tail the run.sh.log file. You will need to wait
87
+until it run.sh has finished executing.
82 88
 
83
-You will also need to copy your localrc to the Xenserver host.
84 89
 
85
-Step 5: Run ./build_domU.sh
86
-This script does a lot of stuff, it is probably best to read it in its entirety.
87
-But in a nutshell, it performs the following:
88
-
89
-* Configures bridges and vlans for public, private, and management nets
90
-* Creates and installs a OpenStack all-in-one domU in an HA-FlatDHCP configuration
91
-* A script to create a multi-domU (ie. head node separated from compute) configuration is coming soon!
92
-
93
-cd $DEVSTACKSRCROOT/devstack/tools/xen
94
-./build_domU.sh
95
-
96
-Step 6: Do cloudy stuff!
90
+Step 5: Do cloudy stuff!
97 91
 --------------------------
98 92
 * Play with horizon
99 93
 * Play with the CLI
100 94
 * Log bugs to devstack and core projects, and submit fixes!
95
+
96
+Step 6: Run from snapshot
97
+-------------------------
98
+If you want to quicky re-run devstack from a clean state,
99
+using the same settings you used in your previous run,
100
+you can revert the DomU to the snapshot called "before_first_boot"
101 101
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,42 +1,42 @@
1 1
 #!/bin/bash
2 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
3
+# This script is run by install_os_domU.sh
4
+#
5
+# It modifies the ubuntu image created by install_os_domU.sh
6
+# and previously moodified by prepare_guest_template.sh
7
+#
8
+# This script is responsible for:
9
+# - pushing in the DevStack code
10
+# - creating run.sh, to run the code on boot
11
+# It does this by mounting the disk image of the VM.
12
+#
13
+# The resultant image is then templated and started
14
+# by install_os_domU.sh
15
+
16
+# Exit on errors
17
+set -o errexit
18
+# Echo commands
19
+set -o xtrace
9 20
 
10 21
 # This directory
11 22
 TOP_DIR=$(cd $(dirname "$0") && pwd)
12 23
 
24
+# Include onexit commands
25
+. $TOP_DIR/scripts/on_exit.sh
26
+
13 27
 # Source params - override xenrc params in your localrc to suite your taste
14 28
 source xenrc
15 29
 
16
-# Echo commands
17
-set -o xtrace
18
-
19
-# Directory where we stage the build
20
-STAGING_DIR=$TOP_DIR/stage
30
+#
31
+# Parameters
32
+#
33
+GUEST_NAME="$1"
21 34
 
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
37
-
38
-# Free up precious disk space
39
-rm -f /tmp/stage.tgz
35
+#
36
+# Mount the VDI
37
+#
38
+STAGING_DIR=$($TOP_DIR/scripts/manage-vdi open $GUEST_NAME 0 1 | grep -o "/tmp/tmp.[[:alnum:]]*")
39
+add_on_exit "$TOP_DIR/scripts/manage-vdi close $GUEST_NAME 0 1"
40 40
 
41 41
 # Make sure we have a stage
42 42
 if [ ! -d $STAGING_DIR/etc ]; then
... ...
@@ -55,69 +55,36 @@ 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
-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
73
+chown -R stack /opt/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
 
118 81
 # Hostname must resolve for rabbit
82
+HOSTS_FILE_IP=$PUB_IP
83
+if [ $MGT_IP != "dhcp" ]; then
84
+    HOSTS_FILE_IP=$MGT_IP
85
+fi
119 86
 cat <<EOF >$STAGING_DIR/etc/hosts
120
-$MGT_IP $GUEST_NAME
87
+$HOSTS_FILE_IP $GUEST_NAME
121 88
 127.0.0.1 localhost localhost.localdomain
122 89
 EOF
123 90
 
... ...
@@ -151,10 +118,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
... ...
@@ -177,15 +140,6 @@ cat <<EOF >$STAGING_DIR/opt/stack/run.sh
177 177
 #!/bin/bash
178 178
 cd /opt/stack/devstack
179 179
 killall screen
180
-UPLOAD_LEGACY_TTY=yes HOST_IP=$PUB_IP VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST=1 HOST_IP_IFACE=$HOST_IP_IFACE $STACKSH_PARAMS ./stack.sh
180
+VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST=$MULTI_HOST HOST_IP_IFACE=$HOST_IP_IFACE $STACKSH_PARAMS ./stack.sh
181 181
 EOF
182 182
 chmod 755 $STAGING_DIR/opt/stack/run.sh
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]"
192 183
new file mode 100644
... ...
@@ -0,0 +1,470 @@
0
+### Contents of the preconfiguration file (for squeeze)
1
+### Localization
2
+# Preseeding only locale sets language, country and locale.
3
+d-i debian-installer/locale string en_US
4
+
5
+# The values can also be preseeded individually for greater flexibility.
6
+#d-i debian-installer/language string en
7
+#d-i debian-installer/country string NL
8
+#d-i debian-installer/locale string en_GB.UTF-8
9
+# Optionally specify additional locales to be generated.
10
+#d-i localechooser/supported-locales en_US.UTF-8, nl_NL.UTF-8
11
+
12
+# Keyboard selection.
13
+# Disable automatic (interactive) keymap detection.
14
+d-i console-setup/ask_detect boolean false
15
+#d-i keyboard-configuration/modelcode string pc105
16
+d-i keyboard-configuration/layoutcode string us
17
+# To select a variant of the selected layout (if you leave this out, the
18
+# basic form of the layout will be used):
19
+#d-i keyboard-configuration/variantcode string dvorak
20
+
21
+### Network configuration
22
+# Disable network configuration entirely. This is useful for cdrom
23
+# installations on non-networked devices where the network questions,
24
+# warning and long timeouts are a nuisance.
25
+#d-i netcfg/enable boolean false
26
+
27
+# netcfg will choose an interface that has link if possible. This makes it
28
+# skip displaying a list if there is more than one interface.
29
+d-i netcfg/choose_interface select auto
30
+
31
+# To pick a particular interface instead:
32
+#d-i netcfg/choose_interface select eth1
33
+
34
+# If you have a slow dhcp server and the installer times out waiting for
35
+# it, this might be useful.
36
+#d-i netcfg/dhcp_timeout string 60
37
+
38
+# If you prefer to configure the network manually, uncomment this line and
39
+# the static network configuration below.
40
+#d-i netcfg/disable_autoconfig boolean true
41
+
42
+# If you want the preconfiguration file to work on systems both with and
43
+# without a dhcp server, uncomment these lines and the static network
44
+# configuration below.
45
+#d-i netcfg/dhcp_failed note
46
+#d-i netcfg/dhcp_options select Configure network manually
47
+
48
+# Static network configuration.
49
+#d-i netcfg/get_nameservers string 192.168.1.1
50
+#d-i netcfg/get_ipaddress string 192.168.1.42
51
+#d-i netcfg/get_netmask string 255.255.255.0
52
+#d-i netcfg/get_gateway string 192.168.1.1
53
+#d-i netcfg/confirm_static boolean true
54
+
55
+# Any hostname and domain names assigned from dhcp take precedence over
56
+# values set here. However, setting the values still prevents the questions
57
+# from being shown, even if values come from dhcp.
58
+d-i netcfg/get_hostname string stack
59
+d-i netcfg/get_domain string stackpass
60
+
61
+# Disable that annoying WEP key dialog.
62
+d-i netcfg/wireless_wep string
63
+# The wacky dhcp hostname that some ISPs use as a password of sorts.
64
+#d-i netcfg/dhcp_hostname string radish
65
+
66
+# If non-free firmware is needed for the network or other hardware, you can
67
+# configure the installer to always try to load it, without prompting. Or
68
+# change to false to disable asking.
69
+#d-i hw-detect/load_firmware boolean true
70
+
71
+### Network console
72
+# Use the following settings if you wish to make use of the network-console
73
+# component for remote installation over SSH. This only makes sense if you
74
+# intend to perform the remainder of the installation manually.
75
+#d-i anna/choose_modules string network-console
76
+#d-i network-console/password password r00tme
77
+#d-i network-console/password-again password r00tme
78
+
79
+### Mirror settings
80
+# If you select ftp, the mirror/country string does not need to be set.
81
+#d-i mirror/protocol string ftp
82
+d-i mirror/country string manual
83
+d-i mirror/http/hostname string archive.ubuntu.com
84
+d-i mirror/http/directory string /ubuntu
85
+d-i mirror/http/proxy string
86
+
87
+# Alternatively: by default, the installer uses CC.archive.ubuntu.com where
88
+# CC is the ISO-3166-2 code for the selected country. You can preseed this
89
+# so that it does so without asking.
90
+#d-i mirror/http/mirror select CC.archive.ubuntu.com
91
+
92
+# Suite to install.
93
+#d-i mirror/suite string squeeze
94
+# Suite to use for loading installer components (optional).
95
+#d-i mirror/udeb/suite string squeeze
96
+# Components to use for loading installer components (optional).
97
+#d-i mirror/udeb/components multiselect main, restricted
98
+
99
+### Clock and time zone setup
100
+# Controls whether or not the hardware clock is set to UTC.
101
+d-i clock-setup/utc boolean true
102
+
103
+# You may set this to any valid setting for $TZ; see the contents of
104
+# /usr/share/zoneinfo/ for valid values.
105
+d-i time/zone string US/Pacific
106
+
107
+# Controls whether to use NTP to set the clock during the install
108
+d-i clock-setup/ntp boolean true
109
+# NTP server to use. The default is almost always fine here.
110
+d-i clock-setup/ntp-server string 0.us.pool.ntp.org
111
+
112
+### Partitioning
113
+## Partitioning example
114
+# If the system has free space you can choose to only partition that space.
115
+# This is only honoured if partman-auto/method (below) is not set.
116
+# Alternatives: custom, some_device, some_device_crypto, some_device_lvm.
117
+#d-i partman-auto/init_automatically_partition select biggest_free
118
+
119
+# Alternatively, you may specify a disk to partition. If the system has only
120
+# one disk the installer will default to using that, but otherwise the device
121
+# name must be given in traditional, non-devfs format (so e.g. /dev/hda or
122
+# /dev/sda, and not e.g. /dev/discs/disc0/disc).
123
+# For example, to use the first SCSI/SATA hard disk:
124
+#d-i partman-auto/disk string /dev/sda
125
+# In addition, you'll need to specify the method to use.
126
+# The presently available methods are:
127
+# - regular: use the usual partition types for your architecture
128
+# - lvm:     use LVM to partition the disk
129
+# - crypto:  use LVM within an encrypted partition
130
+d-i partman-auto/method string regular
131
+
132
+# If one of the disks that are going to be automatically partitioned
133
+# contains an old LVM configuration, the user will normally receive a
134
+# warning. This can be preseeded away...
135
+d-i partman-lvm/device_remove_lvm boolean true
136
+# The same applies to pre-existing software RAID array:
137
+d-i partman-md/device_remove_md boolean true
138
+# And the same goes for the confirmation to write the lvm partitions.
139
+d-i partman-lvm/confirm boolean true
140
+
141
+# For LVM partitioning, you can select how much of the volume group to use
142
+# for logical volumes.
143
+#d-i partman-auto-lvm/guided_size string max
144
+#d-i partman-auto-lvm/guided_size string 10GB
145
+#d-i partman-auto-lvm/guided_size string 50%
146
+
147
+# You can choose one of the three predefined partitioning recipes:
148
+# - atomic: all files in one partition
149
+# - home:   separate /home partition
150
+# - multi:  separate /home, /usr, /var, and /tmp partitions
151
+d-i partman-auto/choose_recipe select atomic
152
+
153
+# Or provide a recipe of your own...
154
+# If you have a way to get a recipe file into the d-i environment, you can
155
+# just point at it.
156
+#d-i partman-auto/expert_recipe_file string /hd-media/recipe
157
+
158
+# If not, you can put an entire recipe into the preconfiguration file in one
159
+# (logical) line. This example creates a small /boot partition, suitable
160
+# swap, and uses the rest of the space for the root partition:
161
+#d-i partman-auto/expert_recipe string                         \
162
+#      boot-root ::                                            \
163
+#              40 50 100 ext3                                  \
164
+#                      $primary{ } $bootable{ }                \
165
+#                      method{ format } format{ }              \
166
+#                      use_filesystem{ } filesystem{ ext3 }    \
167
+#                      mountpoint{ /boot }                     \
168
+#              .                                               \
169
+#              500 10000 1000000000 ext3                       \
170
+#                      method{ format } format{ }              \
171
+#                      use_filesystem{ } filesystem{ ext3 }    \
172
+#                      mountpoint{ / }                         \
173
+#              .                                               \
174
+#              64 512 300% linux-swap                          \
175
+#                      method{ swap } format{ }                \
176
+#              .
177
+
178
+# If you just want to change the default filesystem from ext3 to something
179
+# else, you can do that without providing a full recipe.
180
+d-i partman/default_filesystem string ext3
181
+
182
+# The full recipe format is documented in the file partman-auto-recipe.txt
183
+# included in the 'debian-installer' package or available from D-I source
184
+# repository. This also documents how to specify settings such as file
185
+# system labels, volume group names and which physical devices to include
186
+# in a volume group.
187
+
188
+# This makes partman automatically partition without confirmation, provided
189
+# that you told it what to do using one of the methods above.
190
+d-i partman-partitioning/confirm_write_new_label boolean true
191
+d-i partman/choose_partition select finish
192
+d-i partman/confirm boolean true
193
+d-i partman/confirm_nooverwrite boolean true
194
+
195
+## Partitioning using RAID
196
+# The method should be set to "raid".
197
+#d-i partman-auto/method string raid
198
+# Specify the disks to be partitioned. They will all get the same layout,
199
+# so this will only work if the disks are the same size.
200
+#d-i partman-auto/disk string /dev/sda /dev/sdb
201
+
202
+# Next you need to specify the physical partitions that will be used. 
203
+#d-i partman-auto/expert_recipe string \
204
+#      multiraid ::                                         \
205
+#              1000 5000 4000 raid                          \
206
+#                      $primary{ } method{ raid }           \
207
+#              .                                            \
208
+#              64 512 300% raid                             \
209
+#                      method{ raid }                       \
210
+#              .                                            \
211
+#              500 10000 1000000000 raid                    \
212
+#                      method{ raid }                       \
213
+#              .
214
+
215
+# Last you need to specify how the previously defined partitions will be
216
+# used in the RAID setup. Remember to use the correct partition numbers
217
+# for logical partitions. RAID levels 0, 1, 5, 6 and 10 are supported;
218
+# devices are separated using "#".
219
+# Parameters are:
220
+# <raidtype> <devcount> <sparecount> <fstype> <mountpoint> \
221
+#          <devices> <sparedevices>
222
+
223
+#d-i partman-auto-raid/recipe string \
224
+#    1 2 0 ext3 /                    \
225
+#          /dev/sda1#/dev/sdb1       \
226
+#    .                               \
227
+#    1 2 0 swap -                    \
228
+#          /dev/sda5#/dev/sdb5       \
229
+#    .                               \
230
+#    0 2 0 ext3 /home                \
231
+#          /dev/sda6#/dev/sdb6       \
232
+#    .
233
+
234
+# For additional information see the file partman-auto-raid-recipe.txt
235
+# included in the 'debian-installer' package or available from D-I source
236
+# repository.
237
+
238
+# This makes partman automatically partition without confirmation.
239
+d-i partman-md/confirm boolean true
240
+d-i partman-partitioning/confirm_write_new_label boolean true
241
+d-i partman/choose_partition select finish
242
+d-i partman/confirm boolean true
243
+d-i partman/confirm_nooverwrite boolean true
244
+
245
+## Controlling how partitions are mounted
246
+# The default is to mount by UUID, but you can also choose "traditional" to
247
+# use traditional device names, or "label" to try filesystem labels before
248
+# falling back to UUIDs.
249
+#d-i partman/mount_style select uuid
250
+
251
+### Base system installation
252
+# Configure APT to not install recommended packages by default. Use of this
253
+# option can result in an incomplete system and should only be used by very
254
+# experienced users.
255
+#d-i base-installer/install-recommends boolean false
256
+
257
+# The kernel image (meta) package to be installed; "none" can be used if no
258
+# kernel is to be installed.
259
+#d-i base-installer/kernel/image string linux-generic
260
+
261
+### Account setup
262
+# Skip creation of a root account (normal user account will be able to
263
+# use sudo). The default is false; preseed this to true if you want to set
264
+# a root password.
265
+d-i passwd/root-login boolean true
266
+# Alternatively, to skip creation of a normal user account.
267
+d-i passwd/make-user boolean false
268
+
269
+# Root password, either in clear text
270
+d-i passwd/root-password password stackpass
271
+d-i passwd/root-password-again password stackpass
272
+# or encrypted using an MD5 hash.
273
+#d-i passwd/root-password-crypted password [MD5 hash]
274
+
275
+# To create a normal user account.
276
+#d-i passwd/user-fullname string Ubuntu User
277
+#d-i passwd/username string ubuntu
278
+# Normal user's password, either in clear text
279
+#d-i passwd/user-password password insecure
280
+#d-i passwd/user-password-again password insecure
281
+# or encrypted using an MD5 hash.
282
+#d-i passwd/user-password-crypted password [MD5 hash]
283
+# Create the first user with the specified UID instead of the default.
284
+#d-i passwd/user-uid string 1010
285
+# The installer will warn about weak passwords. If you are sure you know
286
+# what you're doing and want to override it, uncomment this.
287
+d-i user-setup/allow-password-weak boolean true
288
+
289
+# The user account will be added to some standard initial groups. To
290
+# override that, use this.
291
+#d-i passwd/user-default-groups string audio cdrom video
292
+
293
+# Set to true if you want to encrypt the first user's home directory.
294
+d-i user-setup/encrypt-home boolean false
295
+
296
+### Apt setup
297
+# You can choose to install restricted and universe software, or to install
298
+# software from the backports repository.
299
+#d-i apt-setup/restricted boolean true
300
+#d-i apt-setup/universe boolean true
301
+#d-i apt-setup/backports boolean true
302
+# Uncomment this if you don't want to use a network mirror.
303
+#d-i apt-setup/use_mirror boolean false
304
+# Select which update services to use; define the mirrors to be used.
305
+# Values shown below are the normal defaults.
306
+#d-i apt-setup/services-select multiselect security
307
+#d-i apt-setup/security_host string security.ubuntu.com
308
+#d-i apt-setup/security_path string /ubuntu
309
+
310
+# Additional repositories, local[0-9] available
311
+#d-i apt-setup/local0/repository string \
312
+#       http://local.server/ubuntu squeeze main
313
+#d-i apt-setup/local0/comment string local server
314
+# Enable deb-src lines
315
+#d-i apt-setup/local0/source boolean true
316
+# URL to the public key of the local repository; you must provide a key or
317
+# apt will complain about the unauthenticated repository and so the
318
+# sources.list line will be left commented out
319
+#d-i apt-setup/local0/key string http://local.server/key
320
+
321
+# By default the installer requires that repositories be authenticated
322
+# using a known gpg key. This setting can be used to disable that
323
+# authentication. Warning: Insecure, not recommended.
324
+#d-i debian-installer/allow_unauthenticated boolean true
325
+
326
+### Package selection
327
+#tasksel tasksel/first multiselect ubuntu-desktop
328
+#tasksel tasksel/first multiselect lamp-server, print-server
329
+#tasksel tasksel/first multiselect kubuntu-desktop
330
+tasksel tasksel/first multiselect openssh-server
331
+
332
+# Individual additional packages to install
333
+#d-i pkgsel/include string openssh-server build-essential
334
+# Whether to upgrade packages after debootstrap.
335
+# Allowed values: none, safe-upgrade, full-upgrade
336
+#d-i pkgsel/upgrade select none
337
+
338
+# Language pack selection
339
+#d-i pkgsel/language-packs multiselect de, en, zh
340
+
341
+# Policy for applying updates. May be "none" (no automatic updates),
342
+# "unattended-upgrades" (install security updates automatically), or
343
+# "landscape" (manage system with Landscape).
344
+d-i pkgsel/update-policy select unattended-upgrades
345
+
346
+# Some versions of the installer can report back on what software you have
347
+# installed, and what software you use. The default is not to report back,
348
+# but sending reports helps the project determine what software is most
349
+# popular and include it on CDs.
350
+#popularity-contest popularity-contest/participate boolean false
351
+
352
+# By default, the system's locate database will be updated after the
353
+# installer has finished installing most packages. This may take a while, so
354
+# if you don't want it, you can set this to "false" to turn it off.
355
+d-i pkgsel/updatedb boolean false
356
+
357
+### Boot loader installation
358
+# Grub is the default boot loader (for x86). If you want lilo installed
359
+# instead, uncomment this:
360
+#d-i grub-installer/skip boolean true
361
+# To also skip installing lilo, and install no bootloader, uncomment this
362
+# too:
363
+#d-i lilo-installer/skip boolean true
364
+
365
+# With a few exceptions for unusual partitioning setups, GRUB 2 is now the
366
+# default. If you need GRUB Legacy for some particular reason, then
367
+# uncomment this:
368
+#d-i grub-installer/grub2_instead_of_grub_legacy boolean false
369
+
370
+# This is fairly safe to set, it makes grub install automatically to the MBR
371
+# if no other operating system is detected on the machine.
372
+d-i grub-installer/only_debian boolean true
373
+
374
+# This one makes grub-installer install to the MBR if it also finds some other
375
+# OS, which is less safe as it might not be able to boot that other OS.
376
+d-i grub-installer/with_other_os boolean true
377
+
378
+# Alternatively, if you want to install to a location other than the mbr,
379
+# uncomment and edit these lines:
380
+#d-i grub-installer/only_debian boolean false
381
+#d-i grub-installer/with_other_os boolean false
382
+#d-i grub-installer/bootdev  string (hd0,0)
383
+# To install grub to multiple disks:
384
+#d-i grub-installer/bootdev  string (hd0,0) (hd1,0) (hd2,0)
385
+
386
+# Optional password for grub, either in clear text
387
+#d-i grub-installer/password password r00tme
388
+#d-i grub-installer/password-again password r00tme
389
+# or encrypted using an MD5 hash, see grub-md5-crypt(8).
390
+#d-i grub-installer/password-crypted password [MD5 hash]
391
+
392
+# Use the following option to add additional boot parameters for the
393
+# installed system (if supported by the bootloader installer).
394
+# Note: options passed to the installer will be added automatically.
395
+#d-i debian-installer/add-kernel-opts string nousb
396
+
397
+### Finishing up the installation
398
+# During installations from serial console, the regular virtual consoles
399
+# (VT1-VT6) are normally disabled in /etc/inittab. Uncomment the next
400
+# line to prevent this.
401
+d-i finish-install/keep-consoles boolean true
402
+
403
+# Avoid that last message about the install being complete.
404
+d-i finish-install/reboot_in_progress note
405
+
406
+# This will prevent the installer from ejecting the CD during the reboot,
407
+# which is useful in some situations.
408
+#d-i cdrom-detect/eject boolean false
409
+
410
+# This is how to make the installer shutdown when finished, but not
411
+# reboot into the installed system.
412
+#d-i debian-installer/exit/halt boolean true
413
+# This will power off the machine instead of just halting it.
414
+#d-i debian-installer/exit/poweroff boolean true
415
+
416
+### X configuration
417
+# X can detect the right driver for some cards, but if you're preseeding,
418
+# you override whatever it chooses. Still, vesa will work most places.
419
+#xserver-xorg xserver-xorg/config/device/driver select vesa
420
+
421
+# A caveat with mouse autodetection is that if it fails, X will retry it
422
+# over and over. So if it's preseeded to be done, there is a possibility of
423
+# an infinite loop if the mouse is not autodetected.
424
+#xserver-xorg xserver-xorg/autodetect_mouse boolean true
425
+
426
+# Monitor autodetection is recommended.
427
+xserver-xorg xserver-xorg/autodetect_monitor boolean true
428
+# Uncomment if you have an LCD display.
429
+#xserver-xorg xserver-xorg/config/monitor/lcd boolean true
430
+# X has three configuration paths for the monitor. Here's how to preseed
431
+# the "medium" path, which is always available. The "simple" path may not
432
+# be available, and the "advanced" path asks too many questions.
433
+xserver-xorg xserver-xorg/config/monitor/selection-method \
434
+       select medium
435
+xserver-xorg xserver-xorg/config/monitor/mode-list \
436
+       select 1024x768 @ 60 Hz
437
+
438
+### Preseeding other packages
439
+# Depending on what software you choose to install, or if things go wrong
440
+# during the installation process, it's possible that other questions may
441
+# be asked. You can preseed those too, of course. To get a list of every
442
+# possible question that could be asked during an install, do an
443
+# installation, and then run these commands:
444
+#   debconf-get-selections --installer > file
445
+#   debconf-get-selections >> file
446
+
447
+
448
+#### Advanced options
449
+### Running custom commands during the installation
450
+# d-i preseeding is inherently not secure. Nothing in the installer checks
451
+# for attempts at buffer overflows or other exploits of the values of a
452
+# preconfiguration file like this one. Only use preconfiguration files from
453
+# trusted locations! To drive that home, and because it's generally useful,
454
+# here's a way to run any shell command you'd like inside the installer,
455
+# automatically.
456
+
457
+# This first command is run as early as possible, just after
458
+# preseeding is read.
459
+#d-i preseed/early_command string anna-install some-udeb
460
+# This command is run immediately before the partitioner starts. It may be
461
+# useful to apply dynamic partitioner preseeding that depends on the state
462
+# of the disks (which may not be visible when preseed/early_command runs).
463
+#d-i partman/early_command \
464
+#       string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
465
+# This command is run just before the install finishes, but when there is
466
+# still a usable /target directory. You can chroot to /target and use it
467
+# directly, or use the apt-install and in-target commands to easily install
468
+# packages and run commands in the target system.
469
+#d-i preseed/late_command string apt-install zsh; in-target chsh -s /bin/zsh
0 470
deleted file mode 100755
... ...
@@ -1,40 +0,0 @@
1
-#!/usr/bin/env bash
2
-
3
-# Echo commands
4
-set -o xtrace
5
-
6
-# Head node host, which runs glance, api, keystone
7
-HEAD_PUB_IP=${HEAD_PUB_IP:-192.168.1.57}
8
-HEAD_MGT_IP=${HEAD_MGT_IP:-172.16.100.57}
9
-
10
-COMPUTE_PUB_IP=${COMPUTE_PUB_IP:-192.168.1.58}
11
-COMPUTE_MGT_IP=${COMPUTE_MGT_IP:-172.16.100.58}
12
-
13
-# Networking params
14
-FLOATING_RANGE=${FLOATING_RANGE:-192.168.1.196/30}
15
-
16
-# Variables common amongst all hosts in the cluster
17
-COMMON_VARS="$STACKSH_PARAMS MYSQL_HOST=$HEAD_MGT_IP RABBIT_HOST=$HEAD_MGT_IP GLANCE_HOSTPORT=$HEAD_MGT_IP:9292 FLOATING_RANGE=$FLOATING_RANGE"
18
-
19
-# Helper to launch containers
20
-function install_domU {
21
-    GUEST_NAME=$1 PUB_IP=$2 MGT_IP=$3 DO_SHUTDOWN=$4 TERMINATE=$TERMINATE STACKSH_PARAMS="$COMMON_VARS $5" ./build_domU.sh
22
-}
23
-
24
-# Launch the head node - headnode uses a non-ip domain name,
25
-# because rabbit won't launch with an ip addr hostname :(
26
-install_domU HEADNODE $HEAD_PUB_IP $HEAD_MGT_IP 1 "ENABLED_SERVICES=g-api,g-reg,key,n-api,n-sch,n-vnc,horizon,mysql,rabbit"
27
-
28
-if [ $HEAD_PUB_IP == "dhcp" ]
29
-then
30
-    guestnet=$(xe vm-list --minimal name-label=HEADNODE params=networks)
31
-    HEAD_PUB_IP=$(echo $guestnet | grep -w -o --only-matching "3/ip: [0-9,.]*;" | cut -d ':' -f2 | cut -d ';' -f 1)
32
-fi
33
-# Wait till the head node is up
34
-while ! curl -L http://$HEAD_PUB_IP | grep -q username; do
35
-    echo "Waiting for head node ($HEAD_PUB_IP) to start..."
36
-    sleep 5
37
-done
38
-
39
-# Build the HA compute host
40
-install_domU COMPUTENODE $COMPUTE_PUB_IP $COMPUTE_MGT_IP 0 "ENABLED_SERVICES=n-cpu,n-net,n-api"
41 1
new file mode 100755
... ...
@@ -0,0 +1,418 @@
0
+#!/bin/bash
1
+
2
+# This script is a level script
3
+# It must be run on a XenServer or XCP machine
4
+#
5
+# It creates a DomU VM that runs OpenStack services
6
+#
7
+# For more details see: README.md
8
+
9
+# Exit on errors
10
+set -o errexit
11
+# Echo commands
12
+set -o xtrace
13
+
14
+# Abort if localrc is not set
15
+if [ ! -e ../../localrc ]; then
16
+    echo "You must have a localrc with ALL necessary passwords defined before proceeding."
17
+    echo "See the xen README for required passwords."
18
+    exit 1
19
+fi
20
+
21
+# This directory
22
+TOP_DIR=$(cd $(dirname "$0") && pwd)
23
+
24
+# Source lower level functions
25
+. $TOP_DIR/../../functions
26
+
27
+# Include onexit commands
28
+. $TOP_DIR/scripts/on_exit.sh
29
+
30
+
31
+#
32
+# Get Settings
33
+#
34
+
35
+# Source params - override xenrc params in your localrc to suit your taste
36
+source xenrc
37
+
38
+xe_min()
39
+{
40
+  local cmd="$1"
41
+  shift
42
+  xe "$cmd" --minimal "$@"
43
+}
44
+
45
+
46
+#
47
+# Prepare Dom0
48
+# including installing XenAPI plugins
49
+#
50
+
51
+cd $TOP_DIR
52
+if [ -f ./master ]
53
+then
54
+    rm -rf ./master
55
+    rm -rf ./nova
56
+fi
57
+wget https://github.com/openstack/nova/zipball/master --no-check-certificate
58
+unzip -o master -d ./nova
59
+cp -pr ./nova/*/plugins/xenserver/xenapi/etc/xapi.d /etc/
60
+chmod a+x /etc/xapi.d/plugins/*
61
+mkdir -p /boot/guest
62
+
63
+
64
+#
65
+# Configure Networking
66
+#
67
+
68
+# Helper to create networks
69
+# Uses echo trickery to return network uuid
70
+function create_network() {
71
+    br=$1
72
+    dev=$2
73
+    vlan=$3
74
+    netname=$4
75
+    if [ -z $br ]
76
+    then
77
+        pif=$(xe_min pif-list device=$dev VLAN=$vlan)
78
+        if [ -z $pif ]
79
+        then
80
+            net=$(xe network-create name-label=$netname)
81
+        else
82
+            net=$(xe_min network-list  PIF-uuids=$pif)
83
+        fi
84
+        echo $net
85
+        return 0
86
+    fi
87
+    if [ ! $(xe_min network-list  params=bridge | grep -w --only-matching $br) ]
88
+    then
89
+        echo "Specified bridge $br does not exist"
90
+        echo "If you wish to use defaults, please keep the bridge name empty"
91
+        exit 1
92
+    else
93
+        net=$(xe_min network-list  bridge=$br)
94
+        echo $net
95
+    fi
96
+}
97
+
98
+function errorcheck() {
99
+    rc=$?
100
+    if [ $rc -ne 0 ]
101
+    then
102
+        exit $rc
103
+    fi
104
+}
105
+
106
+# Create host, vm, mgmt, pub networks on XenServer
107
+VM_NET=$(create_network "$VM_BR" "$VM_DEV" "$VM_VLAN" "vmbr")
108
+errorcheck
109
+MGT_NET=$(create_network "$MGT_BR" "$MGT_DEV" "$MGT_VLAN" "mgtbr")
110
+errorcheck
111
+PUB_NET=$(create_network "$PUB_BR" "$PUB_DEV" "$PUB_VLAN" "pubbr")
112
+errorcheck
113
+
114
+# Helper to create vlans
115
+function create_vlan() {
116
+    dev=$1
117
+    vlan=$2
118
+    net=$3
119
+    # VLAN -1 refers to no VLAN (physical network)
120
+    if [ $vlan -eq -1 ]
121
+    then
122
+        return
123
+    fi
124
+    if [ -z $(xe_min vlan-list  tag=$vlan) ]
125
+    then
126
+        pif=$(xe_min pif-list  network-uuid=$net)
127
+        # We created a brand new network this time
128
+        if [ -z $pif ]
129
+        then
130
+            pif=$(xe_min pif-list  device=$dev VLAN=-1)
131
+            xe vlan-create pif-uuid=$pif vlan=$vlan network-uuid=$net
132
+        else
133
+            echo "VLAN does not exist but PIF attached to this network"
134
+            echo "How did we reach here?"
135
+            exit 1
136
+        fi
137
+    fi
138
+}
139
+
140
+# Create vlans for vm and management
141
+create_vlan $PUB_DEV $PUB_VLAN $PUB_NET
142
+create_vlan $VM_DEV $VM_VLAN $VM_NET
143
+create_vlan $MGT_DEV $MGT_VLAN $MGT_NET
144
+
145
+# Get final bridge names
146
+if [ -z $VM_BR ]; then
147
+    VM_BR=$(xe_min network-list  uuid=$VM_NET params=bridge)
148
+fi
149
+if [ -z $MGT_BR ]; then
150
+    MGT_BR=$(xe_min network-list  uuid=$MGT_NET params=bridge)
151
+fi
152
+if [ -z $PUB_BR ]; then
153
+    PUB_BR=$(xe_min network-list  uuid=$PUB_NET params=bridge)
154
+fi
155
+
156
+# dom0 ip, XenAPI is assumed to be listening
157
+HOST_IP=${HOST_IP:-`ifconfig xenbr0 | grep "inet addr" | cut -d ":" -f2 | sed "s/ .*//"`}
158
+
159
+# Set up ip forwarding
160
+if ! grep -q "FORWARD_IPV4=YES" /etc/sysconfig/network; then
161
+    # FIXME: This doesn't work on reboot!
162
+    echo "FORWARD_IPV4=YES" >> /etc/sysconfig/network
163
+fi
164
+# Also, enable ip forwarding in rc.local, since the above trick isn't working
165
+if ! grep -q  "echo 1 >/proc/sys/net/ipv4/ip_forward" /etc/rc.local; then
166
+    echo "echo 1 >/proc/sys/net/ipv4/ip_forward" >> /etc/rc.local
167
+fi
168
+# Enable ip forwarding at runtime as well
169
+echo 1 > /proc/sys/net/ipv4/ip_forward
170
+
171
+
172
+#
173
+# Shutdown previous runs
174
+#
175
+
176
+DO_SHUTDOWN=${DO_SHUTDOWN:-1}
177
+CLEAN_TEMPLATES=${CLEAN_TEMPLATES:-false}
178
+if [ "$DO_SHUTDOWN" = "1" ]; then
179
+    # Shutdown all domU's that created previously
180
+    clean_templates_arg=""
181
+    if $CLEAN_TEMPLATES; then
182
+        clean_templates_arg="--remove-templates"
183
+    fi
184
+    ./scripts/uninstall-os-vpx.sh $clean_templates_arg
185
+
186
+    # Destroy any instances that were launched
187
+    for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do
188
+        echo "Shutting down nova instance $uuid"
189
+        xe vm-unpause uuid=$uuid || true
190
+        xe vm-shutdown uuid=$uuid || true
191
+        xe vm-destroy uuid=$uuid
192
+    done
193
+
194
+    # Destroy orphaned vdis
195
+    for uuid in `xe vdi-list | grep -1 Glance | grep uuid | sed "s/.*\: //g"`; do
196
+        xe vdi-destroy uuid=$uuid
197
+    done
198
+fi
199
+
200
+
201
+#
202
+# Create Ubuntu VM template
203
+# and/or create VM from template
204
+#
205
+
206
+GUEST_NAME=${GUEST_NAME:-"DevStackOSDomU"}
207
+TNAME="devstack_template_essex_11.10"
208
+SNAME_PREPARED="template_prepared"
209
+SNAME_FIRST_BOOT="before_first_boot"
210
+
211
+function wait_for_VM_to_halt() {
212
+    while true
213
+    do
214
+        state=$(xe_min vm-list name-label="$GUEST_NAME" power-state=halted)
215
+        if [ -n "$state" ]
216
+        then
217
+            break
218
+        else
219
+            echo "Waiting for "$GUEST_NAME" to finish installation..."
220
+            sleep 20
221
+        fi
222
+    done
223
+}
224
+
225
+templateuuid=$(xe template-list name-label="$TNAME")
226
+if [ -z "$templateuuid" ]; then
227
+    #
228
+    # Install Ubuntu over network
229
+    #
230
+
231
+    # try to find ubuntu template
232
+    ubuntu_template_name="Ubuntu 11.10 for DevStack (64-bit)"
233
+    ubuntu_template=$(xe_min template-list name-label="$ubuntu_template_name")
234
+
235
+    # remove template, if we are in CLEAN_TEMPLATE mode
236
+    if [ -n "$ubuntu_template" ]; then
237
+        if $CLEAN_TEMPLATES; then
238
+            xe template-param-clear param-name=other-config uuid=$ubuntu_template
239
+            xe template-uninstall template-uuid=$ubuntu_template force=true
240
+            ubuntu_template=""
241
+        fi
242
+    fi
243
+
244
+    # install ubuntu template, if required
245
+    if [ -z "$ubuntu_template" ]; then
246
+        $TOP_DIR/scripts/xenoneirictemplate.sh "${HOST_IP}/devstackubuntupreseed.cfg"
247
+    fi
248
+
249
+    # always update the preseed file, incase we have a newer one
250
+    cp -f $TOP_DIR/devstackubuntupreseed.cfg /opt/xensource/www/
251
+    MIRROR=${MIRROR:-""}
252
+    if [ -n "$MIRROR" ]; then
253
+        sed -e "s,d-i mirror/http/hostname string .*,d-i mirror/http/hostname string $MIRROR," \
254
+            -i /opt/xensource/www/devstackubuntupreseed.cfg
255
+    fi
256
+
257
+    # create a new VM with the given template
258
+    # creating the correct VIFs and metadata
259
+    $TOP_DIR/scripts/install-os-vpx.sh -t "$ubuntu_template_name" -v $VM_BR -m $MGT_BR -p $PUB_BR -l $GUEST_NAME -r $OSDOMU_MEM_MB -k "flat_network_bridge=${VM_BR}"
260
+
261
+    # wait for install to finish
262
+    wait_for_VM_to_halt
263
+
264
+    # set VM to restart after a reboot
265
+    vm_uuid=$(xe_min vm-list name-label="$GUEST_NAME")
266
+    xe vm-param-set actions-after-reboot=Restart uuid="$vm_uuid"
267
+
268
+    #
269
+    # Prepare VM for DevStack
270
+    #
271
+
272
+    # Install XenServer tools, and other such things
273
+    $TOP_DIR/prepare_guest_template.sh "$GUEST_NAME"
274
+
275
+    # start the VM to run the prepare steps
276
+    xe vm-start vm="$GUEST_NAME"
277
+
278
+    # Wait for prep script to finish and shutdown system
279
+    wait_for_VM_to_halt
280
+
281
+    # Make template from VM
282
+    snuuid=$(xe vm-snapshot vm="$GUEST_NAME" new-name-label="$SNAME_PREPARED")
283
+    xe snapshot-clone uuid=$snuuid new-name-label="$TNAME"
284
+else
285
+    #
286
+    # Template already installed, create VM from template
287
+    #
288
+    vm_uuid=$(xe vm-install template="$TNAME" new-name-label="$GUEST_NAME")
289
+fi
290
+
291
+
292
+#
293
+# Inject DevStack inside VM disk
294
+#
295
+$TOP_DIR/build_xva.sh "$GUEST_NAME"
296
+
297
+# create a snapshot before the first boot
298
+# to allow a quick re-run with the same settings
299
+xe vm-snapshot vm="$GUEST_NAME" new-name-label="$SNAME_FIRST_BOOT"
300
+
301
+
302
+#
303
+# Run DevStack VM
304
+#
305
+xe vm-start vm="$GUEST_NAME"
306
+
307
+
308
+#
309
+# Find IP and optionally wait for stack.sh to complete
310
+#
311
+
312
+function find_ip_by_name() {
313
+  local guest_name="$1"
314
+  local interface="$2"
315
+  local period=10
316
+  max_tries=10
317
+  i=0
318
+  while true
319
+  do
320
+    if [ $i -ge $max_tries ]; then
321
+      echo "Timed out waiting for devstack ip address"
322
+      exit 11
323
+    fi
324
+
325
+    devstackip=$(xe vm-list --minimal \
326
+                 name-label=$guest_name \
327
+                 params=networks | sed -ne "s,^.*${interface}/ip: \([0-9.]*\).*\$,\1,p")
328
+    if [ -z "$devstackip" ]
329
+    then
330
+      sleep $period
331
+      ((i++))
332
+    else
333
+      echo $devstackip
334
+      break
335
+    fi
336
+  done
337
+}
338
+
339
+function ssh_no_check() {
340
+    ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$@"
341
+}
342
+
343
+# Note the XenServer needs to be on the chosen
344
+# network, so XenServer can access Glance API
345
+if [ $HOST_IP_IFACE == "eth2" ]; then
346
+    DOMU_IP=$MGT_IP
347
+    if [ $MGT_IP == "dhcp" ]; then
348
+        DOMU_IP=$(find_ip_by_name $GUEST_NAME 2)
349
+    fi
350
+else
351
+    DOMU_IP=$PUB_IP
352
+    if [ $PUB_IP == "dhcp" ]; then
353
+        DOMU_IP=$(find_ip_by_name $GUEST_NAME 3)
354
+    fi
355
+fi
356
+
357
+# If we have copied our ssh credentials, use ssh to monitor while the installation runs
358
+WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1}
359
+COPYENV=${COPYENV:-1}
360
+if [ "$WAIT_TILL_LAUNCH" = "1" ]  && [ -e ~/.ssh/id_rsa.pub  ] && [ "$COPYENV" = "1" ]; then
361
+    echo "We're done launching the vm, about to start tailing the"
362
+    echo "stack.sh log. It will take a second or two to start."
363
+    echo
364
+    echo "Just CTRL-C at any time to stop tailing."
365
+
366
+    # wait for log to appear
367
+    while ! ssh_no_check -q stack@$DOMU_IP "[ -e run.sh.log ]"; do
368
+        sleep 10
369
+    done
370
+
371
+    # output the run.sh.log
372
+    ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no stack@$DOMU_IP 'tail -f run.sh.log' &
373
+    TAIL_PID=$!
374
+
375
+    function kill_tail() {
376
+        kill -9 $TAIL_PID
377
+        exit 1
378
+    }
379
+    # Let Ctrl-c kill tail and exit
380
+    trap kill_tail SIGINT
381
+
382
+    # ensure we kill off the tail if we exit the script early
383
+    # for other reasons
384
+    add_on_exit "kill -9 $TAIL_PID || true"
385
+
386
+    # wait silently until stack.sh has finished
387
+    set +o xtrace
388
+    while ! ssh_no_check -q stack@$DOMU_IP "tail run.sh.log | grep -q 'stack.sh completed in'"; do
389
+        sleep 10
390
+    done
391
+    set -o xtrace
392
+
393
+    # kill the tail process now stack.sh has finished
394
+    kill -9 $TAIL_PID
395
+
396
+    # check for a failure
397
+    if ssh_no_check -q stack@$DOMU_IP "grep -q 'stack.sh failed' run.sh.log"; then
398
+        exit 1
399
+    fi
400
+    echo "################################################################################"
401
+    echo ""
402
+    echo "All Finished!"
403
+    echo "You can visit the OpenStack Dashboard"
404
+    echo "at http://$DOMU_IP, and contact other services at the usual ports."
405
+else
406
+    echo "################################################################################"
407
+    echo ""
408
+    echo "All Finished!"
409
+    echo "Now, you can monitor the progress of the stack.sh installation by "
410
+    echo "tailing /opt/stack/run.sh.log from within your domU."
411
+    echo ""
412
+    echo "ssh into your domU now: 'ssh stack@$DOMU_IP' using your password"
413
+    echo "and then do: 'tail -f /opt/stack/run.sh.log'"
414
+    echo ""
415
+    echo "When the script completes, you can then visit the OpenStack Dashboard"
416
+    echo "at http://$DOMU_IP, and contact other services at the usual ports."
417
+fi
0 418
deleted file mode 100755
... ...
@@ -1,41 +0,0 @@
1
-#i!/bin/sh
2
-set -o xtrace
3
-set -o errexit
4
-
5
-# Install basics for vi and git
6
-yum -y  --enablerepo=base install gcc make vim-enhanced zlib-devel openssl-devel curl-devel.i386
7
-
8
-# Simple but usable vimrc
9
-if [ ! -e /root/.vimrc ]; then
10
-    cat > /root/.vimrc <<EOF
11
-syntax on
12
-se ts=4
13
-se expandtab
14
-se shiftwidth=4
15
-EOF
16
-fi
17
-
18
-# Use the pretty vim
19
-if [ -e /usr/bin/vim ]; then
20
-    rm /bin/vi
21
-    ln -s /usr/bin/vim /bin/vi
22
-fi
23
-
24
-# Install git
25
-if ! which git; then
26
-    DEST=/tmp/
27
-    GITDIR=$DEST/git-1.7.7
28
-    cd $DEST
29
-    rm -rf $GITDIR*
30
-    wget http://git-core.googlecode.com/files/git-1.7.7.tar.gz
31
-    tar xfv git-1.7.7.tar.gz
32
-    cd $GITDIR
33
-    ./configure --with-curl --with-expat
34
-    make install
35
-fi
36
-
37
-# Clone devstack
38
-DEVSTACK=${DEVSTACKROOT:-"/root/devstack"}
39
-if [ ! -d $DEVSTACK ]; then
40
-    git clone git://github.com/openstack-dev/devstack.git $DEVSTACK
41
-fi
42 1
old mode 100644
43 2
new mode 100755
... ...
@@ -1,39 +1,30 @@
1 1
 #!/bin/bash
2 2
 
3
+# This script is run on an Ubuntu VM.
4
+# It is inserted to the VM by prepare_guest_template.sh
5
+# It customizes a fresh Ubuntu install, so it is ready
6
+# to run stack.sh
7
+#
8
+# This includes installing the XenServer tools,
9
+# creating the user called "stack",
10
+# and shuts down the VM to signal the script has completed
11
+
3 12
 set -x
13
+# Echo commands
14
+set -o xtrace
4 15
 
5 16
 # Configurable nuggets
6 17
 GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
7 18
 STAGING_DIR=${STAGING_DIR:-stage}
8 19
 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
-
17
-# Sources.list
18
-cat <<EOF >$STAGING_DIR/etc/apt/sources.list
19
-deb http://us.archive.ubuntu.com/ubuntu/ oneiric main restricted
20
-deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric main restricted
21
-deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates main restricted
22
-deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric-updates main restricted
23
-deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe
24
-deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates universe
25
-deb http://us.archive.ubuntu.com/ubuntu/ oneiric multiverse
26
-deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates multiverse
27
-EOF
28 20
 
29 21
 # Install basics
30 22
 chroot $STAGING_DIR apt-get update
31
-chroot $STAGING_DIR apt-get install -y linux-image-$KERNEL_VERSION
32 23
 chroot $STAGING_DIR apt-get install -y cracklib-runtime curl wget ssh openssh-server tcpdump ethtool
33 24
 chroot $STAGING_DIR apt-get install -y curl wget ssh openssh-server python-pip git vim-nox sudo
34 25
 chroot $STAGING_DIR pip install xenapi
35 26
 
36
-# Install guest utilities
27
+# Install XenServer guest utilities
37 28
 XEGUEST=xe-guest-utilities_5.6.100-651_amd64.deb
38 29
 wget http://images.ansolabs.com/xen/$XEGUEST -O $XEGUEST
39 30
 cp $XEGUEST $STAGING_DIR/root
... ...
@@ -88,3 +79,12 @@ if [ "$DO_TGZ" = "1" ]; then
88 88
     rm -f stage.tgz
89 89
     tar cfz stage.tgz stage
90 90
 fi
91
+
92
+# remove self from local.rc
93
+# so this script is not run again
94
+rm -rf /etc/rc.local
95
+mv /etc/rc.local.preparebackup /etc/rc.local
96
+cp $STAGING_DIR/etc/rc.local $STAGING_DIR/etc/rc.local.backup
97
+
98
+# shutdown to notify we are done
99
+shutdown -h now
91 100
new file mode 100755
... ...
@@ -0,0 +1,57 @@
0
+#!/bin/bash
1
+
2
+# This script is run by install_os_domU.sh
3
+#
4
+# Parameters:
5
+# - $GUEST_NAME - hostname for the DomU VM
6
+#
7
+# It modifies the ubuntu image created by install_os_domU.sh
8
+#
9
+# This script is responsible for cusomtizing the fresh ubuntu
10
+# image so on boot it runs the prepare_guest.sh script
11
+# that modifies the VM so it is ready to run stack.sh.
12
+# It does this by mounting the disk image of the VM.
13
+#
14
+# The resultant image is started by install_os_domU.sh,
15
+# and once the VM has shutdown, build_xva.sh is run
16
+
17
+# Exit on errors
18
+set -o errexit
19
+# Echo commands
20
+set -o xtrace
21
+
22
+# This directory
23
+TOP_DIR=$(cd $(dirname "$0") && pwd)
24
+
25
+# Include onexit commands
26
+. $TOP_DIR/scripts/on_exit.sh
27
+
28
+# Source params - override xenrc params in your localrc to suite your taste
29
+source xenrc
30
+
31
+#
32
+# Parameters
33
+#
34
+GUEST_NAME="$1"
35
+
36
+# Mount the VDI
37
+STAGING_DIR=$($TOP_DIR/scripts/manage-vdi open $GUEST_NAME 0 1 | grep -o "/tmp/tmp.[[:alnum:]]*")
38
+add_on_exit "$TOP_DIR/scripts/manage-vdi close $GUEST_NAME 0 1"
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
+# Copy prepare_guest.sh to VM
47
+mkdir -p $STAGING_DIR/opt/stack/
48
+cp $TOP_DIR/prepare_guest.sh $STAGING_DIR/opt/stack/prepare_guest.sh
49
+
50
+# backup rc.local
51
+cp $STAGING_DIR/etc/rc.local $STAGING_DIR/etc/rc.local.preparebackup
52
+
53
+# run prepare_guest.sh on boot
54
+cat <<EOF >$STAGING_DIR/etc/rc.local
55
+GUEST_PASSWORD=$GUEST_PASSWORD STAGING_DIR=/ DO_TGZ=0 bash /opt/stack/prepare_guest.sh > /opt/stack/prepare_guest.log 2>&1
56
+EOF
... ...
@@ -38,7 +38,7 @@ usage()
38 38
 cat << EOF
39 39
 
40 40
   Usage: $0 [-f FILE_PATH] [-d DISK_SIZE] [-v BRIDGE_NAME] [-m BRIDGE_NAME] [-p BRIDGE_NAME]
41
-            [-k PARAMS] [-r RAM] [-i|-c] [-w] [-b] [-l NAME_LABEL]
41
+            [-k PARAMS] [-r RAM] [-i|-c] [-w] [-b] [-l NAME_LABEL] [-t TEMPLATE_NW_INSTALL]
42 42
 
43 43
   Installs XenServer OpenStack VPX.
44 44
 
... ...
@@ -61,6 +61,7 @@ cat << EOF
61 61
      -r MiB       Specifies RAM used by the VPX, in MiB.
62 62
                   By default it will take the value from the XVA.
63 63
      -l name      Specifies the name label for the VM.
64
+     -t template  Network install an openstack domU from this template
64 65
 
65 66
   EXAMPLES:
66 67
 
... ...
@@ -88,7 +89,7 @@ EOF
88 88
 
89 89
 get_params()
90 90
 {
91
-  while getopts "hicwbf:d:v:m:p:k:r:l:" OPTION;
91
+  while getopts "hicwbf:d:v:m:p:k:r:l:t:" OPTION;
92 92
   do
93 93
     case $OPTION in
94 94
       h) usage
... ...
@@ -127,9 +128,12 @@ get_params()
127 127
       v)
128 128
          BRIDGE_V=$OPTARG
129 129
          ;;
130
-     l)
130
+      l)
131 131
          NAME_LABEL=$OPTARG
132 132
          ;;
133
+      t)
134
+         TEMPLATE_NAME=$OPTARG
135
+         ;;
133 136
       ?)
134 137
          usage
135 138
          exit
... ...
@@ -328,17 +332,11 @@ set_kernel_params()
328 328
 {
329 329
   local v="$1"
330 330
   local args=$KERNEL_PARAMS
331
-  local cmdline=$(cat /proc/cmdline)
332
-  for word in $cmdline
333
-  do
334
-    if echo "$word" | grep -q "geppetto"
335
-    then
336
-      args="$word $args"
337
-    fi
338
-  done
339 331
   if [ "$args" != "" ]
340 332
   then
341 333
     echo "Passing Geppetto args to VPX: $args."
334
+    pvargs=$(xe vm-param-get param-name=PV-args uuid="$v")
335
+    args="$pvargs $args"
342 336
     xe vm-param-set PV-args="$args" uuid="$v"
343 337
   fi
344 338
 }
... ...
@@ -422,6 +420,20 @@ then
422 422
 
423 423
   destroy_vifs "$vm_uuid"
424 424
   set_all "$vm_uuid"
425
+elif [ "$TEMPLATE_NAME" ]
426
+then
427
+  echo $TEMPLATE_NAME
428
+  vm_uuid=$(xe_min vm-install template="$TEMPLATE_NAME" new-name-label="$NAME_LABEL")
429
+  destroy_vifs "$vm_uuid"
430
+  set_auto_start "$vm_uuid"
431
+  create_gi_vif "$vm_uuid"
432
+  create_vm_vif "$vm_uuid"
433
+  create_management_vif "$vm_uuid"
434
+  create_public_vif "$vm_uuid"
435
+  set_kernel_params "$vm_uuid"
436
+  xe vm-param-set other-config:os-vpx=true uuid="$vm_uuid"
437
+  xe vm-param-set actions-after-reboot=Destroy uuid="$vm_uuid"
438
+  set_memory "$vm_uuid"
425 439
 else
426 440
   if [ ! -f "$VPX_FILE" ]
427 441
   then
428 442
new file mode 100755
... ...
@@ -0,0 +1,52 @@
0
+#!/bin/bash
1
+
2
+set -eux
3
+
4
+action="$1"
5
+vm="$2"
6
+device="${3-0}"
7
+part="${4-}"
8
+
9
+xe_min()
10
+{
11
+  local cmd="$1"
12
+  shift
13
+  xe "$cmd" --minimal "$@"
14
+}
15
+
16
+vm_uuid=$(xe_min vm-list name-label="$vm")
17
+vdi_uuid=$(xe_min vbd-list params=vdi-uuid vm-uuid="$vm_uuid" \
18
+                           userdevice="$device")
19
+
20
+dom0_uuid=$(xe_min vm-list is-control-domain=true)
21
+
22
+open_vdi()
23
+{
24
+  vbd_uuid=$(xe vbd-create vm-uuid="$dom0_uuid" vdi-uuid="$vdi_uuid" \
25
+                         device=autodetect)
26
+  mp=$(mktemp -d)
27
+  xe vbd-plug uuid="$vbd_uuid"
28
+
29
+  udevsettle
30
+  dev=$(xe_min vbd-list params=device uuid="$vbd_uuid")
31
+  mount "/dev/$dev$part" "$mp"
32
+  echo "Your vdi is mounted at $mp"
33
+}
34
+
35
+close_vdi()
36
+{
37
+  vbd_uuid=$(xe_min vbd-list vm-uuid="$dom0_uuid" vdi-uuid="$vdi_uuid")
38
+  dev=$(xe_min vbd-list params=device uuid="$vbd_uuid")
39
+  umount "/dev/$dev$part"
40
+
41
+  xe vbd-unplug uuid=$vbd_uuid
42
+  xe vbd-destroy uuid=$vbd_uuid
43
+}
44
+
45
+if [ "$action" == "open" ]
46
+then
47
+  open_vdi
48
+elif [ "$action" == "close" ]
49
+then
50
+  close_vdi
51
+fi
0 52
new file mode 100755
... ...
@@ -0,0 +1,24 @@
0
+#!/bin/bash
1
+
2
+set -e
3
+set -o xtrace
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
+}
0 24
new file mode 100755
... ...
@@ -0,0 +1,9 @@
0
+#!/bin/bash
1
+
2
+#Usage: ./templatedelete.sh <template-uuid>
3
+
4
+templateuuid="$1"
5
+
6
+xe template-param-set other-config:default_template=false uuid="$templateuuid"
7
+xe template-param-set is-a-template=false uuid="$templateuuid"
8
+xe vm-destroy uuid="$templateuuid"
... ...
@@ -17,19 +17,19 @@
17 17
 #    under the License.
18 18
 #
19 19
 
20
-remove_data=
21
-if [ "$1" = "--remove-data" ]
22
-then
23
-  remove_data=1
24
-fi
20
+set -ex
25 21
 
26
-set -eu
22
+# By default, don't remove the templates
23
+REMOVE_TEMPLATES=${REMOVE_TEMPLATES:-"false"}
24
+if [ "$1" = "--remove-templates" ]; then
25
+  REMOVE_TEMPLATES=true
26
+fi
27 27
 
28 28
 xe_min()
29 29
 {
30 30
   local cmd="$1"
31 31
   shift
32
-  /opt/xensource/bin/xe "$cmd" --minimal "$@"
32
+  xe "$cmd" --minimal "$@"
33 33
 }
34 34
 
35 35
 destroy_vdi()
... ...
@@ -39,11 +39,8 @@ destroy_vdi()
39 39
   local dev=$(xe_min vbd-list uuid=$vbd_uuid params=userdevice)
40 40
   local vdi_uuid=$(xe_min vbd-list uuid=$vbd_uuid params=vdi-uuid)
41 41
 
42
-  if [ "$type" = 'Disk' ] && [ "$dev" != 'xvda' ] && [ "$dev" != '0' ]
43
-  then
44
-    echo -n "Destroying data disk... "
42
+  if [ "$type" == 'Disk' ] && [ "$dev" != 'xvda' ] && [ "$dev" != '0' ]; then
45 43
     xe vdi-destroy uuid=$vdi_uuid
46
-    echo "done."
47 44
   fi
48 45
 }
49 46
 
... ...
@@ -52,50 +49,36 @@ uninstall()
52 52
   local vm_uuid="$1"
53 53
   local power_state=$(xe_min vm-list uuid=$vm_uuid params=power-state)
54 54
 
55
-  if [ "$power_state" != "halted" ]
56
-  then
57
-    echo -n "Shutting down VM... "
55
+  if [ "$power_state" != "halted" ]; then
58 56
     xe vm-shutdown vm=$vm_uuid force=true
59
-    echo "done."
60 57
   fi
61 58
 
62
-  if [ "$remove_data" = "1" ]
63
-  then
64
-    for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g')
65
-    do
66
-      destroy_vdi "$v"
67
-    done
68
-  fi
59
+  for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g'); do
60
+    destroy_vdi "$v"
61
+  done
69 62
 
70
-  echo -n "Deleting VM... "
71 63
   xe vm-uninstall vm=$vm_uuid force=true >/dev/null
72
-  echo "done."
73 64
 }
74 65
 
75 66
 uninstall_template()
76 67
 {
77 68
   local vm_uuid="$1"
78 69
 
79
-  if [ "$remove_data" = "1" ]
80
-  then
81
-    for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g')
82
-    do
83
-      destroy_vdi "$v"
84
-    done
85
-  fi
70
+  for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g'); do
71
+    destroy_vdi "$v"
72
+  done
86 73
 
87
-  echo -n "Deleting template... "
88 74
   xe template-uninstall template-uuid=$vm_uuid force=true >/dev/null
89
-  echo "done."
90 75
 }
91 76
 
92
-
93
-for u in $(xe_min vm-list other-config:os-vpx=true | sed -e 's/,/ /g')
94
-do
77
+# remove the VMs and their disks
78
+for u in $(xe_min vm-list other-config:os-vpx=true | sed -e 's/,/ /g'); do
95 79
   uninstall "$u"
96 80
 done
97 81
 
98
-for u in $(xe_min template-list other-config:os-vpx=true | sed -e 's/,/ /g')
99
-do
100
-  uninstall_template "$u"
101
-done
82
+# remove the templates
83
+if [ "$REMOVE_TEMPLATES" == "true" ]; then
84
+  for u in $(xe_min template-list other-config:os-vpx=true | sed -e 's/,/ /g'); do
85
+    uninstall_template "$u"
86
+  done
87
+fi
102 88
new file mode 100755
... ...
@@ -0,0 +1,63 @@
0
+#!/bin/bash
1
+## makeubuntu.sh, this creates Ubuntu server 11.10 32 and 64 bit templates
2
+## on Xenserver 6.0.2 Net install only
3
+## Original Author: David Markey <david.markey@citrix.com>
4
+## Author: Renuka Apte <renuka.apte@citrix.com>
5
+## This is not an officially supported guest OS on XenServer 6.0.2
6
+
7
+BASE_DIR=$(cd $(dirname "$0") && pwd)
8
+source $BASE_DIR/../../../localrc
9
+
10
+LENNY=$(xe template-list name-label=Debian\ Lenny\ 5.0\ \(32-bit\) --minimal)
11
+
12
+if [[ -z $LENNY ]] ; then
13
+    echo "Cant find lenny 32bit template, is this on 6.0.2?"
14
+    exit 1
15
+fi
16
+
17
+distro="Ubuntu 11.10 for DevStack"
18
+arches=("32-bit" "64-bit")
19
+
20
+preseedurl=${1:-"http://images.ansolabs.com/devstackubuntupreseed.cfg"}
21
+
22
+NETINSTALL_LOCALE=${NETINSTALL_LOCALE:-en_US}
23
+NETINSTALL_KEYBOARD=${NETINSTALL_KEYBOARD:-us}
24
+NETINSTALL_IFACE=${NETINSTALL_IFACE:-eth3}
25
+
26
+for arch in ${arches[@]} ; do
27
+    echo "Attempting $distro ($arch)"
28
+    if [[ -n $(xe template-list name-label="$distro ($arch)" params=uuid --minimal) ]] ; then
29
+        echo "$distro ($arch)" already exists, Skipping
30
+    else
31
+        if [ -z $NETINSTALLIP ]
32
+        then
33
+            echo "NETINSTALLIP not set in localrc"
34
+            exit 1
35
+        fi
36
+        # Some of these settings can be found in example preseed files
37
+        # however these need to be answered before the netinstall
38
+        # is ready to fetch the preseed file, and as such must be here
39
+        # to get a fully automated install
40
+        pvargs="-- quiet console=hvc0 partman/default_filesystem=ext3 locale=${NETINSTALL_LOCALE} console-setup/ask_detect=false keyboard-configuration/layoutcode=${NETINSTALL_KEYBOARD} netcfg/choose_interface=${NETINSTALL_IFACE} netcfg/get_hostname=os netcfg/get_domain=os auto url=${preseedurl}"
41
+        if [ "$NETINSTALLIP" != "dhcp" ]
42
+        then
43
+            netcfgargs="netcfg/disable_autoconfig=true netcfg/get_nameservers=${NAMESERVERS} netcfg/get_ipaddress=${NETINSTALLIP} netcfg/get_netmask=${NETMASK} netcfg/get_gateway=${GATEWAY} netcfg/confirm_static=true"
44
+            pvargs="${pvargs} ${netcfgargs}"
45
+        fi
46
+        NEWUUID=$(xe vm-clone uuid=$LENNY new-name-label="$distro ($arch)")
47
+        xe template-param-set uuid=$NEWUUID other-config:install-methods=http,ftp \
48
+         other-config:install-repository=http://archive.ubuntu.net/ubuntu \
49
+         PV-args="$pvargs" \
50
+         other-config:debian-release=oneiric \
51
+         other-config:default_template=true
52
+
53
+        if [[ "$arch" == "32-bit" ]] ; then
54
+            xe template-param-set uuid=$NEWUUID other-config:install-arch="i386"
55
+        else
56
+            xe template-param-set uuid=$NEWUUID other-config:install-arch="amd64"
57
+        fi
58
+        echo "Success"
59
+    fi
60
+done
61
+
62
+echo "Done"
... ...
@@ -1,16 +1,19 @@
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
+OSDOMU_MEM_MB=1024
8 9
 
9 10
 # VM Password
10 11
 GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
11 12
 
12
-# Host Interface, i.e. the public facing interface on the nova vm
13
-HOST_IP_IFACE=${HOST_IP_IFACE:-eth0}
13
+# Host Interface, i.e. the interface on the nova vm you want to expose the services on
14
+# Usually either eth2 (management network) or eth3 (public network)
15
+# not eth0 (private network with XenServer host) or eth1 (VM traffic network)
16
+HOST_IP_IFACE=${HOST_IP_IFACE:-eth3}
14 17
 
15 18
 # Our nova host's network info
16 19
 VM_IP=${VM_IP:-10.255.255.255} # A host-only ip that let's the interface come up, otherwise unused
... ...
@@ -35,11 +38,5 @@ 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 }
43
-
44 38
 # Source params
45 39
 cd ../.. && source ./stackrc && cd $TOP_DIR