Browse code

Merge branch 'master' into instances-path

Conflicts:
stack.sh

Vishvananda Ishaya authored on 2011/10/29 04:28:30
Showing 16 changed files
... ...
@@ -1,5 +1,6 @@
1 1
 dnsmasq-base
2 2
 kpartx
3
+parted
3 4
 mysql-server
4 5
 python-mysqldb
5 6
 kvm
... ...
@@ -81,6 +81,15 @@ DEST=${DEST:-/opt/stack}
81 81
 # Configure services to syslog instead of writing to individual log files
82 82
 SYSLOG=${SYSLOG:-False}
83 83
 
84
+# apt-get wrapper to just get arguments set correctly
85
+function apt_get() {
86
+    local sudo="sudo"
87
+    [ "$(id -u)" = "0" ] && sudo="env"
88
+    $sudo DEBIAN_FRONTEND=noninteractive apt-get \
89
+        --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
90
+}
91
+
92
+
84 93
 # OpenStack is designed to be run as a regular user (Dashboard will fail to run
85 94
 # as root, since apache refused to startup serve content from root user).  If
86 95
 # stack.sh is run as root, it automatically creates a stack user with
... ...
@@ -125,9 +134,12 @@ else
125 125
     # Natty uec images sudoers does not have a '#includedir'. add one.
126 126
     sudo grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||
127 127
         echo "#includedir /etc/sudoers.d" | sudo tee -a /etc/sudoers
128
-    sudo cp $FILES/sudo/nova /etc/sudoers.d/stack_sh_nova
129
-    sudo sed -e "s,%USER%,$USER,g" -i /etc/sudoers.d/stack_sh_nova
130
-    sudo chmod 0440 /etc/sudoers.d/stack_sh_nova
128
+    TEMPFILE=`mktemp`
129
+    cat $FILES/sudo/nova > $TEMPFILE
130
+    sed -e "s,%USER%,$USER,g" -i $TEMPFILE
131
+    chmod 0440 $TEMPFILE
132
+    sudo chown root:root $TEMPFILE
133
+    sudo mv $TEMPFILE /etc/sudoers.d/stack_sh_nova
131 134
 fi
132 135
 
133 136
 # Set the destination directories for openstack projects
... ...
@@ -142,9 +154,10 @@ NOVNC_DIR=$DEST/noVNC
142 142
 # Specify which services to launch.  These generally correspond to screen tabs
143 143
 ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,dash,mysql,rabbit}
144 144
 
145
-# Nova hypervisor configuration.  We default to **kvm** but will drop back to
146
-# **qemu** if we are unable to load the kvm module.  Stack.sh can also install
147
-# an **LXC** based system.
145
+# Nova hypervisor configuration.  We default to libvirt whth  **kvm** but will
146
+# drop back to **qemu** if we are unable to load the kvm module.  Stack.sh can
147
+# also install an **LXC** based system.
148
+VIRT_DRIVER=${VIRT_DRIVER:-libvirt}
148 149
 LIBVIRT_TYPE=${LIBVIRT_TYPE:-kvm}
149 150
 
150 151
 # nova supports pluggable schedulers.  ``SimpleScheduler`` should work in most
... ...
@@ -156,14 +169,6 @@ if [ ! -n "$HOST_IP" ]; then
156 156
     HOST_IP=`LC_ALL=C /sbin/ifconfig  | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
157 157
 fi
158 158
 
159
-# apt-get wrapper to just get arguments set correctly
160
-function apt_get() {
161
-    local sudo="sudo"
162
-    [ "$(id -u)" = "0" ] && sudo=""
163
-    $sudo DEBIAN_FRONTEND=noninteractive apt-get \
164
-        --option "Dpkg::Options::=--force-confold" --assume-yes "$@"
165
-}
166
-
167 159
 # Generic helper to configure passwords
168 160
 function read_password {
169 161
     set +o xtrace
... ...
@@ -210,7 +215,7 @@ function read_password {
210 210
 PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-eth0}
211 211
 FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24}
212 212
 FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256}
213
-FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.1/28}
213
+FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.224/28}
214 214
 NET_MAN=${NET_MAN:-FlatDHCPManager}
215 215
 EC2_DMZ_HOST=${EC2_DMZ_HOST:-$HOST_IP}
216 216
 FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-br100}
... ...
@@ -457,6 +462,7 @@ if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
457 457
     sudo cp $FILES/000-default.template /etc/apache2/sites-enabled/000-default
458 458
     sudo sed -e "s,%USER%,$USER,g" -i /etc/apache2/sites-enabled/000-default
459 459
     sudo sed -e "s,%DASH_DIR%,$DASH_DIR,g" -i /etc/apache2/sites-enabled/000-default
460
+    sudo service apache2 restart
460 461
 fi
461 462
 
462 463
 
... ...
@@ -624,13 +630,8 @@ add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST"
624 624
 add_nova_flag "--rabbit_host=$RABBIT_HOST"
625 625
 add_nova_flag "--rabbit_password=$RABBIT_PASSWORD"
626 626
 add_nova_flag "--glance_api_servers=$GLANCE_HOSTPORT"
627
-add_nova_flag "--flat_network_bridge=$FLAT_NETWORK_BRIDGE"
628 627
 if [ -n "$INSTANCES_PATH" ]; then
629 628
     add_nova_flag "--instances_path=$INSTANCES_PATH"
630
-fi
631
-if [ -n "$FLAT_INTERFACE" ]; then
632
-    add_nova_flag "--flat_interface=$FLAT_INTERFACE"
633
-fi
634 629
 if [ -n "$MULTI_HOST" ]; then
635 630
     add_nova_flag "--multi_host=$MULTI_HOST"
636 631
     add_nova_flag "--send_arp_for_ha=1"
... ...
@@ -639,6 +640,26 @@ if [ "$SYSLOG" != "False" ]; then
639 639
     add_nova_flag "--use_syslog=1"
640 640
 fi
641 641
 
642
+# XenServer
643
+# ---------
644
+
645
+if [ "$VIRT_DRIVER" = 'xenserver' ]; then
646
+    read_password XENAPI_PASSWORD "ENTER A PASSWORD TO USE FOR XEN."
647
+    add_nova_flag "--connection_type=xenapi"
648
+    add_nova_flag "--xenapi_connection_url=http://169.254.0.1"
649
+    add_nova_flag "--xenapi_connection_username=root"
650
+    add_nova_flag "--xenapi_connection_password=$XENAPI_PASSWORD"
651
+    add_nova_flag "--flat_injected=False"
652
+    add_nova_flag "--flat_interface=eth1"
653
+    add_nova_flag "--flat_network_bridge=xenbr1"
654
+    add_nova_flag "--public_interface=eth3"
655
+else
656
+    add_nova_flag "--flat_network_bridge=$FLAT_NETWORK_BRIDGE"
657
+    if [ -n "$FLAT_INTERFACE" ]; then
658
+        add_nova_flag "--flat_interface=$FLAT_INTERFACE"
659
+    fi
660
+fi
661
+
642 662
 # Nova Database
643 663
 # ~~~~~~~~~~~~~
644 664
 
... ...
@@ -750,7 +771,7 @@ screen_it n-vol "cd $NOVA_DIR && $NOVA_DIR/bin/nova-volume"
750 750
 screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network"
751 751
 screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler"
752 752
 screen_it n-vnc "cd $NOVNC_DIR && ./utils/nova-wsproxy.py 6080 --web . --flagfile=../nova/bin/nova.conf"
753
-screen_it dash "cd $DASH_DIR && sudo /etc/init.d/apache2 restart; sudo tail -f /var/log/apache2/error.log"
753
+screen_it dash "cd $DASH_DIR && sudo tail -f /var/log/apache2/error.log"
754 754
 
755 755
 # Install Images
756 756
 # ==============
... ...
@@ -772,6 +793,20 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
772 772
     # Create a directory for the downloaded image tarballs.
773 773
     mkdir -p $FILES/images
774 774
 
775
+    # Option to upload legacy ami-tty, which works with xenserver
776
+    if [ $UPLOAD_LEGACY_TTY ]; then
777
+        if [ ! -f $FILES/tty.tgz ]; then
778
+            wget -c http://images.ansolabs.com/tty.tgz -O $FILES/tty.tgz
779
+        fi
780
+
781
+        tar -zxf $FILES/tty.tgz -C $FILES/images
782
+        RVAL=`glance add -A $SERVICE_TOKEN name="tty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/aki-tty/image`
783
+        KERNEL_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
784
+        RVAL=`glance add -A $SERVICE_TOKEN name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < $FILES/images/ari-tty/image`
785
+        RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "`
786
+        glance add -A $SERVICE_TOKEN name="tty" is_public=true container_format=ami disk_format=ami kernel_id=$KERNEL_ID ramdisk_id=$RAMDISK_ID < $FILES/images/ami-tty/image
787
+    fi
788
+
775 789
     for image_url in ${IMAGE_URLS//,/ }; do
776 790
         # Downloads the image (uec ami+aki style), then extracts it.
777 791
         IMAGE_FNAME=`basename "$image_url"`
... ...
@@ -341,7 +341,14 @@ chroot $ROOTFS chown -R stack $DEST
341 341
 # Change boot params so that we get a console log
342 342
 sudo sed -e "s/quiet splash/splash console=ttyS0 console=ttyS1,19200n8/g" -i $ROOTFS/boot/grub/menu.lst
343 343
 sudo sed -e "s/^hiddenmenu//g" -i $ROOTFS/boot/grub/menu.lst
344
-#chroot $ROOTFS grub-install /dev/vda
344
+
345
+# Set the hostname
346
+echo $GUEST_NAME > $ROOTFS/etc/hostname
347
+
348
+# We need the hostname to resolve for rabbit to launch
349
+if ! grep -q $GUEST_NAME $ROOTFS/etc/hosts; then
350
+    echo "$GUEST_IP $GUEST_NAME" >> $ROOTFS/etc/hosts
351
+fi
345 352
 
346 353
 # Unmount
347 354
 umount $ROOTFS || echo 'ok'
348 355
new file mode 100644
... ...
@@ -0,0 +1,64 @@
0
+Getting Started With XenServer 5.6 and Devstack
1
+===============================================
2
+The purpose of the code in this directory it to help developers bootstrap
3
+a XenServer 5.6 + Openstack development environment.  This file gives
4
+some pointers on how to get started.
5
+
6
+Step 1: Install Xenserver
7
+------------------------
8
+Install XenServer 5.6 on a clean box. You can get XenServer by signing
9
+up for an account on citrix.com, and then visiting:
10
+https://www.citrix.com/English/ss/downloads/details.asp?downloadId=2311504&productId=683148
11
+
12
+Here are some sample Xenserver network settings for when you are just
13
+getting started (I use settings like this with a lappy + cheap wifi router):
14
+
15
+* XenServer Host IP: 192.168.1.10
16
+* XenServer Netmask: 255.255.255.0
17
+* XenServer Gateway: 192.168.1.1
18
+* XenServer DNS: 192.168.1.1
19
+
20
+Step 2: Prepare DOM0
21
+-------------------
22
+At this point, your server is missing some critical software that you will
23
+need to run devstack (like git).  Do this to install required software:
24
+
25
+    wget --no-check-certificate https://github.com/cloudbuilders/devstack/raw/xen/tools/xen/prepare_dom0.sh
26
+    chmod 755 prepare_dom0.sh
27
+    ./prepare_dom0.sh 
28
+
29
+This script will also clone devstack in /root/devstack
30
+
31
+Step 3: Configure your localrc
32
+-----------------------------
33
+Devstack uses a localrc for user-specific configuration.  Note that 
34
+the XENAPI_PASSWORD must be your dom0 root password.
35
+Of course, use real passwords if this machine is exposed.
36
+
37
+    cat > /root/devstack/localrc <<EOF
38
+    MYSQL_PASSWORD=my_super_secret
39
+    SERVICE_TOKEN=my_super_secret
40
+    ADMIN_PASSWORD=my_super_secret
41
+    RABBIT_PASSWORD=my_super_secret
42
+    # This is the password for your guest (for both stack and root users)
43
+    GUEST_PASSWORD=my_super_secret
44
+    # IMPORTANT: The following must be set to your dom0 root password!
45
+    XENAPI_PASSWORD=my_super_secret
46
+    # Do not download the usual images yet!
47
+    IMAGE_URLS=""
48
+    EOF
49
+
50
+Step 4: Run ./build_domU.sh
51
+--------------------------
52
+This script does a lot of stuff, it is probably best to read it in its entirety.
53
+But in a nutshell, it performs the following:
54
+
55
+* Configures bridges and vlans for public, private, and management nets
56
+* Creates and installs a OpenStack all-in-one domU in an HA-FlatDHCP configuration
57
+* A script to create a multi-domU (ie. head node separated from compute) configuration is coming soon!
58
+
59
+Step 5: Do cloudy stuff!
60
+--------------------------
61
+* Play with dashboard
62
+* Play with the CLI
63
+* Log bugs to devstack and core projects, and submit fixes!
0 64
new file mode 100755
... ...
@@ -0,0 +1,294 @@
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
+# Echo commands
10
+set -o xtrace
11
+
12
+# Name of this guest
13
+GUEST_NAME=${GUEST_NAME:-ALLINONE}
14
+
15
+# dom0 ip
16
+HOST_IP=${HOST_IP:-`ifconfig xenbr0 | grep "inet addr" | cut -d ":" -f2 | sed "s/ .*//"`}
17
+
18
+# Our nova host's network info 
19
+VM_IP=${VM_IP:-10.255.255.255} # A host-only ip that let's the interface come up, otherwise unused
20
+MGT_IP=${MGT_IP:-172.16.100.55}
21
+PUB_IP=${PUB_IP:-192.168.1.55}
22
+
23
+# Public network
24
+PUB_BR=${PUB_BR:-xenbr0}
25
+PUB_NETMASK=${PUB_NETMASK:-255.255.255.0}
26
+
27
+# VM network params
28
+VM_NETMASK=${VM_NETMASK:-255.255.255.0}
29
+VM_BR=${VM_BR:-xenbr1}
30
+VM_VLAN=${VM_VLAN:-100}
31
+
32
+# MGMT network params
33
+MGT_NETMASK=${MGT_NETMASK:-255.255.255.0}
34
+MGT_BR=${MGT_BR:-xenbr2}
35
+MGT_VLAN=${MGT_VLAN:-101}
36
+
37
+# VM Password
38
+GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
39
+
40
+# Size of image
41
+VDI_MB=${VDI_MB:-2500}
42
+
43
+# This directory
44
+TOP_DIR=$(cd $(dirname "$0") && pwd)
45
+
46
+# Make sure we have git
47
+if ! which git; then
48
+    GITDIR=/tmp/git-1.7.7
49
+    cd /tmp
50
+    rm -rf $GITDIR*
51
+    wget http://git-core.googlecode.com/files/git-1.7.7.tar.gz
52
+    tar xfv git-1.7.7.tar.gz
53
+    cd $GITDIR
54
+    ./configure
55
+    make install
56
+    cd $TOP_DIR
57
+fi
58
+
59
+# Helper to create networks
60
+function create_network() {
61
+    if ! xe network-list | grep bridge | grep -q $1; then
62
+        echo "Creating bridge $1"
63
+        xe network-create name-label=$1
64
+    fi
65
+}
66
+
67
+# Create host, vm, mgmt, pub networks
68
+create_network xapi0
69
+create_network $VM_BR
70
+create_network $MGT_BR
71
+create_network $PUB_BR
72
+
73
+# Get the uuid for our physical (public) interface
74
+PIF=`xe pif-list --minimal device=eth0`
75
+
76
+# Create networks/bridges for vm and management
77
+VM_NET=`xe network-list --minimal bridge=$VM_BR`
78
+MGT_NET=`xe network-list --minimal bridge=$MGT_BR`
79
+
80
+# Helper to create vlans
81
+function create_vlan() {
82
+    pif=$1
83
+    vlan=$2
84
+    net=$3
85
+    if ! xe vlan-list | grep tag | grep -q $vlan; then
86
+        xe vlan-create pif-uuid=$pif vlan=$vlan network-uuid=$net
87
+    fi
88
+}
89
+
90
+# Create vlans for vm and management
91
+create_vlan $PIF $VM_VLAN $VM_NET
92
+create_vlan $PIF $MGT_VLAN $MGT_NET
93
+
94
+# Setup host-only nat rules
95
+HOST_NET=169.254.0.0/16
96
+if ! iptables -L -v -t nat | grep -q $HOST_NET; then
97
+    iptables -t nat -A POSTROUTING -s $HOST_NET -j SNAT --to-source $HOST_IP
98
+    iptables -I FORWARD 1 -s $HOST_NET -j ACCEPT
99
+    /etc/init.d/iptables save
100
+fi
101
+
102
+# Set up ip forwarding
103
+if ! grep -q "FORWARD_IPV4=YES" /etc/sysconfig/network; then
104
+    # FIXME: This doesn't work on reboot!
105
+    echo "FORWARD_IPV4=YES" >> /etc/sysconfig/network
106
+fi
107
+
108
+# Also, enable ip forwarding in rc.local, since the above trick isn't working
109
+if ! grep -q  "echo 1 >/proc/sys/net/ipv4/ip_forward" /etc/rc.local; then
110
+    echo "echo 1 >/proc/sys/net/ipv4/ip_forward" >> /etc/rc.local
111
+fi
112
+
113
+# Enable ip forwarding at runtime as well
114
+echo 1 > /proc/sys/net/ipv4/ip_forward
115
+
116
+# Directory where we stage the build
117
+STAGING_DIR=$TOP_DIR/stage
118
+
119
+# Option to clean out old stuff
120
+CLEAN=${CLEAN:-0}
121
+if [ "$CLEAN" = "1" ]; then
122
+    rm -rf $STAGING_DIR
123
+fi
124
+
125
+# Download our base image.  This image is made using prepare_guest.sh
126
+BASE_IMAGE_URL=${BASE_IMAGE_URL:-http://images.ansolabs.com/xen/stage.tgz}
127
+if [ ! -e $STAGING_DIR ]; then
128
+    if [ ! -e /tmp/stage.tgz ]; then
129
+        wget $BASE_IMAGE_URL -O /tmp/stage.tgz
130
+    fi
131
+    tar xfz /tmp/stage.tgz
132
+    cd $TOP_DIR
133
+fi
134
+
135
+# Free up precious disk space
136
+rm -f /tmp/stage.tgz
137
+
138
+# Make sure we have a stage
139
+if [ ! -d $STAGING_DIR/etc ]; then
140
+    echo "Stage is not properly set up!"
141
+    exit 1
142
+fi
143
+
144
+# Directory where our conf files are stored
145
+FILES_DIR=$TOP_DIR/files
146
+TEMPLATES_DIR=$TOP_DIR/templates
147
+
148
+# Directory for supporting script files
149
+SCRIPT_DIR=$TOP_DIR/scripts
150
+
151
+# Version of ubuntu with which we are working
152
+UBUNTU_VERSION=`cat $STAGING_DIR/etc/lsb-release | grep "DISTRIB_CODENAME=" | sed "s/DISTRIB_CODENAME=//"`
153
+KERNEL_VERSION=`ls $STAGING_DIR/boot/vmlinuz* | head -1 | sed "s/.*vmlinuz-//"`
154
+
155
+# Setup fake grub
156
+rm -rf $STAGING_DIR/boot/grub/
157
+mkdir -p $STAGING_DIR/boot/grub/
158
+cp $TEMPLATES_DIR/menu.lst.in $STAGING_DIR/boot/grub/menu.lst
159
+sed -e "s,@KERNEL_VERSION@,$KERNEL_VERSION,g" -i $STAGING_DIR/boot/grub/menu.lst
160
+
161
+# Setup fstab, tty, and other system stuff
162
+cp $FILES_DIR/fstab $STAGING_DIR/etc/fstab
163
+cp $FILES_DIR/hvc0.conf $STAGING_DIR/etc/init/
164
+
165
+# Put the VPX into UTC.
166
+rm -f $STAGING_DIR/etc/localtime
167
+
168
+# Configure dns (use same dns as dom0)
169
+cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
170
+
171
+# Copy over devstack
172
+rm -f /tmp/devstack.tar
173
+tar --exclude='stage' --exclude='xen/xvas' --exclude='xen/nova' -cvf /tmp/devstack.tar $TOP_DIR/../../../devstack
174
+cd $STAGING_DIR/opt/stack/
175
+tar xf /tmp/devstack.tar
176
+cd $TOP_DIR
177
+
178
+# Configure OVA
179
+VDI_SIZE=$(($VDI_MB*1024*1024))
180
+PRODUCT_BRAND=${PRODUCT_BRAND:-openstack}
181
+PRODUCT_VERSION=${PRODUCT_VERSION:-001}
182
+BUILD_NUMBER=${BUILD_NUMBER:-001}
183
+LABEL="$PRODUCT_BRAND $PRODUCT_VERSION-$BUILD_NUMBER"
184
+OVA=$STAGING_DIR/tmp/ova.xml
185
+cp $TEMPLATES_DIR/ova.xml.in  $OVA
186
+sed -e "s,@VDI_SIZE@,$VDI_SIZE,g" -i $OVA
187
+sed -e "s,@PRODUCT_BRAND@,$PRODUCT_BRAND,g" -i $OVA
188
+sed -e "s,@PRODUCT_VERSION@,$PRODUCT_VERSION,g" -i $OVA
189
+sed -e "s,@BUILD_NUMBER@,$BUILD_NUMBER,g" -i $OVA
190
+
191
+# Directory for xvas
192
+XVA_DIR=$TOP_DIR/xvas
193
+
194
+# Create xva dir
195
+mkdir -p $XVA_DIR
196
+
197
+# Clean nova if desired
198
+if [ "$CLEAN" = "1" ]; then
199
+    rm -rf $TOP_DIR/nova
200
+fi
201
+
202
+# Checkout nova
203
+if [ ! -d $TOP_DIR/nova ]; then
204
+    git clone git://github.com/cloudbuilders/nova.git
205
+    git checkout diablo
206
+fi 
207
+
208
+# Run devstack on launch
209
+cat <<EOF >$STAGING_DIR/etc/rc.local
210
+GUEST_PASSWORD=$GUEST_PASSWORD STAGING_DIR=/ DO_TGZ=0 bash /opt/stack/devstack/tools/xen/prepare_guest.sh
211
+su -c "/opt/stack/run.sh > /opt/stack/run.sh.log" stack
212
+exit 0
213
+EOF
214
+
215
+# Install plugins
216
+cp -pr $TOP_DIR/nova/plugins/xenserver/xenapi/etc/xapi.d /etc/
217
+chmod a+x /etc/xapi.d/plugins/*
218
+yum --enablerepo=base install -y parted
219
+mkdir -p /boot/guest
220
+
221
+# Set local storage il8n
222
+SR_UUID=`xe sr-list --minimal name-label="Local storage"`
223
+xe sr-param-set uuid=$SR_UUID other-config:i18n-key=local-storage
224
+
225
+# Uninstall previous runs
226
+xe vm-list --minimal name-label="$LABEL" | xargs ./scripts/uninstall-os-vpx.sh
227
+
228
+# Destroy any instances that were launched
229
+for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do
230
+    echo "Shutting down nova instance $uuid"
231
+    xe vm-shutdown uuid=$uuid
232
+    xe vm-destroy uuid=$uuid
233
+done
234
+
235
+# Path to head xva.  By default keep overwriting the same one to save space
236
+USE_SEPARATE_XVAS=${USE_SEPARATE_XVAS:-0}
237
+if [ "$USE_SEPARATE_XVAS" = "0" ]; then
238
+    XVA=$XVA_DIR/$UBUNTU_VERSION.xva 
239
+else
240
+    XVA=$XVA_DIR/$UBUNTU_VERSION.$GUEST_NAME.xva 
241
+fi
242
+
243
+# Clean old xva. In the future may not do this every time.
244
+rm -f $XVA
245
+
246
+# Configure the hostname
247
+echo $GUEST_NAME > $STAGING_DIR/etc/hostname
248
+
249
+# Hostname must resolve for rabbit
250
+cat <<EOF >$STAGING_DIR/etc/hosts
251
+$MGT_IP $GUEST_NAME
252
+127.0.0.1 localhost localhost.localdomain
253
+EOF
254
+
255
+# Configure the network
256
+INTERFACES=$STAGING_DIR/etc/network/interfaces
257
+cp $TEMPLATES_DIR/interfaces.in  $INTERFACES
258
+sed -e "s,@ETH1_IP@,$VM_IP,g" -i $INTERFACES
259
+sed -e "s,@ETH1_NETMASK@,$VM_NETMASK,g" -i $INTERFACES
260
+sed -e "s,@ETH2_IP@,$MGT_IP,g" -i $INTERFACES
261
+sed -e "s,@ETH2_NETMASK@,$MGT_NETMASK,g" -i $INTERFACES
262
+sed -e "s,@ETH3_IP@,$PUB_IP,g" -i $INTERFACES
263
+sed -e "s,@ETH3_NETMASK@,$PUB_NETMASK,g" -i $INTERFACES
264
+
265
+# Configure run.sh
266
+cat <<EOF >$STAGING_DIR/opt/stack/run.sh
267
+#!/bin/bash
268
+cd /opt/stack/devstack
269
+killall screen
270
+UPLOAD_LEGACY_TTY=yes HOST_IP=$PUB_IP VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST=1 $STACKSH_PARAMS ./stack.sh
271
+EOF
272
+chmod 755 $STAGING_DIR/opt/stack/run.sh
273
+
274
+# Create xva
275
+if [ ! -e $XVA ]; then
276
+    rm -rf /tmp/mkxva*
277
+    UID=0 $SCRIPT_DIR/mkxva -o $XVA -t xva -x $OVA $STAGING_DIR $VDI_MB /tmp/
278
+fi
279
+
280
+# Start guest
281
+$TOP_DIR/scripts/install-os-vpx.sh -f $XVA -v $VM_BR -m $MGT_BR -p $PUB_BR
282
+
283
+echo "################################################################################"
284
+echo ""
285
+echo "All Finished!"
286
+echo "Now, you can monitor the progress of the stack.sh installation by "
287
+echo "tailing /opt/stack/run.sh.log from within your domU."
288
+echo ""
289
+echo "ssh into your domU now: 'ssh stack@$PUB_IP' using your password"
290
+echo "and then do: 'tail -f /opt/stack/run.sh.log'"
291
+echo ""
292
+echo "When the script completes, you can then visit the OpenStack Dashboard"
293
+echo "at http://$PUB_IP, and contact other services at the usual ports."
0 294
new file mode 100644
... ...
@@ -0,0 +1,5 @@
0
+LABEL=vpxroot           /                       ext3    defaults        1 1
1
+tmpfs                   /dev/shm                tmpfs   defaults        0 0
2
+devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
3
+sysfs                   /sys                    sysfs   defaults        0 0
4
+proc                    /proc                   proc    defaults        0 0
0 5
new file mode 100644
... ...
@@ -0,0 +1,10 @@
0
+# hvc0 - getty
1
+#
2
+# This service maintains a getty on hvc0 from the point the system is
3
+# started until it is shut down again.
4
+
5
+start on stopped rc RUNLEVEL=[2345]
6
+stop on runlevel [!2345]
7
+
8
+respawn
9
+exec /sbin/getty -8 9600 hvc0
0 10
new file mode 100755
... ...
@@ -0,0 +1,41 @@
0
+#!/bin/sh
1
+set -o xtrace
2
+set -o errexit
3
+
4
+# Install basics for vi and git
5
+yum -y  --enablerepo=base install gcc make vim-enhanced zlib-devel openssl-devel
6
+
7
+# Simple but usable vimrc
8
+if [ ! -e /root/.vimrc ]; then
9
+    cat > /root/.vimrc <<EOF
10
+syntax on
11
+se ts=4
12
+se expandtab
13
+se shiftwidth=4
14
+EOF
15
+fi
16
+
17
+# Use the pretty vim
18
+if [ -e /usr/bin/vim ]; then
19
+    rm /bin/vi
20
+    ln -s /usr/bin/vim /bin/vi
21
+fi
22
+
23
+# Install git 
24
+if ! which git; then
25
+    DEST=/tmp/
26
+    GITDIR=$DEST/git-1.7.7
27
+    cd $DEST
28
+    rm -rf $GITDIR*
29
+    wget http://git-core.googlecode.com/files/git-1.7.7.tar.gz
30
+    tar xfv git-1.7.7.tar.gz
31
+    cd $GITDIR
32
+    ./configure
33
+    make install
34
+fi
35
+
36
+# Clone devstack
37
+DEVSTACK=/root/devstack
38
+if [ ! -d $DEVSTACK ]; then
39
+    git clone git://github.com/cloudbuilders/devstack.git $DEVSTACK
40
+fi
0 41
new file mode 100644
... ...
@@ -0,0 +1,88 @@
0
+#!/bin/bash
1
+
2
+# Configurable nuggets
3
+GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
4
+STAGING_DIR=${STAGING_DIR:-stage}
5
+DO_TGZ=${DO_TGZ:-1}
6
+KERNEL_VERSION=3.0.0-12-virtual
7
+
8
+# Debootstrap base system
9
+if [ ! -d $STAGING_DIR ]; then
10
+    apt-get install debootstrap
11
+    debootstrap --arch amd64 oneiric $STAGING_DIR http://us.archive.ubuntu.com/ubuntu/
12
+fi
13
+
14
+# Sources.list
15
+cat <<EOF >$STAGING_DIR/etc/apt/sources.list
16
+deb http://us.archive.ubuntu.com/ubuntu/ oneiric main restricted
17
+deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric main restricted
18
+deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates main restricted
19
+deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric-updates main restricted
20
+deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe
21
+deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates universe
22
+deb http://us.archive.ubuntu.com/ubuntu/ oneiric multiverse
23
+deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates multiverse
24
+EOF
25
+
26
+# Install basics
27
+chroot $STAGING_DIR apt-get update
28
+chroot $STAGING_DIR apt-get install -y linux-image-$KERNEL_VERSION
29
+chroot $STAGING_DIR apt-get install -y cracklib-runtime curl wget ssh openssh-server tcpdump ethtool
30
+chroot $STAGING_DIR apt-get install -y curl wget ssh openssh-server python-pip git vim-nox sudo
31
+chroot $STAGING_DIR pip install xenapi
32
+
33
+# Install guest utilities
34
+XEGUEST=xe-guest-utilities_5.6.100-651_amd64.deb
35
+wget http://images.ansolabs.com/xen/$XEGUEST -O $XEGUEST
36
+cp $XEGUEST $STAGING_DIR/root
37
+chroot $STAGING_DIR dpkg -i /root/$XEGUEST
38
+chroot $STAGING_DIR update-rc.d -f xe-linux-distribution remove
39
+chroot $STAGING_DIR update-rc.d xe-linux-distribution defaults
40
+
41
+# Make a small cracklib dictionary, so that passwd still works, but we don't
42
+# have the big dictionary.
43
+mkdir -p $STAGING_DIR/usr/share/cracklib
44
+echo a | chroot $STAGING_DIR cracklib-packer
45
+
46
+# Make /etc/shadow, and set the root password
47
+chroot $STAGING_DIR "pwconv"
48
+echo "root:$GUEST_PASSWORD" | chroot $STAGING_DIR chpasswd
49
+
50
+# Put the VPX into UTC.
51
+rm -f $STAGING_DIR/etc/localtime
52
+
53
+# Add stack user
54
+chroot $STAGING_DIR groupadd libvirtd
55
+chroot $STAGING_DIR useradd stack -s /bin/bash -d /opt/stack -G libvirtd
56
+echo stack:$GUEST_PASSWORD | chroot $STAGING_DIR chpasswd
57
+echo "stack ALL=(ALL) NOPASSWD: ALL" >> $STAGING_DIR/etc/sudoers
58
+
59
+# Give ownership of /opt/stack to stack user
60
+chroot $STAGING_DIR chown -R stack /opt/stack
61
+
62
+# Make our ip address hostnames look nice at the command prompt
63
+echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $STAGING_DIR/opt/stack/.bashrc
64
+echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $STAGING_DIR/root/.bashrc
65
+echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $STAGING_DIR/etc/profile
66
+
67
+function setup_vimrc {
68
+    if [ ! -e $1 ]; then
69
+        # Simple but usable vimrc
70
+        cat > $1 <<EOF
71
+syntax on
72
+se ts=4
73
+se expandtab
74
+se shiftwidth=4
75
+EOF
76
+    fi
77
+}
78
+
79
+# Setup simple .vimrcs
80
+setup_vimrc $STAGING_DIR/root/.vimrc
81
+setup_vimrc $STAGING_DIR/opt/stack/.vimrc
82
+
83
+if [ "$DO_TGZ" = "1" ]; then
84
+    # Compress
85
+    rm -f stage.tgz
86
+    tar cfz stage.tgz stage
87
+fi
0 88
new file mode 100755
... ...
@@ -0,0 +1,507 @@
0
+#!/bin/bash
1
+#
2
+# Copyright (c) 2011 Citrix Systems, Inc.
3
+# Copyright 2011 OpenStack LLC.
4
+# All Rights Reserved.
5
+#
6
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+#    not use this file except in compliance with the License. You may obtain
8
+#    a copy of the License at
9
+#
10
+#         http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+#    Unless required by applicable law or agreed to in writing, software
13
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+#    License for the specific language governing permissions and limitations
16
+#    under the License.
17
+#
18
+
19
+set -eux
20
+
21
+. /etc/xensource-inventory
22
+
23
+NAME="XenServer OpenStack VPX"
24
+DATA_VDI_SIZE="500MiB"
25
+BRIDGE_M=
26
+BRIDGE_P=
27
+KERNEL_PARAMS=
28
+VPX_FILE=os-vpx.xva
29
+AS_TEMPLATE=
30
+FROM_TEMPLATE=
31
+RAM=
32
+WAIT_FOR_NETWORK=
33
+BALLOONING=
34
+
35
+usage()
36
+{
37
+cat << EOF
38
+
39
+  Usage: $0 [-f FILE_PATH] [-d DISK_SIZE] [-v BRIDGE_NAME] [-m BRIDGE_NAME] [-p BRIDGE_NAME]
40
+            [-k PARAMS] [-r RAM] [-i|-c] [-w] [-b]
41
+
42
+  Installs XenServer OpenStack VPX.
43
+
44
+  OPTIONS:
45
+
46
+     -h           Shows this message.
47
+     -i           Install OpenStack VPX as template.
48
+     -c           Clone from existing template.
49
+     -w           Wait for the network settings to show up before exiting.
50
+     -b           Enable memory ballooning. When set min_RAM=RAM/2 max_RAM=RAM.
51
+     -f path      Specifies the path to the XVA.
52
+                  Default to ./os-vpx.xva.
53
+     -d disk-size Specifies the size in MiB for the data disk.
54
+                  Defaults to 500 MiB.
55
+     -m bridge    Specifies the bridge for the isolated management network.
56
+                  Defaults to xenbr0.
57
+     -v bridge    Specifies the bridge for the vm network
58
+     -p bridge    Specifies the bridge for the externally facing network.
59
+     -k params    Specifies kernel parameters.
60
+     -r MiB       Specifies RAM used by the VPX, in MiB.
61
+                  By default it will take the value from the XVA.
62
+
63
+  EXAMPLES:
64
+
65
+     Create a VPX that connects to the isolated management network using the
66
+     default bridge with a data disk of 1GiB:
67
+            install-os-vpx.sh -f /root/os-vpx-devel.xva -d 1024
68
+
69
+     Create a VPX that connects to the isolated management network using xenbr1
70
+     as bridge:
71
+            install-os-vpx.sh -m xenbr1
72
+
73
+     Create a VPX that connects to both the management and public networks
74
+     using xenbr1 and xapi4 as bridges:
75
+            install-os-vpx.sh -m xenbr1 -p xapi4
76
+
77
+     Create a VPX that connects to both the management and public networks
78
+     using the default for management traffic:
79
+            install-os-vpx.sh -m xapi4
80
+
81
+     Create a VPX that automatically becomes the master:
82
+            install-os-vpx.sh -k geppetto_master=true
83
+
84
+EOF
85
+}
86
+
87
+get_params()
88
+{
89
+  while getopts "hicwbf:d:v:m:p:k:r:" OPTION; 
90
+  do
91
+    case $OPTION in
92
+      h) usage
93
+         exit 1
94
+         ;;
95
+      i)
96
+         AS_TEMPLATE=1
97
+         ;;
98
+      c)
99
+         FROM_TEMPLATE=1
100
+         ;;
101
+      w)
102
+         WAIT_FOR_NETWORK=1
103
+         ;;
104
+      b)
105
+         BALLOONING=1
106
+         ;;
107
+      f)
108
+         VPX_FILE=$OPTARG
109
+         ;;
110
+      d)
111
+         DATA_VDI_SIZE="${OPTARG}MiB"
112
+         ;;
113
+      m)
114
+         BRIDGE_M=$OPTARG
115
+         ;;
116
+      p)
117
+         BRIDGE_P=$OPTARG
118
+         ;;
119
+      k)
120
+         KERNEL_PARAMS=$OPTARG
121
+         ;;
122
+      r)
123
+         RAM=$OPTARG
124
+         ;;
125
+      v)
126
+         BRIDGE_V=$OPTARG
127
+         ;;
128
+      ?)
129
+         usage
130
+         exit
131
+         ;;
132
+    esac
133
+  done
134
+  if [[ -z $BRIDGE_M ]]
135
+  then
136
+     BRIDGE_M=xenbr0
137
+  fi
138
+}
139
+
140
+
141
+xe_min()
142
+{
143
+  local cmd="$1"
144
+  shift
145
+  xe "$cmd" --minimal "$@"
146
+}
147
+
148
+
149
+get_dest_sr()
150
+{
151
+  IFS=,
152
+  sr_uuids=$(xe sr-list --minimal other-config:i18n-key=local-storage)
153
+  dest_sr=""
154
+  for sr_uuid in $sr_uuids
155
+  do
156
+    pbd=$(xe pbd-list --minimal sr-uuid=$sr_uuid host-uuid=$INSTALLATION_UUID)
157
+    if [ "$pbd" ]
158
+    then
159
+      echo "$sr_uuid"
160
+      unset IFS
161
+      return
162
+    fi
163
+  done
164
+  unset IFS
165
+
166
+  dest_sr=$(xe_min sr-list uuid=$(xe_min pool-list params=default-SR))
167
+  if [ "$dest_sr" = "" ]
168
+  then
169
+    echo "No local storage and no default storage; cannot import VPX." >&2
170
+    exit 1
171
+  else
172
+    echo "$dest_sr"
173
+  fi
174
+}
175
+
176
+
177
+find_network()
178
+{
179
+  result=$(xe_min network-list bridge="$1")
180
+  if [ "$result" = "" ]
181
+  then
182
+    result=$(xe_min network-list name-label="$1")
183
+  fi
184
+  echo "$result"
185
+}
186
+
187
+
188
+find_template()
189
+{
190
+  xe_min template-list other-config:os-vpx=true
191
+}
192
+
193
+
194
+renumber_system_disk()
195
+{
196
+  local v="$1"
197
+  local vdi_uuid=$(xe_min vbd-list vm-uuid="$v" type=Disk userdevice=xvda \
198
+                                   params=vdi-uuid)
199
+  if [ "$vdi_uuid" ]
200
+  then
201
+    local vbd_uuid=$(xe_min vbd-list vm-uuid="$v" vdi-uuid="$vdi_uuid")
202
+    xe vbd-destroy uuid="$vbd_uuid"
203
+    local new_vbd_uuid=$(xe vbd-create vm-uuid="$v" vdi-uuid="$vdi_uuid" \
204
+                         device=0 bootable=true type=Disk)
205
+    xe vbd-param-set other-config:owner uuid="$new_vbd_uuid"
206
+  fi
207
+}
208
+
209
+
210
+create_vif()
211
+{
212
+  xe vif-create vm-uuid="$1" network-uuid="$2" device="$3"
213
+}
214
+
215
+create_gi_vif()
216
+{
217
+  local v="$1"
218
+  # Note that we've made the outbound device eth1, so that it comes up after
219
+  # the guest installer VIF, which means that the outbound one wins in terms
220
+  # of gateway.
221
+  local gi_network_uuid=$(xe_min network-list \
222
+                                 other-config:is_guest_installer_network=true)
223
+  create_vif "$v" "$gi_network_uuid" "0" >/dev/null
224
+}
225
+
226
+create_vm_vif()
227
+{
228
+  local v="$1"
229
+  echo "Installing management interface on $BRIDGE_V."
230
+  local out_network_uuid=$(find_network "$BRIDGE_V")
231
+  create_vif "$v" "$out_network_uuid" "1" >/dev/null
232
+}
233
+
234
+create_management_vif()
235
+{
236
+  local v="$1"
237
+  echo "Installing management interface on $BRIDGE_M."
238
+  local out_network_uuid=$(find_network "$BRIDGE_M")
239
+  create_vif "$v" "$out_network_uuid" "2" >/dev/null
240
+}
241
+
242
+
243
+# This installs the interface for public traffic, only if a bridge is specified
244
+# The interface is not configured at this stage, but it will be, once the admin   
245
+# tasks are complete for the services of this VPX
246
+create_public_vif()
247
+{
248
+  local v="$1"
249
+  if [[ -z $BRIDGE_P ]]
250
+  then
251
+    echo "Skipping installation of interface for public traffic."
252
+  else
253
+    echo "Installing public interface on $BRIDGE_P."
254
+    pub_network_uuid=$(find_network "$BRIDGE_P")
255
+    create_vif "$v" "$pub_network_uuid" "3" >/dev/null
256
+  fi
257
+}
258
+
259
+
260
+label_system_disk()
261
+{
262
+  local v="$1"
263
+  local vdi_uuid=$(xe_min vbd-list vm-uuid="$v" type=Disk userdevice=0 \
264
+                                   params=vdi-uuid)
265
+  xe vdi-param-set \
266
+     name-label="$NAME system disk" \
267
+     other-config:os-vpx=true \
268
+     uuid=$vdi_uuid
269
+}
270
+
271
+
272
+create_data_disk()
273
+{
274
+  local v="$1"
275
+
276
+  local sys_vdi_uuid=$(xe_min vbd-list vm-uuid="$v" type=Disk params=vdi-uuid)
277
+  local data_vdi_uuid=$(xe_min vdi-list other-config:os-vpx-data=true)
278
+
279
+  if echo "$data_vdi_uuid" | grep -q ,
280
+  then
281
+    echo "Multiple data disks found -- assuming that you want a new one."
282
+    data_vdi_uuid=""
283
+  else
284
+    data_in_use=$(xe_min vbd-list vdi-uuid="$data_vdi_uuid")
285
+    if [ "$data_in_use" != "" ]
286
+    then
287
+      echo "Data disk already in use -- will create another one."
288
+      data_vdi_uuid=""
289
+    fi
290
+  fi
291
+
292
+  if [ "$data_vdi_uuid" = "" ]
293
+  then
294
+    echo -n "Creating new data disk ($DATA_VDI_SIZE)... "
295
+    sr_uuid=$(xe_min vdi-list params=sr-uuid uuid="$sys_vdi_uuid")
296
+    data_vdi_uuid=$(xe vdi-create name-label="$NAME data disk" \
297
+                                  sr-uuid="$sr_uuid" \
298
+                                  type=user \
299
+                                  virtual-size="$DATA_VDI_SIZE")
300
+    xe vdi-param-set \
301
+       other-config:os-vpx-data=true \
302
+       uuid="$data_vdi_uuid"
303
+    dom0_uuid=$(xe_min vm-list is-control-domain=true)
304
+    vbd_uuid=$(xe vbd-create device=autodetect type=Disk \
305
+                             vdi-uuid="$data_vdi_uuid" vm-uuid="$dom0_uuid")
306
+    xe vbd-plug uuid=$vbd_uuid
307
+    dev=$(xe_min vbd-list params=device uuid=$vbd_uuid)
308
+    mke2fs -q -j -m0 /dev/$dev
309
+    e2label /dev/$dev vpxstate
310
+    xe vbd-unplug uuid=$vbd_uuid
311
+    xe vbd-destroy uuid=$vbd_uuid
312
+  else
313
+    echo -n "Attaching old data disk... "
314
+  fi
315
+  vbd_uuid=$(xe vbd-create device=2 type=Disk \
316
+                           vdi-uuid="$data_vdi_uuid" vm-uuid="$v")
317
+  xe vbd-param-set other-config:os-vpx-data=true uuid=$vbd_uuid
318
+  echo "done."
319
+}
320
+
321
+
322
+set_kernel_params()
323
+{
324
+  local v="$1"
325
+  local args=$KERNEL_PARAMS
326
+  local cmdline=$(cat /proc/cmdline)
327
+  for word in $cmdline
328
+  do
329
+    if echo "$word" | grep -q "geppetto"
330
+    then
331
+      args="$word $args"
332
+    fi
333
+  done
334
+  if [ "$args" != "" ]
335
+  then
336
+    echo "Passing Geppetto args to VPX: $args."
337
+    xe vm-param-set PV-args="$args" uuid="$v"
338
+  fi
339
+}
340
+
341
+
342
+set_memory()
343
+{
344
+  local v="$1"
345
+  if [ "$RAM" != "" ]
346
+  then
347
+    echo "Setting RAM to $RAM MiB."
348
+    [ "$BALLOONING" == 1 ] && RAM_MIN=$(($RAM / 2)) || RAM_MIN=$RAM
349
+    xe vm-memory-limits-set static-min=16MiB static-max=${RAM}MiB \
350
+                            dynamic-min=${RAM_MIN}MiB dynamic-max=${RAM}MiB \
351
+                            uuid="$v"
352
+  fi
353
+}
354
+
355
+
356
+# Make the VM auto-start on server boot.
357
+set_auto_start()
358
+{
359
+  local v="$1"
360
+  xe vm-param-set uuid="$v" other-config:auto_poweron=true
361
+}
362
+
363
+
364
+set_all()
365
+{
366
+  local v="$1"
367
+  set_kernel_params "$v"
368
+  set_memory "$v"
369
+  set_auto_start "$v"
370
+  label_system_disk "$v"
371
+  create_gi_vif "$v"
372
+  create_vm_vif "$v"
373
+  create_management_vif "$v"
374
+  create_public_vif "$v"
375
+}
376
+
377
+
378
+log_vifs()
379
+{
380
+  local v="$1"
381
+
382
+  (IFS=,
383
+   for vif in $(xe_min vif-list vm-uuid="$v")
384
+   do
385
+    dev=$(xe_min vif-list uuid="$vif" params=device)
386
+    mac=$(xe_min vif-list uuid="$vif" params=MAC | sed -e 's/:/-/g')
387
+    echo "eth$dev has MAC $mac."
388
+   done
389
+   unset IFS) | sort
390
+}
391
+
392
+
393
+destroy_vifs()
394
+{
395
+  local v="$1"
396
+  IFS=,
397
+  for vif in $(xe_min vif-list vm-uuid="$v")
398
+  do
399
+    xe vif-destroy uuid="$vif"
400
+  done
401
+  unset IFS
402
+}
403
+
404
+
405
+get_params "$@"
406
+
407
+thisdir=$(dirname "$0")
408
+
409
+if [ "$FROM_TEMPLATE" ]
410
+then
411
+  template_uuid=$(find_template)
412
+  name=$(xe_min template-list params=name-label uuid="$template_uuid")
413
+  echo -n "Cloning $name... "
414
+  vm_uuid=$(xe vm-clone vm="$template_uuid" new-name-label="$name")
415
+  xe vm-param-set is-a-template=false uuid="$vm_uuid"
416
+  echo $vm_uuid.
417
+
418
+  destroy_vifs "$vm_uuid"
419
+  set_all "$vm_uuid"
420
+else
421
+  if [ ! -f "$VPX_FILE" ]
422
+  then
423
+      # Search $thisdir/$VPX_FILE too.  In particular, this is used when
424
+      # installing the VPX from the supp-pack, because we want to be able to
425
+      # invoke this script from the RPM and the firstboot script.
426
+      if [ -f "$thisdir/$VPX_FILE" ]
427
+      then
428
+          VPX_FILE="$thisdir/$VPX_FILE"
429
+      else
430
+          echo "$VPX_FILE does not exist." >&2
431
+          exit 1
432
+      fi
433
+  fi
434
+
435
+  echo "Found OS-VPX File: $VPX_FILE. "
436
+
437
+  dest_sr=$(get_dest_sr)
438
+
439
+  echo -n "Installing $NAME... "
440
+  vm_uuid=$(xe vm-import filename=$VPX_FILE sr-uuid="$dest_sr")
441
+  echo $vm_uuid.
442
+
443
+  renumber_system_disk "$vm_uuid"
444
+
445
+  nl=$(xe_min vm-list params=name-label uuid=$vm_uuid)
446
+  xe vm-param-set \
447
+    "name-label=${nl/ import/}" \
448
+    other-config:os-vpx=true \
449
+    uuid=$vm_uuid
450
+
451
+  set_all "$vm_uuid"
452
+  create_data_disk "$vm_uuid"
453
+
454
+  if [ "$AS_TEMPLATE" ]
455
+  then
456
+    xe vm-param-set uuid="$vm_uuid" is-a-template=true \
457
+                                    other-config:instant=true
458
+    echo -n "Installing VPX from template... "
459
+    vm_uuid=$(xe vm-clone vm="$vm_uuid" new-name-label="${nl/ import/}")
460
+    xe vm-param-set is-a-template=false uuid="$vm_uuid"
461
+    echo "$vm_uuid."
462
+  fi
463
+fi
464
+
465
+
466
+log_vifs "$vm_uuid"
467
+
468
+echo -n "Starting VM... "
469
+xe vm-start uuid=$vm_uuid
470
+echo "done."
471
+
472
+
473
+show_ip()
474
+{
475
+  ip_addr=$(echo "$1" | sed -n "s,^.*"$2"/ip: \([^;]*\).*$,\1,p")
476
+  echo -n "IP address for $3: "
477
+  if [ "$ip_addr" = "" ]
478
+  then
479
+    echo "did not appear."
480
+  else
481
+    echo "$ip_addr."
482
+  fi
483
+}
484
+
485
+
486
+if [ "$WAIT_FOR_NETWORK" ]
487
+then
488
+  echo "Waiting for network configuration... "
489
+  i=0
490
+  while [ $i -lt 600 ]
491
+  do
492
+    ip=$(xe_min vm-list params=networks uuid=$vm_uuid)
493
+    if [ "$ip" != "<not in database>" ]
494
+    then
495
+      show_ip "$ip" "1" "$BRIDGE_M"
496
+      if [[ $BRIDGE_P ]]
497
+      then
498
+        show_ip "$ip" "2" "$BRIDGE_P"
499
+      fi
500
+      echo "Installation complete."
501
+      exit 0
502
+    fi
503
+    sleep 10
504
+    let i=i+1
505
+  done
506
+fi
0 507
new file mode 100755
... ...
@@ -0,0 +1,365 @@
0
+#!/bin/bash
1
+#
2
+# Copyright (c) 2011 Citrix Systems, Inc.
3
+# Copyright 2011 OpenStack LLC.
4
+# All Rights Reserved.
5
+#
6
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+#    not use this file except in compliance with the License. You may obtain
8
+#    a copy of the License at
9
+#
10
+#         http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+#    Unless required by applicable law or agreed to in writing, software
13
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+#    License for the specific language governing permissions and limitations
16
+#    under the License.
17
+#
18
+
19
+set -eu
20
+
21
+set -o xtrace
22
+
23
+VBOX_IMG=/output/packages/vbox-img
24
+
25
+usage() {
26
+    cat >&2 <<EOF
27
+$0 -o <output filenames> -t <types> -x <xml files> <fs-staging-dir> <fs-size-MiB> <tmpdir>
28
+  -o: Colon-separated list of output filenames (one for each type).
29
+  -p: Create a disk label and partition within the output image
30
+  -t: Colon-separated list of types of output file.  xva and ovf supported.
31
+  -x: XML filenames (one for each type)
32
+
33
+EOF
34
+    exit 1
35
+}
36
+
37
+# parse cmdline
38
+
39
+OPT_USE_PARTITION=
40
+OPT_TYPES=
41
+OPT_OUTPUT_FILES=
42
+OPT_XML_FILES=
43
+
44
+while getopts o:pt:x: o
45
+do case "$o" in
46
+    o)    OPT_OUTPUT_FILES=$(echo "$OPTARG" | sed -e 's/\s*:\s*/ /g')
47
+        ;;
48
+    p)    OPT_USE_PARTITION=1
49
+        ;;
50
+    t)    OPT_TYPES=$(echo "$OPTARG" | sed -e 's/\s*:\s*/ /g')
51
+        ;;
52
+    x)    OPT_XML_FILES=$(echo "$OPTARG" | sed -e 's/\s*:\s*/ /g')
53
+        ;;
54
+    [?])  usage
55
+        ;;
56
+    esac
57
+done
58
+shift $((OPTIND-1))
59
+
60
+[ $# -ne 3 ] && usage
61
+FS_STAGING="$1"
62
+FS_SIZE_MIB="$2"
63
+TMPDIR="$3"
64
+
65
+if [ "$UID" = "0" ]
66
+then
67
+  SUDO=
68
+else
69
+  SUDO=sudo
70
+fi
71
+
72
+if [ "$FS_SIZE_MIB" = "0" ]
73
+then
74
+    # Just create a dummy file.  This allows developers to bypass bits of
75
+    # the build by setting the size to 0.
76
+    touch $OPT_OUTPUT_FILES
77
+    exit 0
78
+fi
79
+
80
+# create temporary files and dirs
81
+FS_TMPFILE=$(mktemp "$TMPDIR/mkxva-fsimg-XXXXX")
82
+XVA_TARBALL_STAGING=$(mktemp -d "$TMPDIR/mkxva-tarball-staging-XXXXX")
83
+OVF_STAGING=$(mktemp -d "$TMPDIR/mkxva-ovf-staging-XXXXX")
84
+
85
+# Find udevsettle and udevtrigger on this installation
86
+if [ -x "/sbin/udevsettle" ] ; then
87
+    UDEVSETTLE="/sbin/udevsettle --timeout=30"
88
+elif [ -x "/sbin/udevadm" ] ; then
89
+    UDEVSETTLE='/sbin/udevadm settle'
90
+else
91
+    UDEVSETTLE='/bin/true'
92
+fi
93
+
94
+if [ -x "/sbin/udevtrigger" ] ; then
95
+    UDEVTRIGGER=/sbin/udevtrigger
96
+elif [ -x "/sbin/udevadm" ] ; then
97
+    UDEVTRIGGER='/sbin/udevadm trigger'
98
+else
99
+    UDEVTRIGGER=
100
+fi
101
+
102
+# CLEAN_ variables track devices and mounts that must be taken down
103
+# no matter how the script exits.  Loop devices are vulnerable to
104
+# exhaustion so we make every effort to remove them
105
+
106
+CLEAN_KPARTX=
107
+CLEAN_LOSETUP=
108
+CLEAN_MOUNTPOINT=
109
+
110
+cleanup_devices () {
111
+    if [ -n "$CLEAN_MOUNTPOINT" ] ; then
112
+        echo "Mountpoint $CLEAN_MOUNTPOINT removed on abnormal exit"
113
+        $SUDO umount "$CLEAN_MOUNTPOINT" || echo "umount failed"
114
+        rmdir "$CLEAN_MOUNTPOINT" || echo "rmdir failed"
115
+    fi
116
+    if [ -n "$CLEAN_KPARTX" ] ; then
117
+        echo "kpartx devices for $CLEAN_KPARTX removed on abnormal exit"
118
+        $SUDO kpartx -d "$CLEAN_KPARTX" || echo "kpartx -d failed"
119
+    fi
120
+    if [ -n "$CLEAN_LOSETUP" ] ; then
121
+        echo "Loop device $CLEAN_LOSETUP removed on abnormal exit"
122
+        $SUDO losetup -d "$CLEAN_LOSETUP" # Allow losetup errors to propagate
123
+    fi
124
+}
125
+
126
+trap "cleanup_devices" EXIT
127
+
128
+make_fs_inner () {
129
+    local staging="$1"
130
+    local output="$2"
131
+    local options="$3"
132
+    CLEAN_MOUNTPOINT=$(mktemp -d "$TMPDIR/mkfs-XXXXXX")
133
+
134
+    # copy staging dir contents to fs image
135
+    $SUDO mount $options "$output" "$CLEAN_MOUNTPOINT"
136
+    $SUDO tar -C "$staging" -c . | tar -C "$CLEAN_MOUNTPOINT" -x
137
+    $SUDO umount "$CLEAN_MOUNTPOINT"
138
+    rmdir "$CLEAN_MOUNTPOINT"
139
+    CLEAN_MOUNTPOINT=
140
+}
141
+
142
+# Turn a staging dir into an ext3 filesystem within a partition
143
+make_fs_in_partition () {
144
+    local staging="$1"
145
+    local output="$2"
146
+
147
+    # create new empty disk
148
+    dd if=/dev/zero of="$output" bs=1M count=$FS_SIZE_MIB
149
+    # Set up a loop device on the empty disk image
150
+    local loopdevice=$($SUDO losetup -f)
151
+    $SUDO losetup "$loopdevice" "$output"
152
+    CLEAN_LOSETUP="$loopdevice"
153
+    # Create a partition table and single partition.
154
+    # Start partition at sector 63 to allow space for grub
155
+    cat <<EOF
156
+Errors from sfdisk below are expected because the new disk is uninitialised
157
+  Expecting: sfdisk: ERROR: sector 0 does not have an msdos signature
158
+  Expecting: /dev/loop0: unrecognized partition table type
159
+EOF
160
+    $SUDO sfdisk -uS "$CLEAN_LOSETUP" <<EOF
161
+63 - - *
162
+EOF
163
+
164
+    # kpartx creates a device for the new partition
165
+    # in the form /dev/mapper/loop1p1
166
+    $SUDO kpartx -av "$CLEAN_LOSETUP"
167
+    CLEAN_KPARTX="$CLEAN_LOSETUP"
168
+    # Wait for the device to appear
169
+    $UDEVTRIGGER
170
+    $UDEVSETTLE  || echo "udev settle command return code non-zero"
171
+    # Infer the name of the partition device
172
+    local partition="${CLEAN_LOSETUP/dev/dev/mapper}p1"
173
+    # Set permissive privileges on the device
174
+    $SUDO chmod 0777 "$partition"
175
+    # Make an ext3 filesystem on the partition
176
+    /sbin/mkfs.ext3 -I 128 -m0 -F "$partition"
177
+    /sbin/e2label "$partition" vpxroot
178
+    make_fs_inner "$staging" "$partition" ""
179
+    
180
+    # Now run grub on the image we've created
181
+    CLEAN_MOUNTPOINT=$(mktemp -d "$TMPDIR/mkfs-XXXXXX")
182
+
183
+    # copy Set up[ grub files prior to installing grub within the image
184
+    $SUDO mount "$partition" "$CLEAN_MOUNTPOINT"
185
+    $SUDO cp $CLEAN_MOUNTPOINT/usr/share/grub/i386-redhat/* "$CLEAN_MOUNTPOINT/boot/grub"
186
+    kernel_version=$($SUDO chroot "$CLEAN_MOUNTPOINT" rpm -qv kernel | sed -e 's/kernel-//')
187
+    kernel_version_xen=$($SUDO chroot "$CLEAN_MOUNTPOINT" rpm -qv kernel-xen | sed -e 's/kernel-xen-//')
188
+    $SUDO cat > "$CLEAN_MOUNTPOINT/boot/grub/grub.conf" <<EOF
189
+default 0
190
+timeout 2
191
+
192
+title vmlinuz-$kernel_version (HVM)
193
+        root (hd0,0)
194
+        kernel /boot/vmlinuz-$kernel_version ro root=LABEL=vpxroot
195
+        initrd /boot/initrd-$kernel_version.img
196
+
197
+title vmlinuz-${kernel_version_xen}xen (PV)
198
+        root (hd0,0)
199
+        kernel /boot/vmlinuz-${kernel_version_xen}xen ro root=LABEL=vpxroot console=xvc0
200
+        initrd /boot/initrd-${kernel_version_xen}xen.img
201
+EOF
202
+
203
+    $SUDO umount "$CLEAN_MOUNTPOINT"
204
+    CLEAN_MOUNTPOINT=
205
+    
206
+    # Grub expects a disk with name /dev/xxxx with a first partition
207
+    # named /dev/xxxx1, so we give it what it wants using symlinks
208
+    # Note: /dev is linked to the real /dev of the build machine, so
209
+    # must be cleaned up
210
+    local disk_name="/dev/osxva$$bld"
211
+    local disk_part1_name="${disk_name}1"
212
+    rm -f "$disk_name"
213
+    rm -f "$disk_part1_name"
214
+    ln -s "$CLEAN_LOSETUP" "$disk_name"
215
+    ln -s "$partition" "$disk_part1_name"
216
+    
217
+    # Feed commands into the grub shell to setup the disk
218
+    grub --no-curses --device-map=/dev/null <<EOF
219
+device (hd0) $disk_name
220
+setup (hd0) (hd0,0)
221
+quit
222
+EOF
223
+    
224
+    # Cleanup
225
+    rm -f "$disk_name"
226
+    rm -f "$disk_part1_name"
227
+    $SUDO kpartx -dv "$CLEAN_KPARTX"
228
+    CLEAN_KPARTX=
229
+    $SUDO losetup -d "$CLEAN_LOSETUP"
230
+    CLEAN_LOSETUP=
231
+}
232
+
233
+# turn a staging dir into an ext3 filesystem image
234
+make_fs () {
235
+    local staging="$1"
236
+    local output="$2"
237
+
238
+    # create new empty fs
239
+    dd if=/dev/zero of="$output" bs=1M count=0 seek=$FS_SIZE_MIB
240
+    /sbin/mkfs.ext3 -m0 -F "$output"
241
+    /sbin/e2label "$output" vpxroot
242
+    make_fs_inner "$staging" "$output" "-oloop"
243
+}
244
+
245
+
246
+# split a virtual disk image into the format expected inside an xva file
247
+splitvdi () {
248
+    local diskimg="$1"
249
+    local outputdir="$2"
250
+    local rio="$3"
251
+
252
+    local n_bytes=$(stat --printf=%s "$diskimg")
253
+    local n_meg=$((($n_bytes+$((1024*1024 -1)))/$((1024*1024))))
254
+    local i=0
255
+    while [ $i -lt $n_meg ] ; do 
256
+	if [ $rio -eq 0 ] ; then
257
+		local file="$outputdir"/chunk-$(printf "%08d" $i)
258
+		dd if="$diskimg" of="$file" skip=$i bs=1M count=1 2>/dev/null
259
+		gzip "$file"
260
+	else
261
+		local file="$outputdir"/$(printf "%08d" $i)
262
+	        dd if="$diskimg" of="$file" skip=$i bs=1M count=1 2>/dev/null
263
+		local chksum=$(sha1sum -b "$file")
264
+		echo -n "${chksum/ */}" > "$file.checksum"
265
+	fi
266
+	i=$(($i + 1))
267
+    done
268
+}
269
+
270
+if [ -n "$OPT_USE_PARTITION" ] ; then
271
+    make_fs_in_partition "$FS_STAGING" "$FS_TMPFILE"
272
+else
273
+    make_fs "$FS_STAGING" "$FS_TMPFILE"
274
+fi
275
+
276
+VDI_SIZE=$(stat --format=%s "$FS_TMPFILE")
277
+
278
+make_xva () {
279
+    local output_file="$1"
280
+    local xml_file="$2"
281
+    local subdir
282
+    local rio
283
+
284
+    if [[ `cat $xml_file` =~ "<member>\s*<name>class</name>\s*<value>VDI</value>\s*</member>\s*<member>\s*<name>id</name>\s*<value>(Ref:[0-9]+)</value>" ]]
285
+    then
286
+        # it's a rio style xva
287
+        subdir="${BASH_REMATCH[1]}";
288
+        rio=1
289
+    else
290
+        # it's a geneva style xva
291
+        subdir="xvda"
292
+        rio=0
293
+    fi
294
+
295
+    cp "$xml_file" "$XVA_TARBALL_STAGING"/ova.xml
296
+    sed -i -e "s/@VDI_SIZE@/$VDI_SIZE/" "$XVA_TARBALL_STAGING"/ova.xml
297
+    mkdir "$XVA_TARBALL_STAGING/$subdir"
298
+    splitvdi "$FS_TMPFILE" "$XVA_TARBALL_STAGING/$subdir" "$rio"
299
+    TARFILE_MEMBERS=$(cd "$XVA_TARBALL_STAGING" && echo ova.xml $subdir/*)
300
+    tar -C "$XVA_TARBALL_STAGING" --format=v7 -c $TARFILE_MEMBERS -f "$output_file.tmp"
301
+    mv "$output_file.tmp" "$output_file"
302
+}
303
+
304
+make_ovf () {
305
+    local output_dir="$1"
306
+    local xml_file="$2"
307
+    local output_base=$(basename "$output_dir")
308
+    local disk="$output_dir/${output_base}.vmdk"
309
+    local manifest="$output_dir/${output_base}.mf"
310
+    local ovf="$output_dir/${output_base}.ovf"
311
+
312
+    mkdir -p "$output_dir"
313
+    rm -f "$disk"
314
+    $VBOX_IMG convert --srcfilename="$FS_TMPFILE" --dstfilename="$disk" \
315
+        --srcformat RAW --dstformat VMDK --variant Stream
316
+    chmod 0644 "$disk"
317
+
318
+    local n_bytes=$(stat --printf=%s "$disk")
319
+    cp "$xml_file" "$ovf"
320
+    sed -i -e "s/@MKXVA_DISK_FULLSIZE@/$VDI_SIZE/" "$ovf"
321
+    sed -i -e "s/@MKXVA_DISK_SIZE@/$n_bytes/" "$ovf"
322
+    sed -i -e "s/@MKXVA_DISK_MIB_SIZE@/$FS_SIZE_MIB/" "$ovf"
323
+    sed -i -e "s/@MKXVA_DISK_FILENAME@/${output_base}.vmdk/" "$ovf"
324
+
325
+    for to_sign in "$ovf" "$disk"
326
+    do
327
+	local sha1_sum=$(sha1sum "$to_sign" | cut -d' ' -f1)
328
+	echo "SHA1($(basename "$to_sign"))= $sha1_sum" >> $manifest
329
+    done
330
+}
331
+
332
+output_files="$OPT_OUTPUT_FILES"
333
+xml_files="$OPT_XML_FILES"
334
+# Iterate through the type list creating the relevant VMs
335
+for create_type in $OPT_TYPES
336
+do
337
+    # Shift one parameter from the front of the lists
338
+    create_output_file="${output_files%% *}"
339
+    output_files="${output_files#* }"
340
+    create_xml_file="${xml_files%% *}"
341
+    xml_files="${xml_files#* }"
342
+    echo "Creating $create_type appliance $create_output_file using metadata file $create_xml_file"
343
+
344
+    case "$create_type" in
345
+	xva)
346
+	    make_xva "$create_output_file" "$create_xml_file"
347
+	    ;;
348
+	ovf)
349
+	    make_ovf "$create_output_file" "$create_xml_file"
350
+	    ;;
351
+	*)
352
+	    echo "Unknown VM type '$create_type'"
353
+	    exit 1
354
+	    ;;
355
+    esac
356
+
357
+done
358
+
359
+
360
+# cleanup
361
+if [ -z "${DO_NOT_CLEANUP:-}" ] ; then 
362
+    rm -rf "$XVA_TARBALL_STAGING"
363
+    rm -f "$FS_TMPFILE"
364
+fi
0 365
new file mode 100755
... ...
@@ -0,0 +1,101 @@
0
+#!/bin/bash
1
+#
2
+# Copyright (c) 2011 Citrix Systems, Inc.
3
+# Copyright 2011 OpenStack LLC.
4
+# All Rights Reserved.
5
+#
6
+#    Licensed under the Apache License, Version 2.0 (the "License"); you may
7
+#    not use this file except in compliance with the License. You may obtain
8
+#    a copy of the License at
9
+#
10
+#         http://www.apache.org/licenses/LICENSE-2.0
11
+#
12
+#    Unless required by applicable law or agreed to in writing, software
13
+#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14
+#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15
+#    License for the specific language governing permissions and limitations
16
+#    under the License.
17
+#
18
+
19
+remove_data=
20
+if [ "$1" = "--remove-data" ]
21
+then
22
+  remove_data=1
23
+fi
24
+
25
+set -eu
26
+
27
+xe_min()
28
+{
29
+  local cmd="$1"
30
+  shift
31
+  /opt/xensource/bin/xe "$cmd" --minimal "$@"
32
+}
33
+
34
+destroy_vdi()
35
+{
36
+  local vbd_uuid="$1"
37
+  local type=$(xe_min vbd-list uuid=$vbd_uuid params=type)
38
+  local dev=$(xe_min vbd-list uuid=$vbd_uuid params=userdevice)
39
+  local vdi_uuid=$(xe_min vbd-list uuid=$vbd_uuid params=vdi-uuid)
40
+
41
+  if [ "$type" = 'Disk' ] && [ "$dev" != 'xvda' ] && [ "$dev" != '0' ]
42
+  then
43
+    echo -n "Destroying data disk... "
44
+    xe vdi-destroy uuid=$vdi_uuid
45
+    echo "done."
46
+  fi
47
+}
48
+
49
+uninstall()
50
+{
51
+  local vm_uuid="$1"
52
+  local power_state=$(xe_min vm-list uuid=$vm_uuid params=power-state)
53
+
54
+  if [ "$power_state" != "halted" ]
55
+  then
56
+    echo -n "Shutting down VM... "
57
+    xe vm-shutdown vm=$vm_uuid force=true
58
+    echo "done."
59
+  fi
60
+
61
+  if [ "$remove_data" = "1" ]
62
+  then
63
+    for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g')
64
+    do
65
+      destroy_vdi "$v"
66
+    done
67
+  fi
68
+
69
+  echo -n "Deleting VM... "
70
+  xe vm-uninstall vm=$vm_uuid force=true >/dev/null
71
+  echo "done."
72
+}
73
+
74
+uninstall_template()
75
+{
76
+  local vm_uuid="$1"
77
+
78
+  if [ "$remove_data" = "1" ]
79
+  then
80
+    for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g')
81
+    do
82
+      destroy_vdi "$v"
83
+    done
84
+  fi
85
+
86
+  echo -n "Deleting template... "
87
+  xe template-uninstall template-uuid=$vm_uuid force=true >/dev/null
88
+  echo "done."
89
+}
90
+
91
+
92
+for u in $(xe_min vm-list other-config:os-vpx=true | sed -e 's/,/ /g')
93
+do
94
+  uninstall "$u"
95
+done
96
+
97
+for u in $(xe_min template-list other-config:os-vpx=true | sed -e 's/,/ /g')
98
+do
99
+  uninstall_template "$u"
100
+done
0 101
new file mode 100644
... ...
@@ -0,0 +1,8 @@
0
+127.0.0.1   localhost
1
+127.0.0.1   %HOSTNAME%
2
+::1     localhost ip6-localhost ip6-loopback
3
+fe00::0     ip6-localnet
4
+ff00::0     ip6-mcastprefix
5
+ff02::1     ip6-allnodes
6
+ff02::2     ip6-allrouters
7
+
0 8
new file mode 100644
... ...
@@ -0,0 +1,21 @@
0
+auto lo
1
+iface lo inet loopback
2
+
3
+auto eth0
4
+iface eth0 inet dhcp
5
+
6
+auto eth1
7
+iface eth1 inet static
8
+        address @ETH1_IP@
9
+        netmask @ETH1_NETMASK@
10
+post-up ethtool -K eth1 tx off
11
+
12
+auto eth2
13
+iface eth2 inet static
14
+        address @ETH2_IP@
15
+        netmask @ETH2_NETMASK@
16
+
17
+auto eth3
18
+iface eth3 inet static
19
+        address @ETH3_IP@
20
+        netmask @ETH3_NETMASK@
0 21
new file mode 100644
... ...
@@ -0,0 +1,6 @@
0
+default 0
1
+
2
+title default
3
+        root (hd0,0)
4
+        kernel /boot/vmlinuz-@KERNEL_VERSION@ ro root=LABEL=vpxroot console=xvc0
5
+        initrd /boot/initrd.img-@KERNEL_VERSION@
0 6
new file mode 100644
... ...
@@ -0,0 +1,14 @@
0
+<?xml version="1.0" ?>
1
+<appliance version="0.1">
2
+        <vm name="vm">
3
+                <label>
4
+                        @PRODUCT_BRAND@ @PRODUCT_VERSION@-@BUILD_NUMBER@
5
+                </label>
6
+                <shortdesc></shortdesc>
7
+                <config mem_set="671088640" vcpus="1"/>
8
+                <hacks is_hvm="false"/>
9
+                <vbd device="xvda" function="root" mode="w" vdi="vdi_xvda"/>
10
+        </vm>
11
+        <vdi name="vdi_xvda" size="@VDI_SIZE@" source="file://xvda" type="dir-gzipped-chunks" variety="system"/>
12
+</appliance>
13
+