Merge remote-tracking branch 'origin/master' into xen
commit
cc5028ded1
@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Load local configuration
|
||||
source ./stackrc
|
||||
|
||||
# Set api host endpoint
|
||||
HOST_IP=${HOST_IP:-127.0.0.1}
|
||||
|
||||
# Nova original used project_id as the *account* that owned resources (servers,
|
||||
# ip address, ...) With the addition of Keystone we have standardized on the
|
||||
# term **tenant** as the entity that owns the resources. **novaclient** still
|
||||
# uses the old deprecated terms project_id. Note that this field should now be
|
||||
# set to tenant_name, not tenant_id.
|
||||
export NOVA_PROJECT_ID=${TENANT:-demo}
|
||||
|
||||
# In addition to the owning entity (tenant), nova stores the entity performing
|
||||
# the action as the **user**.
|
||||
export NOVA_USERNAME=${USERNAME:-demo}
|
||||
|
||||
# With Keystone you pass the keystone password instead of an api key.
|
||||
export NOVA_API_KEY=${ADMIN_PASSWORD:-secrete}
|
||||
|
||||
# With the addition of Keystone, to use an openstack cloud you should
|
||||
# authenticate against keystone, which returns a **Token** and **Service
|
||||
# Catalog**. The catalog contains the endpoint for all services the user/tenant
|
||||
# has access to - including nova, glance, keystone, swift, ... We currently
|
||||
# recommend using the 2.0 *auth api*.
|
||||
#
|
||||
# *NOTE*: Using the 2.0 *auth api* does not mean that compute api is 2.0. We
|
||||
# will use the 1.1 *compute api*
|
||||
export NOVA_URL=${NOVA_URL:-http://$HOST_IP:5000/v2.0/}
|
||||
|
||||
# Currently novaclient needs you to specify the *compute api* version. This
|
||||
# needs to match the config of your catalog returned by Keystone.
|
||||
export NOVA_VERSION=${NOVA_VERSION:-1.1}
|
||||
|
||||
# FIXME - why does this need to be specified?
|
||||
export NOVA_REGION_NAME=${NOVA_REGION_NAME:-RegionOne}
|
||||
|
||||
# Set the ec2 url so euca2ools works
|
||||
export EC2_URL=${EC2_URL:-http://$HOST_IP:8773/services/Cloud}
|
||||
|
||||
# Access key is set in the initial keystone data to be the same as username
|
||||
export EC2_ACCESS_KEY=${USERNAME:-demo}
|
||||
|
||||
# Secret key is set in the initial keystone data to the admin password
|
||||
export EC2_SECRET_KEY=${ADMIN_PASSWORD:-secrete}
|
||||
|
||||
# set log level to DEBUG (helps debug issues)
|
||||
# export NOVACLIENT_DEBUG=1
|
||||
|
@ -0,0 +1,159 @@
|
||||
#!/bin/bash
|
||||
# get_uec_image.sh - Prepare Ubuntu images in various formats
|
||||
#
|
||||
# Supported formats: qcow (kvm), vmdk (vmserver), vdi (vbox), vhd (vpc), raw
|
||||
#
|
||||
# Required to run as root
|
||||
|
||||
CACHEDIR=${CACHEDIR:-/var/cache/devstack}
|
||||
FORMAT=${FORMAT:-qcow2}
|
||||
ROOTSIZE=${ROOTSIZE:-2000}
|
||||
MIN_PKGS=${MIN_PKGS:-"apt-utils gpgv openssh-server"}
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 - Prepare Ubuntu images"
|
||||
echo ""
|
||||
echo "$0 [-f format] [-r rootsize] release imagefile"
|
||||
echo ""
|
||||
echo "-f format - image format: qcow2 (default), vmdk, vdi, vhd, xen, raw, fs"
|
||||
echo "-r size - root fs size in MB (min 2000MB)"
|
||||
echo "release - Ubuntu release: jaunty - oneric"
|
||||
echo "imagefile - output image file"
|
||||
exit 1
|
||||
}
|
||||
|
||||
while getopts f:hmr: c; do
|
||||
case $c in
|
||||
f) FORMAT=$OPTARG
|
||||
;;
|
||||
h) usage
|
||||
;;
|
||||
m) MINIMAL=1
|
||||
;;
|
||||
r) ROOTSIZE=$OPTARG
|
||||
if $(( ROOTSIZE < 2000 )); then
|
||||
echo "root size must be greater than 2000MB"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift `expr $OPTIND - 1`
|
||||
|
||||
if [ ! "$#" -eq "2" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
# Default args
|
||||
DIST_NAME=$1
|
||||
IMG_FILE=$2
|
||||
|
||||
case $FORMAT in
|
||||
kvm|qcow2) FORMAT=qcow2
|
||||
QFORMAT=qcow2
|
||||
;;
|
||||
vmserver|vmdk)
|
||||
FORMAT=vmdk
|
||||
QFORMAT=vmdk
|
||||
;;
|
||||
vbox|vdi) FORMAT=vdi
|
||||
QFORMAT=vdi
|
||||
;;
|
||||
vhd|vpc) FORMAT=vhd
|
||||
QFORMAT=vpc
|
||||
;;
|
||||
xen) FORMAT=raw
|
||||
QFORMAT=raw
|
||||
;;
|
||||
raw) FORMAT=raw
|
||||
QFORMAT=raw
|
||||
;;
|
||||
*) echo "Unknown format: $FORMAT"
|
||||
usage
|
||||
esac
|
||||
|
||||
case $DIST_NAME in
|
||||
oneiric) ;;
|
||||
natty) ;;
|
||||
maverick) ;;
|
||||
lucid) ;;
|
||||
karmic) ;;
|
||||
jaunty) ;;
|
||||
*) echo "Unknown release: $DIST_NAME"
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
# Set up nbd
|
||||
modprobe nbd max_part=63
|
||||
NBD=${NBD:-/dev/nbd9}
|
||||
NBD_DEV=`basename $NBD`
|
||||
|
||||
# Prepare the base image
|
||||
|
||||
# Get the UEC image
|
||||
UEC_NAME=$DIST_NAME-server-cloudimg-amd64
|
||||
if [ ! -e $CACHEDIR/$UEC_NAME-disk1.img ]; then
|
||||
(cd $CACHEDIR; wget -N http://uec-images.ubuntu.com/$DIST_NAME/current/$UEC_NAME-disk1.img)
|
||||
|
||||
|
||||
# Connect to nbd and wait till it is ready
|
||||
qemu-nbd -d $NBD
|
||||
qemu-nbd -c $NBD $CACHEDIR/$UEC_NAME-disk1.img
|
||||
if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then
|
||||
echo "Couldn't connect $NBD"
|
||||
exit 1
|
||||
fi
|
||||
MNTDIR=`mktemp -d mntXXXXXXXX`
|
||||
mount -t ext4 ${NBD}p1 $MNTDIR
|
||||
|
||||
# Install our required packages
|
||||
cp -p files/sources.list $MNTDIR/etc/apt/sources.list
|
||||
cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf
|
||||
chroot $MNTDIR apt-get update
|
||||
chroot $MNTDIR apt-get install -y $MIN_PKGS
|
||||
rm -f $MNTDIR/etc/resolv.conf
|
||||
|
||||
umount $MNTDIR
|
||||
rmdir $MNTDIR
|
||||
qemu-nbd -d $NBD
|
||||
fi
|
||||
|
||||
if [ "$FORMAT" = "qcow2" ]; then
|
||||
# Just copy image
|
||||
cp -p $CACHEDIR/$UEC_NAME-disk1.img $IMG_FILE
|
||||
else
|
||||
# Convert image
|
||||
qemu-img convert -O $QFORMAT $CACHEDIR/$UEC_NAME-disk1.img $IMG_FILE
|
||||
fi
|
||||
|
||||
# Resize the image if necessary
|
||||
if [ $ROOTSIZE -gt 2000 ]; then
|
||||
# Resize the container
|
||||
qemu-img resize $IMG_FILE +$((ROOTSIZE - 2000))M
|
||||
fi
|
||||
|
||||
# Connect to nbd and wait till it is ready
|
||||
qemu-nbd -c $NBD $IMG_FILE
|
||||
if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then
|
||||
echo "Couldn't connect $NBD"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Resize partition 1 to full size of the disk image
|
||||
echo "d
|
||||
n
|
||||
p
|
||||
1
|
||||
2
|
||||
|
||||
t
|
||||
83
|
||||
a
|
||||
1
|
||||
w
|
||||
" | fdisk $NBD
|
||||
fsck -t ext4 -f ${NBD}p1
|
||||
resize2fs ${NBD}p1
|
||||
|
||||
qemu-nbd -d $NBD
|
Loading…
Reference in New Issue