Commit 3b3a8d50 authored by David Johnson's avatar David Johnson

Refactor VM image setup; support extra images; add user import script.

This cleanly refactors everything we do to VM images (asserting the
random passwd, disabling root passwd, changing sshd config, etc).  This
allows us to support adding extra images based on URL/name user provides
us in params, and to allow them to call our script after profile
instantiation to add an image.  It's fairly comprehensive and it
certainly works for the common cloud images from various linux vendors.

It also rolls multi-nic support into each image.  We do this via
boot-time udev scripts and dhcp hooks that ensure we don't add routes
for interfaces other than eth0 (this ensures that the default gateway is
always attached to eth0).  The old, hacky, sometimes-broken multi-nic
support is gone, as is the special image.  I have no idea why cloud
images don't just include this feature by default... it's not hard at
all.

We support Ubuntu and Fedora/Centos.  We support basically the image
formats that qemu-nbd supports (i.e., qcow, vmware, vdi, raw), and gz or
xz compression.  That seems to cover the core spectrum.

On aarch64, we yank the kernel and initrd out of the image's /boot and
create an AMI/AKI/ARI image tuple, instead of uploading the raw disk
image.  I have never figured out how to boot a raw Ubuntu cloud image on
KVM/aarch64, and the HP guys never got back to me.  So this is the only
way I know (well, there's UEFI, and there's a UEFI aarch64 BIOS, so the
UEFI cloud images might work... but life is way too short for all that
fun).
parent 6d23a989
#!/bin/sh
##
## Download, configure, and upload one or more images into Glance.
##
if [ -n "$DEBUG" -a ! $DEBUG -eq 0 ]; then
set -x
fi
DIRNAME=`dirname $0`
# Gotta know the rules!
if [ `id -u` -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
force=0
if [ "$1" = "--force" ]; then
force=1
shift
fi
CUSTOMIMAGEURLS=""
while [ -n "$1" ]; do
CUSTOMIMAGEURLS="$CUSTOMIMAGEURLS $1"
shift
done
if [ -z "$CUSTOMIMAGEURLS" ]; then
echo "*** ERROR: you didn't specify an image URL to import!"
exit 1
fi
# Grab our libs
. "$DIRNAME/setup-lib.sh"
. "$DIRNAME/setup-images-lib.sh"
if [ "$HOSTNAME" != "$CONTROLLER" ]; then
exit 1;
fi
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
. $OURDIR/admin-openrc.sh
if [ ! -f $OURDIR/controller-done ]; then
echo "*** ERROR: your controller is still being configured; wait until it's done (until $OURDIR/controller-done exists; check $OURDIR/setup-controller.log to check progress)"
exit 1
fi
#
# Take our lockfile.
#
echo "*** Getting image lock..."
lockfile-create $IMAGESETUPLOCKFILE
echo "*** Got image lock, continuing..."
cwd=`pwd`
cd $IMAGEDIR
if [ -n "$CUSTOMIMAGEURLS" ]; then
for imgurl in $CUSTOMIMAGEURLS ; do
echo "$imgurl" | grep -q '|'
if [ $? -eq 0 ]; then
imgurl=`echo "$imgurl" | cut -f 1 -d '|'`
imgname=`echo "$imgurl" | cut -f 2 -d '|'`
fi
imgfile=`get_url "$imgurl"`
if [ ! $? -eq 0 ]; then
echo "ERROR: could not download $imgurl !"
else
if [ -z "$imgname" ]; then
imgname=`echo $imgfile | sed -e 's/\([^\.]*\)\..*$/\1/'`
fi
imgfile=`extract_image "$imgfile"`
if [ -n "$imgfile" ]; then
(fixup_image "$imgfile" \
&& upload_image "$IMAGEDIR/$imgfile" "$imgname") \
|| echo "ERROR: could not configure and upload user VM image $imgurl !"
else
echo "ERROR: could not extract user VM image $imgurl !"
fi
fi
done
fi
#
# Release our lockfile.
#
echo "*** Releasing image lock..."
lockfile-remove $IMAGESETUPLOCKFILE
echo "*** Released image lock."
exit 0
......@@ -40,12 +40,14 @@ pc.defineParameter("osLinkSpeed", "Experiment Link Speed of all nodes",
portal.ParameterType.INTEGER, 0,
[(0,"Any"),(1000000,"1Gb/s"),(10000000,"10Gb/s")],
longDescription="A specific link speed to use for each node. All experiment network interfaces will request this speed.")
pc.defineParameter("ml2plugin","ML2 Plugin",
portal.ParameterType.STRING,"openvswitch",
[("openvswitch","OpenVSwitch"),
("linuxbridge","Linux Bridge")],
longDescription="Starting in Liberty and onwards, we support both the OpenVSwitch and LinuxBridge ML2 plugins to create virtual networks in Neutron. OpenVSwitch remains our default and best-supported option. Note: you cannot use GRE tunnels with the LinuxBridge driver; you'll need to use VXLAN tunnels instead. And by default, the profile allocates 1 GRE tunnel -- so you must change that immediately, or you will see an error.")
pc.defineParameter("extraImageURLs","Extra VM Image URLs",
portal.ParameterType.STRING,"",
longDescription="This parameter allows you to specify a space-separated list of URLs, each of which points to an OpenStack VM image, which we will download and slighty tweak before uploading to Glance in your OpenStack experiment.")
pc.defineParameter("ubuntuMirrorHost","Ubuntu Package Mirror Hostname",
......@@ -830,6 +832,9 @@ class Parameters(RSpec.Resource):
param = ET.SubElement(el,paramXML)
param.text = "ML2PLUGIN=%s" % (str(params.ml2plugin))
param = ET.SubElement(el,paramXML)
param.text = "EXTRAIMAGEURLS='%s'" % (str(params.extraImageURLs))
return el
pass
......
This diff is collapsed.
#!/bin/sh
##
## Initialize some basic aarch64 stuff.
## Initialize some basic x86_64 stuff.
##
set -x
DIRNAME=`dirname $0`
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "$DIRNAME/setup-lib.sh"
if [ "$HOSTNAME" != "$CONTROLLER" ]; then
exit 0;
fi
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
. $OURDIR/admin-openrc.sh
echo "*** Downloading an x86_64 image ..."
imgname=trusty-server-cloudimg-amd64-disk1.img
imgnameshort=trusty-server
#
# First try the local boss, then Apt, then just grab from Ubuntu.
#
if [ ! -f $imgname ]; then
retries=3
while [ $retries -gt 0 ]; do
wget http://boss.${OURDOMAIN}/downloads/$imgname
if [ $? -eq 0 ]; then
break
else
sleep 5
retries=`expr $retries - 1`
fi
done
fi
if [ ! -f $imgname ]; then
retries=3
while [ $retries -gt 0 ]; do
wget http://boss.apt.emulab.net/downloads/$imgname
if [ $? -eq 0 ]; then
break
else
sleep 5
retries=`expr $retries - 1`
fi
done
fi
if [ ! -f $imgname ]; then
retries=100
while [ $retries -gt 0 ]; do
wget https://cloud-images.ubuntu.com/trusty/current/$imgname
if [ $? -eq 0 ]; then
break
else
sleep 5
retries=`expr $retries - 1`
fi
done
fi
modprobe nbd max_part=8
qemu-nbd --connect=/dev/nbd0 $imgname
mount /dev/nbd0p1 /mnt/
echo "*** Setting up sshd ..."
sed -i -e 's/^.*PermitRootLogin .*$/PermitRootLogin yes/' /mnt/etc/ssh/sshd_config
sed -i -e 's/^.*PasswordAuthentication .*$/PasswordAuthentication yes/' /mnt/etc/ssh/sshd_config
echo "*** Modifying root password..."
cp -p /mnt/etc/shadow $OURDIR/
cp -p /mnt/etc/passwd $OURDIR/
cp -p /mnt/etc/group $OURDIR/
echo "*** fixing root password ..."
#sed -i -e "s@root:[^:]*:@root:${ADMIN_PASS_HASH}:@" /mnt/etc/shadow
sed -i -e "s@root:[^:]*:@root:!:@" /mnt/etc/shadow
echo "*** fixing ubuntu password ..."
grep ^ubuntu /etc/passwd
if [ $? -eq 0 ]; then
sed -i -e "s@ubuntu:[^:]*:@ubuntu:${ADMIN_PASS_HASH}:@" /mnt/etc/shadow
else
# Have to add the user so that the passwd is actually set...
echo "ubuntu:x:1000:1000:Ubuntu:/home/ubuntu:/bin/bash" >> /mnt/etc/passwd
echo "ubuntu:!:16731:0:99999:7:::" >> /mnt/etc/shadow
echo "ubuntu:x:1000:" >> /mnt/etc/group
echo "ubuntu:!::" >> /mnt/etc/gshadow
mkdir -p /mnt/home/ubuntu
chown 1000:1000 /mnt/home/ubuntu
sed -i -e "s@ubuntu:[^:]*:@ubuntu:${ADMIN_PASS_HASH}:@" /mnt/etc/shadow
fi
# permit root login!!
sed -i -e 's/^disable_root: true$/disable_root: false/' /mnt/etc/cloud/cloud.cfg
# don't overwrite the Ubuntu passwd we just hacked in
sed -i -e 's/^.*lock_passwd:.*$/ lock_passwd: False/' /mnt/etc/cloud/cloud.cfg
umount /mnt
echo "*** Importing new image ..."
GLANCEOPTS=""
if [ "$OSCODENAME" = "juno" -o "$OSCODENAME" = "kilo" ]; then
GLANCEOPTS="--is-public True"
fi
glance image-create --name ${imgnameshort} ${GLANCEOPTS} --disk-format qcow2 --container-format bare --progress --file $imgname
mount /dev/nbd0p1 /mnt/
echo "*** Modifying to support up to 8 NICs..."
cat <<EOF > /mnt/etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet dhcp
auto eth2
iface eth2 inet dhcp
auto eth3
iface eth3 inet dhcp
auto eth4
iface eth4 inet dhcp
auto eth5
iface eth5 inet dhcp
auto eth6
iface eth6 inet dhcp
auto eth7
iface eth7 inet dhcp
EOF
#
# Ok, there is some delay with local-filesystems not finishing mounting
# until after the cloud-utils have blocked up the system :(. So, remove
# this dependency. You can see why the Ubuntu people have it in general,
# but it will never bother us in this VM image!
#
#sed -i -e 's/^start on (local-filesystems$/start on (mounted MOUNTPOINT=\/ and mounted MOUNTPOINT=\/sys and mounted MOUNTPOINT=\/proc and mounted MOUNTPOINT=\/run/' mnt/etc/init/networking.conf
sed -i -e 's/^start on (local-filesystems$/start on (mounted MOUNTPOINT=\//' /mnt/etc/init/networking.conf
#
# Handle ethX devices that aren't actually in the VM instance by faking
# that they are up so that startup doesn't get hung and timeout. Our hack
# only looks for ^eth\d*$ devices, and skips them if they're not accessible
# via ifconfig. This should be pretty safe, and it doesn't block things
# like bridges, ovs devices, tun/tap, etc.
#
cp -p $DIRNAME/etc/if-pre-up-upstart-faker /mnt/etc/network/if-pre-up.d/
umount /mnt
echo "*** Importing new multi-nic image ..."
glance image-create --name ${imgnameshort}-multi-nic ${GLANCEOPTS} --disk-format qcow2 --container-format bare --progress --file $imgname
qemu-nbd -d /dev/nbd0
#
# Setup the Manila service image so that Manila works out of the box.
#
imgname=manila-service-image-master.qcow2
urls="http://boss.${OURDOMAIN}/downloads/openstack/$imgname http://boss.apt.emulab.net/downloads/openstack/$imgname http://tarballs.openstack.org/manila-image-elements/images/$imgname"
for url in $urls ; do
if [ ! -f $imgname ]; then
retries=3
while [ $retries -gt 0 ]; do
wget -O $imgname $url
if [ $? -eq 0 ]; then
break
else
sleep 5
retries=`expr $retries - 1`
fi
done
fi
if [ -f $imgname ]; then
break
fi
done
if [ -f $imgname ]; then
glance image-create --name manila-service-image --file $imgname \
--disk-format qcow2 --container-format bare --progress \
--visibility public
else
echo "ERROR: could not download $imgname from Cloudlab nor Ubuntu; Manila will not work without a service image!"
fi
exit 0
......@@ -27,15 +27,6 @@ fi
. $OURDIR/admin-openrc.sh
echo "*** Adding Images ..."
ARCH=`uname -m`
if [ "$ARCH" = "aarch64" ] ; then
$DIRNAME/setup-basic-aarch64.sh
else
$DIRNAME/setup-basic-x86_64.sh
fi
#
# Setup tunnel-based networks
#
......@@ -251,4 +242,20 @@ if [ $QUOTASOFF -eq 1 ]; then
openstack quota set --class --volume-type -1 admin
fi
. $OURDIR/setup-images-lib.sh
lockfile-create $IMAGESETUPLOCKFILE
if [ -f $IMAGEUPLOADCMDFILE ]; then
echo "*** Adding Images ..."
. $OURDIR/admin-openrc.sh
. $IMAGEUPLOADCMDFILE
fi
lockfile-remove $IMAGESETUPLOCKFILE
ARCH=`uname -m`
if [ "$ARCH" = "aarch64" ] ; then
$DIRNAME/setup-basic-aarch64.sh
else
$DIRNAME/setup-basic-x86_64.sh
fi
exit 0
......@@ -49,6 +49,16 @@ __openstack() {
done
}
#
# We're going to spin off our image downloader/configurator to better
# parallelize. So make sure it has the packages it needs.
#
maybe_install_packages qemu-utils wget lockfile-progs rpm
if [ "$ARCH" = "aarch64" ]; then
# need growpart
maybe_install_packages cloud-guest-utils
fi
maybe_install_packages pssh
PSSH='/usr/bin/parallel-ssh -t 0 -O StrictHostKeyChecking=no '
......@@ -68,6 +78,11 @@ sleep 2
echo "Your OpenStack instance is setting up on `hostname` ." \
| mail -s "OpenStack Instance Setting Up" ${SWAPPER_EMAIL} &
#
# Fire off the image downloader/configurator in the background.
#
$DIRNAME/setup-images.sh >> $OURDIR/setup-images.log 2>&1 &
#
# If we're >= Kilo, we might need the openstack CLI command.
#
......@@ -3453,4 +3468,6 @@ echo "***"
echo "Your OpenStack instance has completed setup! Browse to http://$CONTROLLER.$EEID.$EPID.${OURDOMAIN}/horizon/auth/login/?next=/horizon/project/instances/ . ${RANDPASSSTRING}" \
| mail -s "OpenStack Instance Finished Setting Up" ${SWAPPER_EMAIL}
touch $OURDIR/controller-done
exit 0
#!/bin/sh
##
## Download and configure the default aarch64 images.
##
set -x
DIRNAME=`dirname $0`
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "$DIRNAME/setup-lib.sh"
if [ "$HOSTNAME" != "$CONTROLLER" ]; then
exit 0;
fi
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
cd $IMAGEDIR
imgfile=`get_url "http://boss.utah.cloudlab.us/downloads/openstack/trusty-server-cloudimg-arm64-disk1.img https://cloud-images.ubuntu.com/trusty/current/trusty-server-cloudimg-arm64-disk1.img"`
imgname=trusty-server
if [ ! $? -eq 0 ]; then
echo "ERROR: failed to download trusty-server-cloudimg-arm64-disk1.img from Cloudlab or Ubuntu!"
else
imgfile=`extract_image "$imgfile"`
if [ ! $? -eq 0 ]; then
echo "ERROR: failed to extract trusty-server-cloudimg-arm64-disk1.img"
else
(fixup_image "$imgfile" \
&& sched_image "$IMAGEDIR/$imgfile" "$imgname" ) \
|| echo "ERROR: could not configure default VM image $imgfile !"
fi
fi
#
# NB: do not exit; we are included!
#
#!/bin/sh
fixup_mounted_image_aarch64() {
MNT="$1"
_imgfile="$2"
_dir=`dirname $_imgfile`
retvalcmd=/bin/true
# Find the kernel and initrd, and copy them to the dir holding
# $_imgfile .
if [ -f $MNT/boot/vmlinuz ]; then
cp -p $MNT/boot/vmlinuz $_dir/$_imgfile-vmlinuz
else
# Try to find the highest-versioned vmlinuz. Totally error-prone.
_vmlinuz=`find $MNT/boot -name vmlinuz\* | sort | tail -1`
if [ -n "$_vmlinuz" ]; then
cp -p $_vmlinuz $_dir/$_imgfile-vmlinuz
else
echo "*** ERROR: could not find vmlinuz* in $MNT/boot; image will most likely fail to boot!"
ls -l $MNT/boot
retvalcmd=/bin/false
fi
fi
if [ -f $MNT/boot/initrd.img ]; then
cp -p $MNT/boot/initrd.img $_dir/$_imgfile-initrd.img
else
# Try to find the highest-versioned initrd.img. Totally error-prone.
_initrd=`find $MNT/boot -name initrd\*.img\* | sort | tail -1`
if [ -n "$_initrd" ]; then
cp -p $_initrd $_dir/$_imgfile-initrd.img
else
echo "*** ERROR: could not find initrd*.img* in $MNT/boot; image will most likely fail to boot!"
ls -l $MNT/boot
retvalcmd=/bin/false
fi
fi
$retvalcmd
}
fixup_image() {
_imgfile="$1"
MNT=`mount_image_etc "$_imgfile"`
if [ -z "$MNT" ]; then
echo "ERROR: could not mount $_imgfile !"
/bin/false
return
fi
fixup_mounted_image "$MNT" "$_imgfile"
fixup_mounted_image_aarch64 "$MNT" "$_imgfile"
umount_image "$MNT"
}
# 21 glance image-list
# 23 glance image-list
# 24 glance image-create --name xenial-server --progress --file xenial-server-cloudimg-arm64-disk1.img --disk-format ami --container-format ami
# 25 glance image-update --property kernel_args=console=ttyAMA0 e12c37fa-3dbd-45ad-8050-2b6c7b1818ad
# 26 glance image-create --name xenial-server-vmlinuz --progres --file xenial-server-cloudimg-arm64-disk1-vmlinuz --disk-format aki --container-format aki
# 27 glance image-create --name xenial-server-initrd --progres --file xenial-server-cloudimg-arm64-disk1-initrd --disk-format ari --container-format ari
# 28 glance image-create --name xenial-server-initrd --progres --file xenial-server-cloudimg-arm64-disk1-initrd.img --disk-format ari --container-format ari
# 29 glance image-update --property kernel_id=daac78a9-d0d0-4e0d-a54f-a4a931659bcf e12c37fa-3dbd-45ad-8050-2b6c7b1818ad
# 30 glance image-update --property ramdisk_id=e8de69f0-87cf-4061-9485-a79fa9dd7d11 e12c37fa-3dbd-45ad-8050-2b6c7b1818ad
# 31 glance image-update --property hw_video_model=vga e12c37fa-3dbd-45ad-8050-2b6c7b1818ad
# 32 glance image-update --property root_device_name=/dev/vda1 e12c37fa-3dbd-45ad-8050-2b6c7b1818ad
#
# Custom versions of these because all aarch64 images get uploaded as
# AMI/AKI/ARI images.
#
sched_image() {
_imgfile="$1"
_imgname="$2"
if [ -z "$_imgname" ]; then
_imgname="$_imgfile"
fi
touch $IMAGEUPLOADCMDFILE
chmod 755 $IMAGEUPLOADCMDFILE
GLANCEOPTS=""
if [ "$OSCODENAME" = "juno" -o "$OSCODENAME" = "kilo" ]; then
GLANCEOPTS="--is-public True"
fi
cat <<EOF >> $IMAGEUPLOADCMDFILE
_imgfile='$_imgfile'
_imgname='$_imgname'
GLANCEOPTS='$GLANCEOPTS'
EOF
cat <<'EOF' >> $IMAGEUPLOADCMDFILE
glance image-create --name "${_imgname}" ${GLANCEOPTS} --disk-format ami --container-format ami --progress --file "$_imgfile"
if [ ! $? -eq 0 ]; then
echo "*** ERROR: could not upload $_imgfile as $_imgname !"
/bin/false
return
fi
IMAGEID=`glance image-list | awk "/ ${_imgname} / { print \\$2 }"`
glance image-update --property kernel_args=console=ttyAMA0 $IMAGEID
glance image-update --property hw_video_model=vga $IMAGEID
glance image-update --property root_device_name=/dev/vda1 $IMAGEID
glance image-create --name ${_imgname}-vmlinuz --progress --file ${_imgfile}-vmlinuz --disk-format aki --container-format aki
KERNELID=`glance image-list | awk "/ ${_imgname}-vmlinuz / { print \\$2 }"`
glance image-update --property kernel_id=$KERNELID $IMAGEID
glance image-create --name ${_imgname}-initrd --progress --file ${_imgfile}-initrd.img --disk-format ari --container-format ari
RAMDISKID=`glance image-list | awk "/ ${_imgname}-initrd / { print \\$2 }"`
glance image-update --property ramdisk_id=$RAMDISKID $IMAGEID
EOF
}
upload_image() {
_imgfile="$1"
_imgname="$2"
if [ -z "$_imgname" ]; then
_imgname="$_imgfile"
fi
GLANCEOPTS=""
if [ "$OSCODENAME" = "juno" -o "$OSCODENAME" = "kilo" ]; then
GLANCEOPTS="--is-public True"
fi
glance image-create --name "${_imgname}" ${GLANCEOPTS} --disk-format ami --container-format ami --progress --file "$_imgfile"
if [ ! $? -eq 0 ]; then
echo "*** ERROR: could not upload $_imgfile as $_imgname !"
/bin/false
return
fi
IMAGEID=`glance image-list | awk "/ ${_imgname} / { print \\$2 }"`
glance image-update --property kernel_args=console=ttyAMA0 $IMAGEID
glance image-update --property hw_video_model=vga $IMAGEID
glance image-update --property root_device_name=/dev/vda1 $IMAGEID
glance image-create --name ${_imgname}-vmlinuz --progress --file ${_imgfile}-vmlinuz --disk-format aki --container-format aki
KERNELID=`glance image-list | awk "/ ${_imgname}-vmlinuz / { print \\$2 }"`
glance image-update --property kernel_id=$KERNELID $IMAGEID
glance image-create --name ${_imgname}-initrd --progress --file ${_imgfile}-initrd.img --disk-format ari --container-format ari
RAMDISKID=`glance image-list | awk "/ ${_imgname}-initrd / { print \\$2 }"`
glance image-update --property ramdisk_id=$RAMDISKID $IMAGEID
}
This diff is collapsed.
#!/bin/sh
##
## Download and configure the default x86_64 images.
##
set -x
DIRNAME=`dirname $0`
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "$DIRNAME/setup-lib.sh"
if [ "$HOSTNAME" != "$CONTROLLER" ]; then
exit 0;
fi
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
cd $IMAGEDIR
echo "*** Configuring a trusty-server x86_64 image ..."
imgfile=trusty-server-cloudimg-amd64-disk1.img
imgname=trusty-server
#
# First try the local boss, then Apt, then just grab from Ubuntu.
#
imgfile=`get_url "http://boss.${OURDOMAIN}/downloads/openstack/$imgfile http://boss.apt.emulab.net/downloads/openstack/$imgfile https://cloud-images.ubuntu.com/trusty/current/$imgfile"`
if [ ! $? -eq 0 ]; then
echo "ERROR: failed to download $imgfile from Cloudlab or Ubuntu!"
else
old="$imgfile"
imgfile=`extract_image "$imgfile"`
if [ ! $? -eq 0 ]; then
echo "ERROR: failed to extract $old"
else
(fixup_image "$imgfile" \
&& sched_image "$IMAGEDIR/$imgfile" "$imgname" ) \
|| echo "ERROR: could not configure default VM image $imgfile !"
fi
fi
#
# Setup the Manila service image so that Manila works out of the box.
#
echo "*** Configuring the manila-service-image image ..."
imgfile=manila-service-image-master.qcow2
imgname=manila-service-image
imgfile=`get_url "http://boss.${OURDOMAIN}/downloads/openstack/$imgfile http://boss.apt.emulab.net/downloads/openstack/$imgfile http://tarballs.openstack.org/manila-image-elements/images/$imgfile"`
if [ ! $? -eq 0 ]; then
echo "ERROR: failed to download $imgfile from Cloudlab or Ubuntu!"
else
old="$imgfile"
imgfile=`extract_image "$imgfile"`
if [ ! $? -eq 0 ]; then
echo "ERROR: failed to extract $old"
else
(fixup_image "$imgfile" \
&& sched_image "$IMAGEDIR/$imgfile" "$imgname" ) \
|| echo "ERROR: could not configure default VM image $imgfile !"
fi
fi
# glance image-create --name manila-service-image --file $imgfile \
# --disk-format qcow2 --container-format bare --progress \
# --visibility public
#
# NB: do not exit; we are included!
#
#!/bin/sh
##
## Download and configure some images, and write out glance commands to
## get them uploaded into glance. This script only runs the upload
## commands if we're not being run from controller setup; otherwise, the
## controller setup process runs this when it is safe (if in controller
## setup, we don't upload them into glance immediately because glance
## might not be running or any number of components may be restarting or
## otherwise in flux; setup-basic.sh uploads them when it is safe, near
## the end of our setup).
##
set -x
DIRNAME=`dirname $0`
# Gotta know the rules!
if [ $EUID -ne 0 ] ; then
echo "This script must be run as root" 1>&2
exit 1
fi
# Grab our libs
. "$DIRNAME/setup-lib.sh"
if [ "$HOSTNAME" != "$CONTROLLER" ]; then
exit 0;
fi
if [ -f $SETTINGS ]; then
. $SETTINGS
fi
#
# Take our lockfile.
#
lockfile-create $IMAGESETUPLOCKFILE
#
# Create and truncate our upload commands.
#
truncate -s 0 $IMAGEUPLOADCMDFILE
chmod 755 $IMAGEUPLOADCMDFILE
cwd=`pwd`
cd $IMAGEDIR
#
# Setup the per-arch default images (and let them override our default
# *_image functions if they wish).
#
. $DIRNAME/setup-images-lib.sh
if [ "$ARCH" = "aarch64" ] ; then
. $DIRNAME/setup-images-aarch64.sh
else
. $DIRNAME/setup-images-x86_64.sh
f