initial cleanup

main
josch 13 years ago
parent 1a52a02f10
commit e8580757bb

@ -1,40 +0,0 @@
#!/usr/bin/env bash
# Test swift via the command line tools that ship with it.
# This script exits on an error so that errors don't compound and you see
# only the first error that occured.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
# Settings
# ========
# Use openrc + stackrc + localrc for settings
pushd $(cd $(dirname "$0")/.. && pwd)
source ./openrc
popd
# Testing Swift
# =============
# Check if we have to swift via keystone
swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD stat
# We start by creating a test container
swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD post testcontainer
# add some files into it.
swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD upload testcontainer /etc/issue
# list them
swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD list testcontainer
# And we may want to delete them now that we have tested that
# everything works.
swift --auth-version 2 -A http://${HOST_IP}:5000/v2.0 -U admin -K $ADMIN_PASSWORD delete testcontainer

@ -1,28 +0,0 @@
<VirtualHost *:80>
WSGIScriptAlias / %HORIZON_DIR%/openstack-dashboard/dashboard/wsgi/django.wsgi
WSGIDaemonProcess horizon user=%USER% group=%USER% processes=3 threads=10
SetEnv APACHE_RUN_USER %USER%
SetEnv APACHE_RUN_GROUP %USER%
WSGIProcessGroup horizon
DocumentRoot %HORIZON_DIR%/.blackhole/
Alias /media %HORIZON_DIR%/openstack-dashboard/dashboard/static
Alias /vpn /opt/stack/vpn
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory %HORIZON_DIR%/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>

@ -1,20 +0,0 @@
apache2 # NOPRIME
libapache2-mod-wsgi # NOPRIME
python-dateutil
python-paste
python-pastedeploy
python-anyjson
python-routes
python-xattr
python-sqlalchemy
python-webob
python-kombu
pylint
pep8
python-eventlet
python-nose
python-sphinx
python-mox
python-kombu
python-coverage
python-cherrypy3 # why?

@ -1,17 +0,0 @@
curl
gcc
memcached # NOPRIME
python-configobj
python-coverage
python-dev
python-eventlet
python-greenlet
python-netifaces
python-nose
python-pastedeploy
python-setuptools
python-simplejson
python-webob
python-xattr
sqlite3
xfsprogs

@ -1,110 +0,0 @@
import os
DEBUG = True
TEMPLATE_DEBUG = DEBUG
PROD = False
USE_SSL = False
LOCAL_PATH = os.path.dirname(os.path.abspath(__file__))
# FIXME: We need to change this to mysql, instead of sqlite.
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(LOCAL_PATH, 'dashboard_openstack.sqlite3'),
'TEST_NAME': os.path.join(LOCAL_PATH, 'test.sqlite3'),
},
}
# The default values for these two settings seem to cause issues with apache
CACHE_BACKEND = 'dummy://'
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
# Send email to the console by default
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# Or send them to /dev/null
#EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'
# django-mailer uses a different settings attribute
MAILER_EMAIL_BACKEND = EMAIL_BACKEND
# Configure these for your outgoing email host
# EMAIL_HOST = 'smtp.my-company.com'
# EMAIL_PORT = 25
# EMAIL_HOST_USER = 'djangomail'
# EMAIL_HOST_PASSWORD = 'top-secret!'
HORIZON_CONFIG = {
'dashboards': ('nova', 'syspanel', 'settings',),
'default_dashboard': 'nova',
'user_home': 'dashboard.views.user_home',
}
OPENSTACK_HOST = "127.0.0.1"
OPENSTACK_KEYSTONE_URL = "http://%s:5000/v2.0" % OPENSTACK_HOST
# FIXME: this is only needed until keystone fixes its GET /tenants call
# so that it doesn't return everything for admins
OPENSTACK_KEYSTONE_ADMIN_URL = "http://%s:35357/v2.0" % OPENSTACK_HOST
OPENSTACK_KEYSTONE_DEFAULT_ROLE = "Member"
SWIFT_PAGINATE_LIMIT = 100
# Configure quantum connection details for networking
QUANTUM_ENABLED = False
QUANTUM_URL = '%s' % OPENSTACK_HOST
QUANTUM_PORT = '9696'
QUANTUM_TENANT = '1234'
QUANTUM_CLIENT_VERSION='0.1'
# If you have external monitoring links, eg:
# EXTERNAL_MONITORING = [
# ['Nagios','http://foo.com'],
# ['Ganglia','http://bar.com'],
# ]
#LOGGING = {
# 'version': 1,
# # When set to True this will disable all logging except
# # for loggers specified in this configuration dictionary. Note that
# # if nothing is specified here and disable_existing_loggers is True,
# # django.db.backends will still log unless it is disabled explicitly.
# 'disable_existing_loggers': False,
# 'handlers': {
# 'null': {
# 'level': 'DEBUG',
# 'class': 'django.utils.log.NullHandler',
# },
# 'console': {
# # Set the level to "DEBUG" for verbose output logging.
# 'level': 'INFO',
# 'class': 'logging.StreamHandler',
# },
# },
# 'loggers': {
# # Logging from django.db.backends is VERY verbose, send to null
# # by default.
# 'django.db.backends': {
# 'handlers': ['null'],
# 'propagate': False,
# },
# 'horizon': {
# 'handlers': ['console'],
# 'propagate': False,
# },
# 'novaclient': {
# 'handlers': ['console'],
# 'propagate': False,
# },
# 'keystoneclient': {
# 'handlers': ['console'],
# 'propagate': False,
# },
# 'nose.plugins.manager': {
# 'handlers': ['console'],
# 'propagate': False,
# }
# }
#}
# How much ram on each compute host?
COMPUTE_HOST_RAM_GB = 16

@ -1,20 +0,0 @@
[DEFAULT]
devices = %NODE_PATH%/node
mount_check = false
bind_port = %BIND_PORT%
user = %USER%
log_facility = LOG_LOCAL%LOG_FACILITY%
swift_dir = %SWIFT_CONFIG_LOCATION%
[pipeline:main]
pipeline = account-server
[app:account-server]
use = egg:swift#account
[account-replicator]
vm_test_mode = yes
[account-auditor]
[account-reaper]

@ -1,22 +0,0 @@
[DEFAULT]
devices = %NODE_PATH%/node
mount_check = false
bind_port = %BIND_PORT%
user = %USER%
log_facility = LOG_LOCAL%LOG_FACILITY%
swift_dir = %SWIFT_CONFIG_LOCATION%
[pipeline:main]
pipeline = container-server
[app:container-server]
use = egg:swift#container
[container-replicator]
vm_test_mode = yes
[container-updater]
[container-auditor]
[container-sync]

@ -1,20 +0,0 @@
[DEFAULT]
devices = %NODE_PATH%/node
mount_check = false
bind_port = %BIND_PORT%
user = %USER%
log_facility = LOG_LOCAL%LOG_FACILITY%
swift_dir = %SWIFT_CONFIG_LOCATION%
[pipeline:main]
pipeline = object-server
[app:object-server]
use = egg:swift#object
[object-replicator]
vm_test_mode = yes
[object-updater]
[object-auditor]

@ -1,33 +0,0 @@
[DEFAULT]
bind_port = 8080
user = %USER%
log_facility = LOG_LOCAL1
swift_dir = %SWIFT_CONFIG_LOCATION%
[pipeline:main]
pipeline = healthcheck cache %AUTH_SERVER% proxy-server
[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true
[filter:keystone]
use = egg:swiftkeystone2#keystone2
keystone_admin_token = %SERVICE_TOKEN%
keystone_url = http://localhost:35357/v2.0
keystone_admin_group = Member
[filter:tempauth]
use = egg:swift#tempauth
user_admin_admin = admin .admin .reseller_admin
user_test_tester = testing .admin
user_test2_tester2 = testing2 .admin
user_test_tester3 = testing3
bind_ip = 0.0.0.0
[filter:healthcheck]
use = egg:swift#healthcheck
[filter:cache]
use = egg:swift#memcache

@ -1,79 +0,0 @@
uid = %USER%
gid = %GROUP%
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 127.0.0.1
[account6012]
max connections = 25
path = %SWIFT_DATA_LOCATION%/1/node/
read only = false
lock file = /var/lock/account6012.lock
[account6022]
max connections = 25
path = %SWIFT_DATA_LOCATION%/2/node/
read only = false
lock file = /var/lock/account6022.lock
[account6032]
max connections = 25
path = %SWIFT_DATA_LOCATION%/3/node/
read only = false
lock file = /var/lock/account6032.lock
[account6042]
max connections = 25
path = %SWIFT_DATA_LOCATION%/4/node/
read only = false
lock file = /var/lock/account6042.lock
[container6011]
max connections = 25
path = %SWIFT_DATA_LOCATION%/1/node/
read only = false
lock file = /var/lock/container6011.lock
[container6021]
max connections = 25
path = %SWIFT_DATA_LOCATION%/2/node/
read only = false
lock file = /var/lock/container6021.lock
[container6031]
max connections = 25
path = %SWIFT_DATA_LOCATION%/3/node/
read only = false
lock file = /var/lock/container6031.lock
[container6041]
max connections = 25
path = %SWIFT_DATA_LOCATION%/4/node/
read only = false
lock file = /var/lock/container6041.lock
[object6010]
max connections = 25
path = %SWIFT_DATA_LOCATION%/1/node/
read only = false
lock file = /var/lock/object6010.lock
[object6020]
max connections = 25
path = %SWIFT_DATA_LOCATION%/2/node/
read only = false
lock file = /var/lock/object6020.lock
[object6030]
max connections = 25
path = %SWIFT_DATA_LOCATION%/3/node/
read only = false
lock file = /var/lock/object6030.lock
[object6040]
max connections = 25
path = %SWIFT_DATA_LOCATION%/4/node/
read only = false
lock file = /var/lock/object6040.lock

@ -1,26 +0,0 @@
#!/bin/bash
cd %SWIFT_CONFIG_LOCATION%
rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
swift-ring-builder object.builder create %SWIFT_PARTITION_POWER_SIZE% 3 1
swift-ring-builder object.builder add z1-127.0.0.1:6010/sdb1 1
swift-ring-builder object.builder add z2-127.0.0.1:6020/sdb2 1
swift-ring-builder object.builder add z3-127.0.0.1:6030/sdb3 1
swift-ring-builder object.builder add z4-127.0.0.1:6040/sdb4 1
swift-ring-builder object.builder rebalance
swift-ring-builder container.builder create %SWIFT_PARTITION_POWER_SIZE% 3 1
swift-ring-builder container.builder add z1-127.0.0.1:6011/sdb1 1
swift-ring-builder container.builder add z2-127.0.0.1:6021/sdb2 1
swift-ring-builder container.builder add z3-127.0.0.1:6031/sdb3 1
swift-ring-builder container.builder add z4-127.0.0.1:6041/sdb4 1
swift-ring-builder container.builder rebalance
swift-ring-builder account.builder create %SWIFT_PARTITION_POWER_SIZE% 3 1
swift-ring-builder account.builder add z1-127.0.0.1:6012/sdb1 1
swift-ring-builder account.builder add z2-127.0.0.1:6022/sdb2 1
swift-ring-builder account.builder add z3-127.0.0.1:6032/sdb3 1
swift-ring-builder account.builder add z4-127.0.0.1:6042/sdb4 1
swift-ring-builder account.builder rebalance

@ -1,3 +0,0 @@
#!/bin/bash
swift-init all restart

@ -1,3 +0,0 @@
[swift-hash]
# random unique string that can never change (DO NOT LOSE)
swift_hash_path_suffix = %SWIFT_HASH%

@ -1,28 +0,0 @@
#!/usr/bin/env bash
# Build an OpenStack install on a bare metal machine.
set +x
# Source params
source ./stackrc
# Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
STACKSH_PARAMS=${STACKSH_PARAMS:-}
# Option to use the version of devstack on which we are currently working
USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
# Configure the runner
RUN_SH=`mktemp`
cat > $RUN_SH <<EOF
#!/usr/bin/env bash
# Install and run stack.sh
cd devstack
$STACKSH_PARAMS ./stack.sh
EOF
# Make the run.sh executable
chmod 755 $RUN_SH
scp -r . root@$CONTAINER_IP:devstack
scp $RUN_SH root@$CONTAINER_IP:$RUN_SH
ssh root@$CONTAINER_IP $RUN_SH

@ -1,37 +0,0 @@
#!/usr/bin/env bash
# Build an OpenStack install on several bare metal machines.
SHELL_AFTER_RUN=no
# Variables common amongst all hosts in the cluster
COMMON_VARS="MYSQL_HOST=$HEAD_HOST RABBIT_HOST=$HEAD_HOST GLANCE_HOSTPORT=$HEAD_HOST:9292 NET_MAN=FlatDHCPManager FLAT_INTERFACE=eth0 FLOATING_RANGE=$FLOATING_RANGE MULTI_HOST=1 SHELL_AFTER_RUN=$SHELL_AFTER_RUN"
# Helper to launch containers
function run_bm {
# For some reason container names with periods can cause issues :/
CONTAINER=$1 CONTAINER_IP=$2 CONTAINER_NETMASK=$NETMASK CONTAINER_GATEWAY=$GATEWAY NAMESERVER=$NAMESERVER TERMINATE=$TERMINATE STACKSH_PARAMS="$COMMON_VARS $3" ./tools/build_bm.sh
}
# Launch the head node - headnode uses a non-ip domain name,
# because rabbit won't launch with an ip addr hostname :(
run_bm STACKMASTER $HEAD_HOST "ENABLED_SERVICES=g-api,g-reg,key,n-api,n-sch,n-vnc,horizon,mysql,rabbit"
# Wait till the head node is up
if [ ! "$TERMINATE" = "1" ]; then
echo "Waiting for head node ($HEAD_HOST) to start..."
if ! timeout 60 sh -c "while ! wget -q -O- http://$HEAD_HOST | grep -q username; do sleep 1; done"; then
echo "Head node did not start"
exit 1
fi
fi
PIDS=""
# Launch the compute hosts in parallel
for compute_host in ${COMPUTE_HOSTS//,/ }; do
run_bm $compute_host $compute_host "ENABLED_SERVICES=n-cpu,n-net,n-api" &
PIDS="$PIDS $!"
done
for x in $PIDS; do
wait $x
done
echo "build_bm_multi complete"

@ -1,235 +0,0 @@
#!/usr/bin/env bash
#
# build_ci_config.sh - Build a config.ini for tempest (openstack-integration-tests)
# (https://github.com/openstack/tempest.git)
function usage {
echo "$0 - Build config.ini for tempest"
echo ""
echo "Usage: $0 [configdir]"
exit 1
}
if [ "$1" = "-h" ]; then
usage
fi
# Clean up any resources that may be in use
cleanup() {
set +o errexit
# Mop up temporary files
if [ -n "$CONFIG_CONF_TMP" -a -e "$CONFIG_CONF_TMP" ]; then
rm -f $CONFIG_CONF_TMP
fi
if [ -n "$CONFIG_INI_TMP" -a -e "$CONFIG_INI_TMP" ]; then
rm -f $CONFIG_INI_TMP
fi
# Kill ourselves to signal any calling process
trap 2; kill -2 $$
}
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
# Abort if localrc is not set
if [ ! -e $TOP_DIR/localrc ]; then
echo "You must have a localrc with ALL necessary passwords and configuration defined before proceeding."
echo "See stack.sh for required passwords."
exit 1
fi
# Source params
source ./stackrc
# Where Openstack code lives
DEST=${DEST:-/opt/stack}
CITEST_DIR=$DEST/tempest
CONFIG_DIR=${1:-$CITEST_DIR/etc}
CONFIG_CONF=$CONFIG_DIR/storm.conf
CONFIG_INI=$CONFIG_DIR/config.ini
DIST_NAME=${DIST_NAME:-oneiric}
# git clone only if directory doesn't exist already. Since ``DEST`` might not
# be owned by the installation user, we create the directory and change the
# ownership to the proper user.
function git_clone {
GIT_REMOTE=$1
GIT_DEST=$2
GIT_BRANCH=$3
# do a full clone only if the directory doesn't exist
if [ ! -d $GIT_DEST ]; then
git clone $GIT_REMOTE $GIT_DEST
cd $2
# This checkout syntax works for both branches and tags
git checkout $GIT_BRANCH
elif [[ "$RECLONE" == "yes" ]]; then
# if it does exist then simulate what clone does if asked to RECLONE
cd $GIT_DEST
# set the url to pull from and fetch
git remote set-url origin $GIT_REMOTE
git fetch origin
# remove the existing ignored files (like pyc) as they cause breakage
# (due to the py files having older timestamps than our pyc, so python
# thinks the pyc files are correct using them)
find $GIT_DEST -name '*.pyc' -delete
git checkout -f origin/$GIT_BRANCH
# a local branch might not exist
git branch -D $GIT_BRANCH || true
git checkout -b $GIT_BRANCH
fi
}
# Install tests and prerequisites
sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install --use-mirrors `cat $TOP_DIR/files/pips/tempest`
git_clone $CITEST_REPO $CITEST_DIR $CITEST_BRANCH
if [ ! -f $DEST/.ramdisk ]; then
# Process network configuration vars
GUEST_NETWORK=${GUEST_NETWORK:-1}
GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes}
GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50}
GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24}
GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0}
GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1}
GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"}
GUEST_RAM=${GUEST_RAM:-1524288}
GUEST_CORES=${GUEST_CORES:-1}
fi
# Use the GUEST_IP unless an explicit IP is set by ``HOST_IP``
HOST_IP=${HOST_IP:-$GUEST_IP}
# Use the first IP if HOST_IP still is not set
if [ ! -n "$HOST_IP" ]; then
HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
fi
RABBIT_HOST=${RABBIT_HOST:-localhost}
# Glance connection info. Note the port must be specified.
GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
set `echo $GLANCE_HOSTPORT | tr ':' ' '`
GLANCE_HOST=$1
GLANCE_PORT=$2
# Create storm.conf
CONFIG_CONF_TMP=$(mktemp $CONFIG_CONF.XXXXXX)
cat >$CONFIG_CONF_TMP <<EOF
[nova]
auth_url=http://$HOST_IP:5000/v2.0/tokens
user=admin
api_key=$ADMIN_PASSWORD
tenant_name=admin
ssh_timeout=300
build_interval=10
build_timeout=600
[environment]
image_ref=3
image_ref_alt=4
flavor_ref=1
flavor_ref_alt=2
create_image_enabled=true
resize_available=true
authentication=keystone_v2
EOF
mv $CONFIG_CONF_TMP $CONFIG_CONF
CONFIG_CONF_TMP=""
# Create config.ini
CONFIG_INI_TMP=$(mktemp $CONFIG_INI.XXXXXX)
if [ "$UPLOAD_LEGACY_TTY" ]; then
cat >$CONFIG_INI_TMP <<EOF
[environment]
aki_location = $DEST/devstack/files/images/aki-tty/image
ari_location = $DEST/devstack/files/images/ari-tty/image
ami_location = $DEST/devstack/files/images/ami-tty/image
image_ref = 3
image_ref_alt = 3
flavor_ref = 1
flavor_ref_alt = 2
[glance]
host = $GLANCE_HOST
apiver = v1
port = $GLANCE_PORT
image_id = 3
image_id_alt = 3
tenant_id = 1
EOF
else
cat >$CONFIG_INI_TMP <<EOF
[environment]
aki_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-vmlinuz-virtual
#ari_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64-loader
ami_location = $DEST/openstack-integration-tests/include/sample_vm/$DIST_NAME-server-cloudimg-amd64.img
image_ref = 2
image_ref_alt = 2
flavor_ref = 1
flavor_ref_alt = 2
[glance]
host = $GLANCE_HOST
apiver = v1
port = $GLANCE_PORT
image_id = 1
image_id_alt = 1
tenant_id = 1
EOF
fi
cat >>$CONFIG_INI_TMP <<EOF
[keystone]
service_host = $HOST_IP
service_port = 5000
apiver = v2.0
user = admin
password = $ADMIN_PASSWORD
tenant_id = 1
[nova]
host = $HOST_IP
port = 8774
apiver = v1.1
project = admin
user = admin
key = $ADMIN_PASSWORD
ssh_timeout = 300
build_timeout = 300
flavor_ref = 1
flavor_ref_alt = 2
multi_node = no
[rabbitmq]
host = $RABBIT_HOST
user = guest
password = $RABBIT_PASSWORD
[swift]
auth_host = $HOST_IP
auth_port = 443
auth_prefix = /auth/
auth_ssl = yes
account = system
username = root
password = password
EOF
mv $CONFIG_INI_TMP $CONFIG_INI
CONFIG_INI_TMP=""
trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT

@ -1,117 +0,0 @@
#!/bin/bash -e
# build_pxe_env.sh - Create a PXE boot environment
#
# build_pxe_env.sh destdir
#
# Requires Ubuntu Oneiric
#
# Only needs to run as root if the destdir permissions require it
dpkg -l syslinux || apt-get install -y syslinux
DEST_DIR=${1:-/tmp}/tftpboot
PXEDIR=${PXEDIR:-/opt/ramstack/pxe}
PROGDIR=`dirname $0`
# Clean up any resources that may be in use
cleanup() {
set +o errexit
# Mop up temporary files
if [ -n "$MNTDIR" -a -d "$MNTDIR" ]; then
umount $MNTDIR
rmdir $MNTDIR
fi
# Kill ourselves to signal any calling process
trap 2; kill -2 $$
}
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
mkdir -p $DEST_DIR/pxelinux.cfg
cd $DEST_DIR
for i in memdisk menu.c32 pxelinux.0; do
cp -pu /usr/lib/syslinux/$i $DEST_DIR
done
CFG=$DEST_DIR/pxelinux.cfg/default
cat >$CFG <<EOF
default menu.c32
prompt 0
timeout 0
MENU TITLE devstack PXE Boot Menu
EOF
# Setup devstack boot
mkdir -p $DEST_DIR/ubuntu
if [ ! -d $PXEDIR ]; then
mkdir -p $PXEDIR
fi
# Get image into place
if [ ! -r $PXEDIR/stack-initrd.img ]; then
cd $TOP_DIR
$PROGDIR/build_ramdisk.sh $PXEDIR/stack-initrd.img
fi
if [ ! -r $PXEDIR/stack-initrd.gz ]; then
gzip -1 -c $PXEDIR/stack-initrd.img >$PXEDIR/stack-initrd.gz
fi
cp -pu $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu
if [ ! -r $PXEDIR/vmlinuz-*-generic ]; then
MNTDIR=`mktemp -d --tmpdir mntXXXXXXXX`
mount -t ext4 -o loop $PXEDIR/stack-initrd.img $MNTDIR
if [ ! -r $MNTDIR/boot/vmlinuz-*-generic ]; then
echo "No kernel found"
umount $MNTDIR
rmdir $MNTDIR
exit 1
else
cp -pu $MNTDIR/boot/vmlinuz-*-generic $PXEDIR
fi
umount $MNTDIR
rmdir $MNTDIR
fi
# Get generic kernel version
KNAME=`basename $PXEDIR/vmlinuz-*-generic`
KVER=${KNAME#vmlinuz-}
cp -pu $PXEDIR/vmlinuz-$KVER $DEST_DIR/ubuntu
cat >>$CFG <<EOF
LABEL devstack
MENU LABEL ^devstack
MENU DEFAULT
KERNEL ubuntu/vmlinuz-$KVER
APPEND initrd=ubuntu/stack-initrd.gz ramdisk_size=2109600 root=/dev/ram0
EOF
# Get Ubuntu
if [ -d $PXEDIR -a -r $PXEDIR/natty-base-initrd.gz ]; then
cp -pu $PXEDIR/natty-base-initrd.gz $DEST_DIR/ubuntu
cat >>$CFG <<EOF
LABEL ubuntu
MENU LABEL ^Ubuntu Natty
KERNEL ubuntu/vmlinuz-$KVER
APPEND initrd=ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0
EOF
fi
# Local disk boot
cat >>$CFG <<EOF
LABEL local
MENU LABEL ^Local disk
LOCALBOOT 0
EOF
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT

@ -1,254 +0,0 @@
#!/bin/bash
# build_ramdisk.sh - Build RAM disk images
# exit on error to stop unexpected errors
set -o errexit
if [ ! "$#" -eq "1" ]; then
echo "$0 builds a gziped Ubuntu OpenStack install"
echo "usage: $0 dest"
exit 1
fi
# Clean up any resources that may be in use
cleanup() {
set +o errexit
# Mop up temporary files
if [ -n "$MNTDIR" -a -d "$MNTDIR" ]; then
umount $MNTDIR
rmdir $MNTDIR
fi
if [ -n "$DEV_FILE_TMP" -a -e "$DEV_FILE_TMP "]; then
rm -f $DEV_FILE_TMP
fi
if [ -n "$IMG_FILE_TMP" -a -e "$IMG_FILE_TMP" ]; then
rm -f $IMG_FILE_TMP
fi
# Release NBD devices
if [ -n "$NBD" ]; then
qemu-nbd -d $NBD
fi
# Kill ourselves to signal any calling process
trap 2; kill -2 $$
}
trap cleanup SIGHUP SIGINT SIGTERM
# Set up nbd
modprobe nbd max_part=63
# Echo commands
set -o xtrace
IMG_FILE=$1
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
# Store cwd
CWD=`pwd`
cd $TOP_DIR
# Source params
source ./stackrc
CACHEDIR=${CACHEDIR:-/opt/stack/cache}
DEST=${DEST:-/opt/stack}
# Configure the root password of the vm to be the same as ``ADMIN_PASSWORD``
ROOT_PASSWORD=${ADMIN_PASSWORD:-password}
# Base image (natty by default)
DIST_NAME=${DIST_NAME:-natty}
# Param string to pass to stack.sh. Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
STACKSH_PARAMS=${STACKSH_PARAMS:-}
# Option to use the version of devstack on which we are currently working
USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
# clean install
if [ ! -r $CACHEDIR/$DIST_NAME-base.img ]; then
$TOOLS_DIR/get_uec_image.sh $DIST_NAME $CACHEDIR/$DIST_NAME-base.img
fi
# Finds the next available NBD device
# Exits script if error connecting or none free
# map_nbd image
# returns full nbd device path
function map_nbd {
for i in `seq 0 15`; do
if [ ! -e /sys/block/nbd$i/pid ]; then
NBD=/dev/nbd$i
# Connect to nbd and wait till it is ready
qemu-nbd -c $NBD $1
if ! timeout 60 sh -c "while ! [ -e ${NBD}p1 ]; do sleep 1; done"; then
echo "Couldn't connect $NBD"
exit 1
fi
break
fi
done
if [ -z "$NBD" ]; then
echo "No free NBD slots"
exit 1
fi
echo $NBD
}
# prime image with as many apt/pips as we can
DEV_FILE=$CACHEDIR/$DIST_NAME-dev.img
DEV_FILE_TMP=`mktemp $DEV_FILE.XXXXXX`
if [ ! -r $DEV_FILE ]; then
cp -p $CACHEDIR/$DIST_NAME-base.img $DEV_FILE_TMP
NBD=`map_nbd $DEV_FILE_TMP`
MNTDIR=`mktemp -d --tmpdir mntXXXXXXXX`
mount -t ext4 ${NBD}p1 $MNTDIR
cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf
chroot $MNTDIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1`
chroot $MNTDIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1`
chroot $MNTDIR pip install `cat files/pips/*`
# Create a stack user that is a member of the libvirtd group so that stack
# is able to interact with libvirt.
chroot $MNTDIR groupadd libvirtd
chroot $MNTDIR useradd stack -s /bin/bash -d $DEST -G libvirtd
mkdir -p $MNTDIR/$DEST
chroot $MNTDIR chown stack $DEST
# a simple password - pass
echo stack:pass | chroot $MNTDIR chpasswd
echo root:$ROOT_PASSWORD | chroot $MNTDIR chpasswd
# and has sudo ability (in the future this should be limited to only what
# stack requires)
echo "stack ALL=(ALL) NOPASSWD: ALL" >> $MNTDIR/etc/sudoers
umount $MNTDIR
rmdir $MNTDIR
qemu-nbd -d $NBD
NBD=""
mv $DEV_FILE_TMP $DEV_FILE
fi
rm -f $DEV_FILE_TMP
# clone git repositories onto the system
# ======================================
IMG_FILE_TMP=`mktemp $IMG_FILE.XXXXXX`
if [ ! -r $IMG_FILE ]; then
NBD=`map_nbd $DEV_FILE`
# Pre-create the image file
# FIXME(dt): This should really get the partition size to
# pre-create the image file
dd if=/dev/zero of=$IMG_FILE_TMP bs=1 count=1 seek=$((2*1024*1024*1024))
# Create filesystem image for RAM disk
dd if=${NBD}p1 of=$IMG_FILE_TMP bs=1M
qemu-nbd -d $NBD
NBD=""
mv $IMG_FILE_TMP $IMG_FILE
fi
rm -f $IMG_FILE_TMP
MNTDIR=`mktemp -d --tmpdir mntXXXXXXXX`
mount -t ext4 -o loop $IMG_FILE $MNTDIR
cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf
# We need to install a non-virtual kernel and modules to boot from
if [ ! -r "`ls $MNTDIR/boot/vmlinuz-*-generic | head -1`" ]; then
chroot $MNTDIR apt-get install -y linux-generic
fi
# git clone only if directory doesn't exist already. Since ``DEST`` might not
# be owned by the installation user, we create the directory and change the
# ownership to the proper user.
function git_clone {
# clone new copy or fetch latest changes
CHECKOUT=${MNTDIR}$2
if [ ! -d $CHECKOUT ]; then
mkdir -p $CHECKOUT
git clone $1 $CHECKOUT
else
pushd $CHECKOUT
git fetch
popd
fi
# FIXME(ja): checkout specified version (should works for branches and tags)
pushd $CHECKOUT
# checkout the proper branch/tag
git checkout $3
# force our local version to be the same as the remote version
git reset --hard origin/$3
popd
# give ownership to the stack user
chroot $MNTDIR chown -R stack $2
}
git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
git_clone $HORIZON_REPO $DEST/horizon $HORIZON_BRANCH
git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
# Use this version of devstack
rm -rf $MNTDIR/$DEST/devstack
cp -pr $CWD $MNTDIR/$DEST/devstack
chroot $MNTDIR chown -R stack $DEST/devstack
# Configure host network for DHCP
mkdir -p $MNTDIR/etc/network
cat > $MNTDIR/etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
EOF
# Set hostname
echo "ramstack" >$MNTDIR/etc/hostname
echo "127.0.0.1 localhost ramstack" >$MNTDIR/etc/hosts
# Configure the runner
RUN_SH=$MNTDIR/$DEST/run.sh
cat > $RUN_SH <<EOF
#!/usr/bin/env bash
# Get IP range
set \`ip addr show dev eth0 | grep inet\`
PREFIX=\`echo \$2 | cut -d. -f1,2,3\`
export FLOATING_RANGE="\$PREFIX.224/27"
# Kill any existing screens
killall screen
# Run stack.sh
cd $DEST/devstack && \$STACKSH_PARAMS ./stack.sh > $DEST/run.sh.log
echo >> $DEST/run.sh.log
echo >> $DEST/run.sh.log
echo "All done! Time to start clicking." >> $DEST/run.sh.log
EOF
# Make the run.sh executable
chmod 755 $RUN_SH
chroot $MNTDIR chown stack $DEST/run.sh
umount $MNTDIR
rmdir $MNTDIR

@ -1,300 +0,0 @@
#!/usr/bin/env bash
# Make sure that we have the proper version of ubuntu (only works on oneiric)
if ! egrep -q "oneiric" /etc/lsb-release; then
echo "This script only works with ubuntu oneiric."
exit 1
fi
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
cd $TOP_DIR
# Source params
source ./stackrc
# Ubuntu distro to install
DIST_NAME=${DIST_NAME:-oneiric}
# Configure how large the VM should be
GUEST_SIZE=${GUEST_SIZE:-10G}
# exit on error to stop unexpected errors
set -o errexit
set -o xtrace
# Abort if localrc is not set
if [ ! -e $TOP_DIR/localrc ]; then
echo "You must have a localrc with ALL necessary passwords defined before proceeding."
echo "See stack.sh for required passwords."
exit 1
fi
# Install deps if needed
DEPS="kvm libvirt-bin kpartx cloud-utils curl"
apt-get install -y --force-yes $DEPS || true # allow this to fail gracefully for concurrent builds
# Where to store files and instances
WORK_DIR=${WORK_DIR:-/opt/uecstack}
# Where to store images
image_dir=$WORK_DIR/images/$DIST_NAME
mkdir -p $image_dir
# Start over with a clean base image, if desired
if [ $CLEAN_BASE ]; then
rm -f $image_dir/disk
fi
# Get the base image if it does not yet exist
if [ ! -e $image_dir/disk ]; then
$TOOLS_DIR/get_uec_image.sh -r $GUEST_SIZE $DIST_NAME $image_dir/disk $image_dir/kernel
fi
# Copy over dev environment if COPY_ENV is set.
# This will also copy over your current devstack.
if [ $COPY_ENV ]; then
cd $TOOLS_DIR
./copy_dev_environment_to_uec.sh $image_dir/disk
fi
# Option to warm the base image with software requirements.
if [ $WARM_CACHE ]; then
cd $TOOLS_DIR
./warm_apts_and_pips_for_uec.sh $image_dir/disk
fi
# Name of our instance, used by libvirt
GUEST_NAME=${GUEST_NAME:-devstack}
# Mop up after previous runs
virsh destroy $GUEST_NAME || true
# Where this vm is stored
vm_dir=$WORK_DIR/instances/$GUEST_NAME
# Create vm dir and remove old disk
mkdir -p $vm_dir
rm -f $vm_dir/disk
# Create a copy of the base image
qemu-img create -f qcow2 -b $image_dir/disk $vm_dir/disk
# Back to devstack
cd $TOP_DIR
GUEST_NETWORK=${GUEST_NETWORK:-1}
GUEST_RECREATE_NET=${GUEST_RECREATE_NET:-yes}
GUEST_IP=${GUEST_IP:-192.168.$GUEST_NETWORK.50}
GUEST_CIDR=${GUEST_CIDR:-$GUEST_IP/24}
GUEST_NETMASK=${GUEST_NETMASK:-255.255.255.0}
GUEST_GATEWAY=${GUEST_GATEWAY:-192.168.$GUEST_NETWORK.1}
GUEST_MAC=${GUEST_MAC:-"02:16:3e:07:69:`printf '%02X' $GUEST_NETWORK`"}
GUEST_RAM=${GUEST_RAM:-1524288}
GUEST_CORES=${GUEST_CORES:-1}
# libvirt.xml configuration
NET_XML=$vm_dir/net.xml
NET_NAME=${NET_NAME:-devstack-$GUEST_NETWORK}
cat > $NET_XML <<EOF
<network>
<name>$NET_NAME</name>
<bridge name="stackbr%d" />
<forward/>
<ip address="$GUEST_GATEWAY" netmask="$GUEST_NETMASK">
<dhcp>
<range start='192.168.$GUEST_NETWORK.2' end='192.168.$GUEST_NETWORK.127' />
</dhcp>
</ip>
</network>
EOF
if [[ "$GUEST_RECREATE_NET" == "yes" ]]; then
virsh net-destroy $NET_NAME || true
# destroying the network isn't enough to delete the leases
rm -f /var/lib/libvirt/dnsmasq/$NET_NAME.leases
virsh net-create $vm_dir/net.xml
fi
# libvirt.xml configuration
LIBVIRT_XML=$vm_dir/libvirt.xml
cat > $LIBVIRT_XML <<EOF
<domain type='kvm'>
<name>$GUEST_NAME</name>
<memory>$GUEST_RAM</memory>
<os>
<type>hvm</type>
<kernel>$image_dir/kernel</kernel>
<cmdline>root=/dev/vda ro console=ttyS0 init=/usr/lib/cloud-init/uncloud-init ds=nocloud-net;s=http://192.168.$GUEST_NETWORK.1:4567/ ubuntu-pass=ubuntu</cmdline>
</os>
<features>
<acpi/>
</features>
<clock offset='utc'/>
<vcpu>$GUEST_CORES</vcpu>
<devices>
<disk type='file'>
<driver type='qcow2'/>
<source file='$vm_dir/disk'/>
<target dev='vda' bus='virtio'/>
</disk>
<interface type='network'>
<source network='$NET_NAME'/>
</interface>
<!-- The order is significant here. File must be defined first -->
<serial type="file">
<source path='$vm_dir/console.log'/>
<target port='1'/>
</serial>
<console type='pty' tty='/dev/pts/2'>
<source path='/dev/pts/2'/>
<target port='0'/>
</console>
<serial type='pty'>
<source path='/dev/pts/2'/>
<target port='0'/>
</serial>
<graphics type='vnc' port='-1' autoport='yes' keymap='en-us' listen='0.0.0.0'/>
</devices>
</domain>
EOF
rm -rf $vm_dir/uec
cp -r $TOOLS_DIR/uec $vm_dir/uec
# set metadata
cat > $vm_dir/uec/meta-data<<EOF
hostname: $GUEST_NAME
instance-id: i-hop
instance-type: m1.ignore
local-hostname: $GUEST_NAME.local
EOF
# set user-data
cat > $vm_dir/uec/user-data<<EOF
#!/bin/bash
# hostname needs to resolve for rabbit
sed -i "s/127.0.0.1/127.0.0.1 \`hostname\`/" /etc/hosts
apt-get update
apt-get install git sudo -y
if [ ! -d devstack ]; then
git clone https://github.com/cloudbuilders/devstack.git
cd devstack
git remote set-url origin `cd $TOP_DIR; git remote show origin | grep Fetch | awk '{print $3}'`
git fetch
git checkout `git rev-parse HEAD`
cat > localrc <<LOCAL_EOF
ROOTSLEEP=0
`cat $TOP_DIR/localrc`
LOCAL_EOF
fi
# Disable byobu
sudo apt-get remove -y byobu
EOF
# Setup stack user with our key
if [[ -e ~/.ssh/id_rsa.pub ]]; then
PUB_KEY=`cat ~/.ssh/id_rsa.pub`
cat >> $vm_dir/uec/user-data<<EOF
mkdir -p /opt/stack
useradd -U -G sudo -s /bin/bash -d /opt/stack -m stack
echo stack:pass | chpasswd
mkdir -p /opt/stack/.ssh
echo "$PUB_KEY" > /opt/stack/.ssh/authorized_keys
chown -R stack /opt/stack
chmod 700 /opt/stack/.ssh
chmod 600 /opt/stack/.ssh/authorized_keys
grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||
echo "#includedir /etc/sudoers.d" >> /etc/sudoers
( umask 226 && echo "stack ALL=(ALL) NOPASSWD:ALL" \
> /etc/sudoers.d/50_stack_sh )
EOF
fi
# Run stack.sh
cat >> $vm_dir/uec/user-data<<EOF
./stack.sh
EOF
# (re)start a metadata service
(
pid=`lsof -iTCP@192.168.$GUEST_NETWORK.1:4567 -n | awk '{print $2}' | tail -1`
[ -z "$pid" ] || kill -9 $pid
)
cd $vm_dir/uec
python meta.py 192.168.$GUEST_NETWORK.1:4567 &
# Create the instance
virsh create $vm_dir/libvirt.xml
# Tail the console log till we are done
WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1}
if [ "$WAIT_TILL_LAUNCH" = "1" ]; then
set +o xtrace
# Done creating the container, let's tail the log
echo
echo "============================================================="
echo " -- YAY! --"
echo "============================================================="
echo
echo "We're done launching the vm, about to start tailing the"
echo "stack.sh log. It will take a second or two to start."
echo
echo "Just CTRL-C at any time to stop tailing."
echo
if ! timeout 60 sh -c "while [ ! -s /var/lib/libvirt/dnsmasq/$NET_NAME.leases ]; do sleep 1; done"; then
echo "Your instance failed to acquire an IP address"
exit 1
fi
ip=`cat /var/lib/libvirt/dnsmasq/$NET_NAME.leases | cut -d " " -f3`
echo "#############################################################"
echo " -- This is your instance's IP: --"
echo " $ip"
echo "#############################################################"
sleep 2
while [ ! -e "$vm_dir/console.log" ]; do
sleep 1
done
tail -F $vm_dir/console.log &
TAIL_PID=$!
function kill_tail() {
kill $TAIL_PID
exit 1
}
# Let Ctrl-c kill tail and exit
trap kill_tail SIGINT
echo "Waiting stack.sh to finish..."
while ! egrep -q '^stack.sh (completed|failed)' $vm_dir/console.log ; do
sleep 1
done
set -o xtrace
kill $TAIL_PID
if ! grep -q "^stack.sh completed in" $vm_dir/console.log; then
exit 1
fi
set +o xtrace
echo ""
echo "Finished - Zip-a-dee Doo-dah!"
fi

@ -1,203 +0,0 @@
#!/usr/bin/env bash
# build_uec_ramdisk.sh - Build RAM disk images based on UEC image
# exit on error to stop unexpected errors
set -o errexit
if [ ! "$#" -eq "1" ]; then
echo "$0 builds a gziped Ubuntu OpenStack install"
echo "usage: $0 dest"
exit 1
fi
# Make sure that we have the proper version of ubuntu (only works on oneiric)
if ! egrep -q "oneiric" /etc/lsb-release; then
echo "This script only works with ubuntu oneiric."
exit 1
fi
# Clean up resources that may be in use
cleanup() {
set +o errexit
if [ -n "$MNT_DIR" ]; then
umount $MNT_DIR/dev
umount $MNT_DIR
fi
if [ -n "$DEST_FILE_TMP" ]; then
rm $DEST_FILE_TMP
fi
# Kill ourselves to signal parents
trap 2; kill -2 $$
}
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
# Output dest image
DEST_FILE=$1
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
cd $TOP_DIR
# Source params
source ./stackrc
DEST=${DEST:-/opt/stack}
# Ubuntu distro to install
DIST_NAME=${DIST_NAME:-oneiric}
# Configure how large the VM should be
GUEST_SIZE=${GUEST_SIZE:-2G}
# exit on error to stop unexpected errors
set -o errexit
set -o xtrace
# Abort if localrc is not set
if [ ! -e $TOP_DIR/localrc ]; then
echo "You must have a localrc with ALL necessary passwords defined before proceeding."
echo "See stack.sh for required passwords."
exit 1
fi
# Install deps if needed
DEPS="kvm libvirt-bin kpartx cloud-utils curl"
apt-get install -y --force-yes $DEPS
# Where to store files and instances
CACHEDIR=${CACHEDIR:-/opt/stack/cache}
WORK_DIR=${WORK_DIR:-/opt/ramstack}
# Where to store images
image_dir=$WORK_DIR/images/$DIST_NAME
mkdir -p $image_dir
# Get the base image if it does not yet exist
if [ ! -e $image_dir/disk ]; then
$TOOLS_DIR/get_uec_image.sh -r 2000M $DIST_NAME $image_dir/disk
fi
# Configure the root password of the vm to be the same as ``ADMIN_PASSWORD``
ROOT_PASSWORD=${ADMIN_PASSWORD:-password}
# Name of our instance, used by libvirt
GUEST_NAME=${GUEST_NAME:-devstack}
# Pre-load the image with basic environment
if [ ! -e $image_dir/disk-primed ]; then
cp $image_dir/disk $image_dir/disk-primed
$TOOLS_DIR/warm_apts_and_pips_for_uec.sh $image_dir/disk-primed
$TOOLS_DIR/copy_dev_environment_to_uec.sh $image_dir/disk-primed
fi
# Back to devstack
cd $TOP_DIR
DEST_FILE_TMP=`mktemp $DEST_FILE.XXXXXX`
MNT_DIR=`mktemp -d --tmpdir mntXXXXXXXX`
cp $image_dir/disk-primed $DEST_FILE_TMP
mount -t ext4 -o loop $DEST_FILE_TMP $MNT_DIR
mount -o bind /dev /$MNT_DIR/dev
cp -p /etc/resolv.conf $MNT_DIR/etc/resolv.conf
echo root:$ROOT_PASSWORD | chroot $MNT_DIR chpasswd
touch $MNT_DIR/$DEST/.ramdisk
# We need to install a non-virtual kernel and modules to boot from
if [ ! -r "`ls $MNT_DIR/boot/vmlinuz-*-generic | head -1`" ]; then
chroot $MNT_DIR apt-get install -y linux-generic
fi
# git clone only if directory doesn't exist already. Since ``DEST`` might not
# be owned by the installation user, we create the directory and change the
# ownership to the proper user.
function git_clone {
# clone new copy or fetch latest changes
CHECKOUT=${MNT_DIR}$2
if [ ! -d $CHECKOUT ]; then
mkdir -p $CHECKOUT
git clone $1 $CHECKOUT
else
pushd $CHECKOUT
git fetch
popd
fi
# FIXME(ja): checkout specified version (should works for branches and tags)
pushd $CHECKOUT
# checkout the proper branch/tag
git checkout $3
# force our local version to be the same as the remote version
git reset --hard origin/$3
popd
# give ownership to the stack user
chroot $MNT_DIR chown -R stack $2
}
git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
git_clone $HORIZON_REPO $DEST/horizon $HORIZON_BRANCH
git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
git_clone $CITEST_REPO $DEST/tempest $CITEST_BRANCH
# Use this version of devstack
rm -rf $MNT_DIR/$DEST/devstack
cp -pr $TOP_DIR $MNT_DIR/$DEST/devstack
chroot $MNT_DIR chown -R stack $DEST/devstack
# Configure host network for DHCP
mkdir -p $MNT_DIR/etc/network
cat > $MNT_DIR/etc/network/interfaces <<EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
EOF
# Set hostname
echo "ramstack" >$MNT_DIR/etc/hostname
echo "127.0.0.1 localhost ramstack" >$MNT_DIR/etc/hosts
# Configure the runner
RUN_SH=$MNT_DIR/$DEST/run.sh
cat > $RUN_SH <<EOF
#!/usr/bin/env bash
# Get IP range
set \`ip addr show dev eth0 | grep inet\`
PREFIX=\`echo \$2 | cut -d. -f1,2,3\`
export FLOATING_RANGE="\$PREFIX.224/27"
# Kill any existing screens
killall screen
# Run stack.sh
cd $DEST/devstack && \$STACKSH_PARAMS ./stack.sh > $DEST/run.sh.log
echo >> $DEST/run.sh.log
echo >> $DEST/run.sh.log
echo "All done! Time to start clicking." >> $DEST/run.sh.log
EOF
# Make the run.sh executable
chmod 755 $RUN_SH
chroot $MNT_DIR chown stack $DEST/run.sh
umount $MNT_DIR/dev
umount $MNT_DIR
rmdir $MNT_DIR
mv $DEST_FILE_TMP $DEST_FILE
rm -f $DEST_FILE_TMP
trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT

@ -1,146 +0,0 @@
#!/bin/bash -e
# build_usb_boot.sh - Create a syslinux boot environment
#
# build_usb_boot.sh destdev
#
# Assumes syslinux is installed
# Needs to run as root
DEST_DIR=${1:-/tmp/syslinux-boot}
PXEDIR=${PXEDIR:-/opt/ramstack/pxe}
PROGDIR=`dirname $0`
# Clean up any resources that may be in use
cleanup() {
set +o errexit
# Mop up temporary files
if [ -n "$DEST_DEV" ]; then
umount $DEST_DIR
rmdir $DEST_DIR
fi
if [ -n "$MNTDIR" -a -d "$MNTDIR" ]; then
umount $MNTDIR
rmdir $MNTDIR
fi
# Kill ourselves to signal any calling process
trap 2; kill -2 $$
}
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
if [ -b $DEST_DIR ]; then
# We have a block device, install syslinux and mount it
DEST_DEV=$DEST_DIR
DEST_DIR=`mktemp -d --tmpdir mntXXXXXX`
mount $DEST_DEV $DEST_DIR
if [ ! -d $DEST_DIR/syslinux ]; then
mkdir -p $DEST_DIR/syslinux
fi
# Install syslinux on the device
syslinux --install --directory syslinux $DEST_DEV
else
# We have a directory (for sanity checking output)
DEST_DEV=""
if [ ! -d $DEST_DIR/syslinux ]; then
mkdir -p $DEST_DIR/syslinux
fi
fi
# Get some more stuff from syslinux
for i in memdisk menu.c32; do
cp -pu /usr/lib/syslinux/$i $DEST_DIR/syslinux
done
CFG=$DEST_DIR/syslinux/syslinux.cfg
cat >$CFG <<EOF
default /syslinux/menu.c32
prompt 0
timeout 0
MENU TITLE devstack Boot Menu
EOF
# Setup devstack boot
mkdir -p $DEST_DIR/ubuntu
if [ ! -d $PXEDIR ]; then
mkdir -p $PXEDIR
fi
# Get image into place
if [ ! -r $PXEDIR/stack-initrd.img ]; then
cd $TOP_DIR
$PROGDIR/build_uec_ramdisk.sh $PXEDIR/stack-initrd.img
fi
if [ ! -r $PXEDIR/stack-initrd.gz ]; then
gzip -1 -c $PXEDIR/stack-initrd.img >$PXEDIR/stack-initrd.gz
fi
cp -pu $PXEDIR/stack-initrd.gz $DEST_DIR/ubuntu
if [ ! -r $PXEDIR/vmlinuz-*-generic ]; then
MNTDIR=`mktemp -d --tmpdir mntXXXXXXXX`
mount -t ext4 -o loop $PXEDIR/stack-initrd.img $MNTDIR
if [ ! -r $MNTDIR/boot/vmlinuz-*-generic ]; then
echo "No kernel found"
umount $MNTDIR
rmdir $MNTDIR
if [ -n "$DEST_DEV" ]; then
umount $DEST_DIR
rmdir $DEST_DIR
fi
exit 1
else
cp -pu $MNTDIR/boot/vmlinuz-*-generic $PXEDIR
fi
umount $MNTDIR
rmdir $MNTDIR
fi
# Get generic kernel version
KNAME=`basename $PXEDIR/vmlinuz-*-generic`
KVER=${KNAME#vmlinuz-}
cp -pu $PXEDIR/vmlinuz-$KVER $DEST_DIR/ubuntu
cat >>$CFG <<EOF
LABEL devstack
MENU LABEL ^devstack
MENU DEFAULT
KERNEL /ubuntu/vmlinuz-$KVER
APPEND initrd=/ubuntu/stack-initrd.gz ramdisk_size=2109600 root=/dev/ram0
EOF
# Get Ubuntu
if [ -d $PXEDIR -a -r $PXEDIR/natty-base-initrd.gz ]; then
cp -pu $PXEDIR/natty-base-initrd.gz $DEST_DIR/ubuntu
cat >>$CFG <<EOF
LABEL ubuntu
MENU LABEL ^Ubuntu Natty
KERNEL /ubuntu/vmlinuz-$KVER
APPEND initrd=/ubuntu/natty-base-initrd.gz ramdisk_size=419600 root=/dev/ram0
EOF
fi
# Local disk boot
cat >>$CFG <<EOF
LABEL local
MENU LABEL ^Local disk
LOCALBOOT 0
EOF
if [ -n "$DEST_DEV" ]; then
umount $DEST_DIR
rmdir $DEST_DIR
fi
trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT

@ -1,72 +0,0 @@
#!/usr/bin/env bash
# Echo commands
set -o xtrace
# Exit on error to stop unexpected errors
set -o errexit
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
# Change dir to top of devstack
cd $TOP_DIR
# Echo usage
usage() {
echo "Add stack user and keys"
echo ""
echo "Usage: $0 [full path to raw uec base image]"
}
# Make sure this is a raw image
if ! qemu-img info $1 | grep -q "file format: raw"; then
usage
exit 1
fi
# Mount the image
DEST=/opt/stack
STAGING_DIR=/tmp/`echo $1 | sed "s/\//_/g"`.stage.user
mkdir -p $STAGING_DIR
umount $STAGING_DIR || true
sleep 1
mount -t ext4 -o loop $1 $STAGING_DIR
mkdir -p $STAGING_DIR/$DEST
# Create a stack user that is a member of the libvirtd group so that stack
# is able to interact with libvirt.
chroot $STAGING_DIR groupadd libvirtd || true
chroot $STAGING_DIR useradd stack -s /bin/bash -d $DEST -G libvirtd || true
# Add a simple password - pass
echo stack:pass | chroot $STAGING_DIR chpasswd
# Configure sudo
( umask 226 && echo "stack ALL=(ALL) NOPASSWD:ALL" \
> $STAGING_DIR/etc/sudoers.d/50_stack_sh )
# Gracefully cp only if source file/dir exists
function cp_it {
if [ -e $1 ] || [ -d $1 ]; then
cp -pRL $1 $2
fi
}
# Copy over your ssh keys and env if desired
cp_it ~/.ssh $STAGING_DIR/$DEST/.ssh
cp_it ~/.ssh/id_rsa.pub $STAGING_DIR/$DEST/.ssh/authorized_keys
cp_it ~/.gitconfig $STAGING_DIR/$DEST/.gitconfig
cp_it ~/.vimrc $STAGING_DIR/$DEST/.vimrc
cp_it ~/.bashrc $STAGING_DIR/$DEST/.bashrc
# Copy devstack
rm -rf $STAGING_DIR/$DEST/devstack
cp_it . $STAGING_DIR/$DEST/devstack
# Give stack ownership over $DEST so it may do the work needed
chroot $STAGING_DIR chown -R stack $DEST
# Unmount
umount $STAGING_DIR

@ -1,103 +0,0 @@
#!/bin/bash
# get_uec_image.sh - Prepare Ubuntu UEC images
CACHEDIR=${CACHEDIR:-/opt/stack/cache}
ROOTSIZE=${ROOTSIZE:-2000}
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
# exit on error to stop unexpected errors
set -o errexit
set -o xtrace
usage() {
echo "Usage: $0 - Fetch and prepare Ubuntu images"
echo ""
echo "$0 [-r rootsize] release imagefile [kernel]"
echo ""
echo "-r size - root fs size (min 2000MB)"
echo "release - Ubuntu release: jaunty - oneric"
echo "imagefile - output image file"
echo "kernel - output kernel"
exit 1
}
# Clean up any resources that may be in use
cleanup() {
set +o errexit
# Mop up temporary files
if [ -n "$IMG_FILE_TMP" -a -e "$IMG_FILE_TMP" ]; then
rm -f $IMG_FILE_TMP
fi
# Kill ourselves to signal any calling process
trap 2; kill -2 $$
}
while getopts hr: c; do
case $c in
h) usage
;;
r) ROOTSIZE=$OPTARG
;;
esac
done
shift `expr $OPTIND - 1`
if [[ ! "$#" -eq "2" && ! "$#" -eq "3" ]]; then
usage
fi
# Default args
DIST_NAME=$1
IMG_FILE=$2
IMG_FILE_TMP=`mktemp $IMG_FILE.XXXXXX`
KERNEL=$3
case $DIST_NAME in
oneiric) ;;
natty) ;;
maverick) ;;
lucid) ;;
*) echo "Unknown release: $DIST_NAME"
usage
;;
esac
trap cleanup SIGHUP SIGINT SIGTERM SIGQUIT EXIT
# Check dependencies
if [ ! -x "`which qemu-img`" -o -z "`dpkg -l | grep cloud-utils`" ]; then
# Missing KVM?
apt_get install qemu-kvm cloud-utils
fi
# Find resize script
RESIZE=`which resize-part-image || which uec-resize-image`
if [ -z "$RESIZE" ]; then
echo "resize tool from cloud-utils not found"
exit 1
fi
# Get the UEC image
UEC_NAME=$DIST_NAME-server-cloudimg-amd64
if [ ! -d $CACHEDIR ]; then
mkdir -p $CACHEDIR/$DIST_NAME
fi
if [ ! -e $CACHEDIR/$DIST_NAME/$UEC_NAME.tar.gz ]; then
(cd $CACHEDIR/$DIST_NAME && wget -N http://uec-images.ubuntu.com/$DIST_NAME/current/$UEC_NAME.tar.gz)
(cd $CACHEDIR/$DIST_NAME && tar Sxvzf $UEC_NAME.tar.gz)
fi
$RESIZE $CACHEDIR/$DIST_NAME/$UEC_NAME.img ${ROOTSIZE} $IMG_FILE_TMP
mv $IMG_FILE_TMP $IMG_FILE
# Copy kernel to destination
if [ -n "$KERNEL" ]; then
cp -p $CACHEDIR/$DIST_NAME/*-vmlinuz-virtual $KERNEL
fi
trap - SIGHUP SIGINT SIGTERM SIGQUIT EXIT

@ -1,218 +0,0 @@
#!/bin/bash
# install_openvpn.sh - Install OpenVPN and generate required certificates
#
# install_openvpn.sh --client name
# install_openvpn.sh --server [name]
#
# name is used on the CN of the generated cert, and the filename of
# the configuration, certificate and key files.
#
# --server mode configures the host with a running OpenVPN server instance
# --client mode creates a tarball of a client configuration for this server
# Get config file
if [ -e localrc ]; then
. localrc
fi
if [ -e vpnrc ]; then
. vpnrc
fi
# Do some IP manipulation
function cidr2netmask() {
set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
if [[ $1 -gt 1 ]]; then
shift $1
else
shift
fi
echo ${1-0}.${2-0}.${3-0}.${4-0}
}
FIXED_NET=`echo $FIXED_RANGE | cut -d'/' -f1`
FIXED_CIDR=`echo $FIXED_RANGE | cut -d'/' -f2`
FIXED_MASK=`cidr2netmask $FIXED_CIDR`
# VPN Config
VPN_SERVER=${VPN_SERVER:-`ifconfig eth0 | awk "/inet addr:/ { print \$2 }" | cut -d: -f2`} # 50.56.12.212
VPN_PROTO=${VPN_PROTO:-tcp}
VPN_PORT=${VPN_PORT:-6081}
VPN_DEV=${VPN_DEV:-tap0}
VPN_BRIDGE=${VPN_BRIDGE:-br100}
VPN_BRIDGE_IF=${VPN_BRIDGE_IF:-$FLAT_INTERFACE}
VPN_CLIENT_NET=${VPN_CLIENT_NET:-$FIXED_NET}
VPN_CLIENT_MASK=${VPN_CLIENT_MASK:-$FIXED_MASK}
VPN_CLIENT_DHCP="${VPN_CLIENT_DHCP:-net.1 net.254}"
VPN_DIR=/etc/openvpn
CA_DIR=$VPN_DIR/easy-rsa
usage() {
echo "$0 - OpenVPN install and certificate generation"
echo ""
echo "$0 --client name"
echo "$0 --server [name]"
echo ""
echo " --server mode configures the host with a running OpenVPN server instance"
echo " --client mode creates a tarball of a client configuration for this server"
exit 1
}
if [ -z $1 ]; then
usage
fi
# Install OpenVPN
VPN_EXEC=`which openvpn`
if [ -z "$VPN_EXEC" -o ! -x "$VPN_EXEC" ]; then
apt-get install -y openvpn bridge-utils
fi
if [ ! -d $CA_DIR ]; then
cp -pR /usr/share/doc/openvpn/examples/easy-rsa/2.0/ $CA_DIR
fi
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=$(cd $TOOLS_DIR/.. && pwd)
WEB_DIR=$TOP_DIR/../vpn
if [[ ! -d $WEB_DIR ]]; then
mkdir -p $WEB_DIR
fi
WEB_DIR=$(cd $TOP_DIR/../vpn && pwd)
cd $CA_DIR
source ./vars
# Override the defaults
export KEY_COUNTRY="US"
export KEY_PROVINCE="TX"
export KEY_CITY="SanAntonio"
export KEY_ORG="Cloudbuilders"
export KEY_EMAIL="rcb@lists.rackspace.com"
if [ ! -r $CA_DIR/keys/dh1024.pem ]; then
# Initialize a new CA
$CA_DIR/clean-all
$CA_DIR/build-dh
$CA_DIR/pkitool --initca
openvpn --genkey --secret $CA_DIR/keys/ta.key ## Build a TLS key
fi
do_server() {
NAME=$1
# Generate server certificate
$CA_DIR/pkitool --server $NAME
(cd $CA_DIR/keys;
cp $NAME.crt $NAME.key ca.crt dh1024.pem ta.key $VPN_DIR
)
cat >$VPN_DIR/br-up <<EOF
#!/bin/bash
BR="$VPN_BRIDGE"
TAP="\$1"
if [[ ! -d /sys/class/net/\$BR ]]; then
brctl addbr \$BR
fi
for t in \$TAP; do
openvpn --mktun --dev \$t
brctl addif \$BR \$t
ifconfig \$t 0.0.0.0 promisc up
done
EOF
chmod +x $VPN_DIR/br-up
cat >$VPN_DIR/br-down <<EOF
#!/bin/bash
BR="$VPN_BRIDGE"
TAP="\$1"
for i in \$TAP; do
brctl delif \$BR $t
openvpn --rmtun --dev \$i
done
EOF
chmod +x $VPN_DIR/br-down
cat >$VPN_DIR/$NAME.conf <<EOF
proto $VPN_PROTO
port $VPN_PORT
dev $VPN_DEV
up $VPN_DIR/br-up
down $VPN_DIR/br-down
cert $NAME.crt
key $NAME.key # This file should be kept secret
ca ca.crt
dh dh1024.pem
duplicate-cn
server-bridge $VPN_CLIENT_NET $VPN_CLIENT_MASK $VPN_CLIENT_DHCP
ifconfig-pool-persist ipp.txt
comp-lzo
user nobody
group nogroup
persist-key
persist-tun
status openvpn-status.log
EOF
/etc/init.d/openvpn restart
}
do_client() {
NAME=$1
# Generate a client certificate
$CA_DIR/pkitool $NAME
TMP_DIR=`mktemp -d`
(cd $CA_DIR/keys;
cp -p ca.crt ta.key $NAME.key $NAME.crt $TMP_DIR
)
if [ -r $VPN_DIR/hostname ]; then
HOST=`cat $VPN_DIR/hostname`
else
HOST=`hostname`
fi
cat >$TMP_DIR/$HOST.conf <<EOF
proto $VPN_PROTO
port $VPN_PORT
dev $VPN_DEV
cert $NAME.crt
key $NAME.key # This file should be kept secret
ca ca.crt
client
remote $VPN_SERVER $VPN_PORT
resolv-retry infinite
nobind
user nobody
group nogroup
persist-key
persist-tun
comp-lzo
verb 3
EOF
(cd $TMP_DIR; tar cf $WEB_DIR/$NAME.tar *)
rm -rf $TMP_DIR
echo "Client certificate and configuration is in $WEB_DIR/$NAME.tar"
}
# Process command line args
case $1 in
--client) if [ -z $2 ]; then
usage
fi
do_client $2
;;
--server) if [ -z $2 ]; then
NAME=`hostname`
else
NAME=$2
# Save for --client use
echo $NAME >$VPN_DIR/hostname
fi
do_server $NAME
;;
--clean) $CA_DIR/clean-all
;;
*) usage
esac

@ -1,38 +0,0 @@
Getting Started With Jenkins and Devstack
=========================================
This little corner of devstack is to show how to get an Openstack jenkins
environment up and running quickly, using the rcb configuration methodology.
To create a jenkins server
--------------------------
cd tools/jenkins/jenkins_home
./build_jenkins.sh
This will create a jenkins environment configured with sample test scripts that run against xen and kvm.
Configuring XS
--------------
In order to make the tests for XS work, you must install xs 5.6 on a separate machine,
and install the the jenkins public key on that server. You then need to create the
/var/lib/jenkins/xenrc on your jenkins server like so:
MYSQL_PASSWORD=secrete
SERVICE_TOKEN=secrete
ADMIN_PASSWORD=secrete
RABBIT_PASSWORD=secrete
# This is the password for your guest (for both stack and root users)
GUEST_PASSWORD=secrete
# Do not download the usual images yet!
IMAGE_URLS=""
FLOATING_RANGE=192.168.1.224/28
VIRT_DRIVER=xenserver
# Explicitly set multi-host
MULTI_HOST=1
# Give extra time for boot
ACTIVE_TIMEOUT=45
# IMPORTANT: This is the ip of your xenserver
XEN_IP=10.5.5.1
# IMPORTANT: The following must be set to your dom0 root password!
XENAPI_PASSWORD='MY_XEN_ROOT_PW'

@ -1,8 +0,0 @@
#!/bin/bash
# Echo commands, exit on error
set -o xtrace
set -o errexit
TOP_DIR=$(cd ../../.. && pwd)
HEAD_IP=`cat $TOP_DIR/addresses | grep HEAD | cut -d "=" -f2`
ssh stack@$HEAD_IP 'cd devstack && source openrc && cd exercises && ./euca.sh'

@ -1,8 +0,0 @@
#!/bin/bash
# Echo commands, exit on error
set -o xtrace
set -o errexit
TOP_DIR=$(cd ../../.. && pwd)
HEAD_IP=`cat $TOP_DIR/addresses | grep HEAD | cut -d "=" -f2`
ssh stack@$HEAD_IP 'cd devstack && source openrc && cd exercises && ./floating_ips.sh'

@ -1,21 +0,0 @@
#!/bin/bash
EXECUTOR_NUMBER=$1
CONFIGURATION=$2
ADAPTER=$3
RC=$4
function usage() {
echo "Usage: $0 - Build a configuration"
echo ""
echo "$0 [EXECUTOR_NUMBER] [CONFIGURATION] [ADAPTER] [RC (optional)]"
exit 1
}
# Validate inputs
if [[ "$EXECUTOR_NUMBER" = "" || "$CONFIGURATION" = "" || "$ADAPTER" = "" ]]; then
usage
fi
# Execute configuration script
cd configurations && ./$CONFIGURATION.sh $EXECUTOR_NUMBER $CONFIGURATION $ADAPTER "$RC"

@ -1,63 +0,0 @@
#!/bin/bash
# exit on error to stop unexpected errors
set -o errexit
set -o xtrace
EXECUTOR_NUMBER=$1
CONFIGURATION=$2
ADAPTER=$3
RC=$4
function usage() {
echo "Usage: $0 - Build a test configuration"
echo ""
echo "$0 [EXECUTOR_NUMBER] [CONFIGURATION] [ADAPTER] [RC (optional)]"
exit 1
}
# Validate inputs
if [[ "$EXECUTOR_NUMBER" = "" || "$CONFIGURATION" = "" || "$ADAPTER" = "" ]]; then
usage
fi
# This directory
CUR_DIR=$(cd $(dirname "$0") && pwd)
# devstack directory
cd ../../..
TOP_DIR=$(pwd)
# Deps
apt-get install -y --force-yes libvirt-bin || true
# Name test instance based on executor
BASE_NAME=executor-`printf "%02d" $EXECUTOR_NUMBER`
GUEST_NAME=$BASE_NAME.$ADAPTER
virsh list | grep $BASE_NAME | cut -d " " -f1 | xargs -n 1 virsh destroy || true
virsh net-list | grep $BASE_NAME | cut -d " " -f1 | xargs -n 1 virsh net-destroy || true
# Configure localrc
cat <<EOF >localrc
RECLONE=yes
GUEST_NETWORK=$EXECUTOR_NUMBER
GUEST_NAME=$GUEST_NAME
FLOATING_RANGE=192.168.$EXECUTOR_NUMBER.128/27
GUEST_CORES=1
GUEST_RAM=12574720
MYSQL_PASSWORD=chicken
RABBIT_PASSWORD=chicken
SERVICE_TOKEN=chicken
ADMIN_PASSWORD=chicken
USERNAME=admin
TENANT=admin
NET_NAME=$BASE_NAME
ACTIVE_TIMEOUT=45
BOOT_TIMEOUT=45
$RC
EOF
cd tools
sudo ./build_uec.sh
# Make the address of the instances available to test runners
echo HEAD=`cat /var/lib/libvirt/dnsmasq/$BASE_NAME.leases | cut -d " " -f3` > $TOP_DIR/addresses

@ -1,53 +0,0 @@
#!/bin/bash
set -o errexit
set -o xtrace
EXECUTOR_NUMBER=$1
CONFIGURATION=$2
ADAPTER=$3
RC=$4
function usage() {
echo "Usage: $0 - Build a test configuration"
echo ""
echo "$0 [EXECUTOR_NUMBER] [CONFIGURATION] [ADAPTER] [RC (optional)]"
exit 1
}
# Validate inputs
if [[ "$EXECUTOR_NUMBER" = "" || "$CONFIGURATION" = "" || "$ADAPTER" = "" ]]; then
usage
fi
# Configuration of xenrc
XENRC=/var/lib/jenkins/xenrc
if [ ! -e $XENRC ]; then
echo "/var/lib/jenkins/xenrc is not present! See README.md"
exit 1
fi
# Move to top of devstack
cd ../../..
# Use xenrc as the start of our localrc
cp $XENRC localrc
# Set the PUB_IP
PUB_IP=192.168.1.1$EXECUTOR_NUMBER
echo "PUB_IP=$PUB_IP" >> localrc
# Overrides
echo "$RC" >> localrc
# Source localrc
. localrc
# Make host ip available to tester
echo "HEAD=$PUB_IP" > addresses
# Build configuration
REMOTE_DEVSTACK=/root/devstack
ssh root@$XEN_IP "rm -rf $REMOTE_DEVSTACK"
scp -pr . root@$XEN_IP:$REMOTE_DEVSTACK
ssh root@$XEN_IP "cd $REMOTE_DEVSTACK/tools/xen && ./build_domU.sh"

@ -1,3 +0,0 @@
builds
workspace
*.sw*

@ -1,108 +0,0 @@
#!/bin/bash
# Echo commands, exit on error
set -o xtrace
set -o errexit
# Make sure only root can run our script
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# This directory
CUR_DIR=$(cd $(dirname "$0") && pwd)
# Configure trunk jenkins!
echo "deb http://pkg.jenkins-ci.org/debian binary/" > /etc/apt/sources.list.d/jenkins.list
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
apt-get update
# Clean out old jenkins - useful if you are having issues upgrading
CLEAN_JENKINS=${CLEAN_JENKINS:-no}
if [ "$CLEAN_JENKINS" = "yes" ]; then
apt-get remove jenkins jenkins-common
fi
# Install software
DEPS="jenkins cloud-utils"
apt-get install -y --force-yes $DEPS
# Install jenkins
if [ ! -e /var/lib/jenkins ]; then
echo "Jenkins installation failed"
exit 1
fi
# Make sure user has configured a jenkins ssh pubkey
if [ ! -e /var/lib/jenkins/.ssh/id_rsa.pub ]; then
echo "Public key for jenkins is missing. This is used to ssh into your instances."
echo "Please run "su -c ssh-keygen jenkins" before proceeding"
exit 1
fi
# Setup sudo
JENKINS_SUDO=/etc/sudoers.d/jenkins
cat > $JENKINS_SUDO <<EOF
jenkins ALL = NOPASSWD: ALL
EOF
chmod 440 $JENKINS_SUDO
# Setup .gitconfig
JENKINS_GITCONF=/var/lib/jenkins/hudson.plugins.git.GitSCM.xml
cat > $JENKINS_GITCONF <<EOF
<?xml version='1.0' encoding='UTF-8'?>
<hudson.plugins.git.GitSCM_-DescriptorImpl>
<generation>4</generation>
<globalConfigName>Jenkins</globalConfigName>
<globalConfigEmail>jenkins@rcb.me</globalConfigEmail>
</hudson.plugins.git.GitSCM_-DescriptorImpl>
EOF
# Add build numbers
JOBS=`ls jobs`
for job in ${JOBS// / }; do
if [ ! -e jobs/$job/nextBuildNumber ]; then
echo 1 > jobs/$job/nextBuildNumber
fi
done
# Set ownership to jenkins
chown -R jenkins $CUR_DIR
# Make sure this directory is accessible to jenkins
if ! su -c "ls $CUR_DIR" jenkins; then
echo "Your devstack directory is not accessible by jenkins."
echo "There is a decent chance you are trying to run this from a directory in /root."
echo "If so, try moving devstack elsewhere (eg. /opt/devstack)."
exit 1
fi
# Move aside old jobs, if present
if [ ! -h /var/lib/jenkins/jobs ]; then
echo "Installing jobs symlink"
if [ -d /var/lib/jenkins/jobs ]; then
mv /var/lib/jenkins/jobs /var/lib/jenkins/jobs.old
fi
fi
# Set up jobs symlink
rm -f /var/lib/jenkins/jobs
ln -s $CUR_DIR/jobs /var/lib/jenkins/jobs
# List of plugins
PLUGINS=http://hudson-ci.org/downloads/plugins/build-timeout/1.6/build-timeout.hpi,http://mirrors.jenkins-ci.org/plugins/git/1.1.12/git.hpi,http://hudson-ci.org/downloads/plugins/global-build-stats/1.2/global-build-stats.hpi,http://hudson-ci.org/downloads/plugins/greenballs/1.10/greenballs.hpi,http://download.hudson-labs.org/plugins/console-column-plugin/1.0/console-column-plugin.hpi
# Configure plugins
for plugin in ${PLUGINS//,/ }; do
name=`basename $plugin`
dest=/var/lib/jenkins/plugins/$name
if [ ! -e $dest ]; then
curl -L $plugin -o $dest
fi
done
# Restart jenkins
/etc/init.d/jenkins stop || true
/etc/init.d/jenkins start

@ -1,21 +0,0 @@
#!/bin/bash
# This script is not yet for general consumption.
set -o errexit
if [ ! "$FORCE" = "yes" ]; then
echo "FORCE not set to 'yes'. Make sure this is something you really want to do. Exiting."
exit 1
fi
virsh list | cut -d " " -f1 | grep -v "-" | egrep -e "[0-9]" | xargs -n 1 virsh destroy || true
virsh net-list | grep active | cut -d " " -f1 | xargs -n 1 virsh net-destroy || true
killall dnsmasq || true
if [ "$CLEAN" = "yes" ]; then
rm -rf jobs
fi
rm /var/lib/jenkins/jobs
git checkout -f
git fetch
git merge origin/jenkins
./build_jenkins.sh

@ -1,82 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<matrix-project>
<actions/>
<description></description>
<keepDependencies>false</keepDependencies>
<properties>
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<hudson.model.StringParameterDefinition>
<name>RC</name>
<description></description>
<defaultValue></defaultValue>
</hudson.model.StringParameterDefinition>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
</properties>
<scm class="hudson.plugins.git.GitSCM">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<name>origin</name>
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
<url>git://github.com/cloudbuilders/devstack.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
<wipeOutWorkspace>false</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir></relativeTargetDir>
<excludedRegions></excludedRegions>
<excludedUsers></excludedUsers>
<gitConfigName></gitConfigName>
<gitConfigEmail></gitConfigEmail>
<skipTag>false</skipTag>
<scmName></scmName>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<axes>
<hudson.matrix.TextAxis>
<name>ADAPTER</name>
<values>
<string>euca</string>
<string>floating_ips</string>
</values>
</hudson.matrix.TextAxis>
</axes>
<builders>
<hudson.tasks.Shell>
<command>sed -i &apos;s/) 2&gt;&amp;1 | tee &quot;${LOGFILE}&quot;/)/&apos; stack.sh</command>
</hudson.tasks.Shell>
<hudson.tasks.Shell>
<command>set -o errexit
cd tools/jenkins
sudo ./build_configuration.sh $EXECUTOR_NUMBER kvm $ADAPTER &quot;$RC&quot;</command>
</hudson.tasks.Shell>
<hudson.tasks.Shell>
<command>set -o errexit
cd tools/jenkins
./run_test.sh $EXECUTOR_NUMBER $ADAPTER $RC &quot;$RC&quot;</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
<runSequentially>false</runSequentially>
</matrix-project>

@ -1,15 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<matrix-config>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>false</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<builders/>
<publishers/>
<buildWrappers/>
</matrix-config>

@ -1,15 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<matrix-config>
<keepDependencies>false</keepDependencies>
<properties/>
<scm class="hudson.scm.NullSCM"/>
<canRoam>false</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<builders/>
<publishers/>
<buildWrappers/>
</matrix-config>

@ -1,88 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<matrix-project>
<actions/>
<description>In order for this to work, you must create a /var/lib/jenkins/xenrc file as described in README.md</description>
<keepDependencies>false</keepDependencies>
<properties>
<hudson.model.ParametersDefinitionProperty>
<parameterDefinitions>
<hudson.model.StringParameterDefinition>
<name>RC</name>
<description></description>
<defaultValue></defaultValue>
</hudson.model.StringParameterDefinition>
</parameterDefinitions>
</hudson.model.ParametersDefinitionProperty>
</properties>
<scm class="hudson.plugins.git.GitSCM">
<configVersion>2</configVersion>
<userRemoteConfigs>
<hudson.plugins.git.UserRemoteConfig>
<name>origin</name>
<refspec>+refs/heads/*:refs/remotes/origin/*</refspec>
<url>git://github.com/cloudbuilders/devstack.git</url>
</hudson.plugins.git.UserRemoteConfig>
</userRemoteConfigs>
<branches>
<hudson.plugins.git.BranchSpec>
<name>master</name>
</hudson.plugins.git.BranchSpec>
</branches>
<recursiveSubmodules>false</recursiveSubmodules>
<doGenerateSubmoduleConfigurations>false</doGenerateSubmoduleConfigurations>
<authorOrCommitter>false</authorOrCommitter>
<clean>false</clean>
<wipeOutWorkspace>false</wipeOutWorkspace>
<pruneBranches>false</pruneBranches>
<remotePoll>false</remotePoll>
<buildChooser class="hudson.plugins.git.util.DefaultBuildChooser"/>
<gitTool>Default</gitTool>
<submoduleCfg class="list"/>
<relativeTargetDir></relativeTargetDir>
<excludedRegions></excludedRegions>
<excludedUsers></excludedUsers>
<gitConfigName></gitConfigName>
<gitConfigEmail></gitConfigEmail>
<skipTag>false</skipTag>
<scmName></scmName>
</scm>
<canRoam>true</canRoam>
<disabled>false</disabled>
<blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
<blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
<triggers class="vector"/>
<concurrentBuild>false</concurrentBuild>
<axes>
<hudson.matrix.TextAxis>
<name>ADAPTER</name>
<values>
<string>euca</string>
<string>floating_ips</string>
</values>
</hudson.matrix.TextAxis>
</axes>
<builders>
<hudson.tasks.Shell>
<command>sed -i &apos;s/) 2&gt;&amp;1 | tee &quot;${LOGFILE}&quot;/)/&apos; stack.sh</command>
</hudson.tasks.Shell>
<hudson.tasks.Shell>
<command>set -o errexit
cd tools/jenkins
sudo ./build_configuration.sh $EXECUTOR_NUMBER xs $ADAPTER &quot;$RC&quot;</command>
</hudson.tasks.Shell>
<hudson.tasks.Shell>
<command>#!/bin/bash
set -o errexit
set -o xtrace
. localrc
# Unlike kvm, ssh to the xen host to run tests, in case the test instance is launch with a host only network
ssh root@$XEN_IP &quot;cd devstack &amp;&amp; . localrc &amp;&amp; cd tools/jenkins &amp;&amp; ./run_test.sh $EXECUTOR_NUMBER $ADAPTER &apos;$RC&apos;&quot;
</command>
</hudson.tasks.Shell>
</builders>
<publishers/>
<buildWrappers/>
<runSequentially>true</runSequentially>
</matrix-project>

@ -1,45 +0,0 @@
#!/usr/bin/python
import urllib
import json
import sys
def print_usage():
print "Usage: %s [jenkins_url (eg. http://50.56.12.202:8080/)]"\
% sys.argv[0]
sys.exit()
def fetch_blob(url):
return json.loads(urllib.urlopen(url + '/api/json').read())
if len(sys.argv) < 2:
print_usage()
BASE_URL = sys.argv[1]
root = fetch_blob(BASE_URL)
results = {}
for job_url in root['jobs']:
job = fetch_blob(job_url['url'])
if job.get('activeConfigurations'):
(tag, name) = job['name'].split('-')
if not results.get(tag):
results[tag] = {}
if not results[tag].get(name):
results[tag][name] = []
for config_url in job['activeConfigurations']:
config = fetch_blob(config_url['url'])
log_url = ''
if config.get('lastBuild'):
log_url = config['lastBuild']['url'] + 'console'
results[tag][name].append({'test': config['displayName'],
'status': config['color'],
'logUrl': log_url,
'healthReport': config['healthReport']})
print json.dumps(results)

@ -1,20 +0,0 @@
#!/bin/bash
EXECUTOR_NUMBER=$1
ADAPTER=$2
RC=$3
function usage() {
echo "Usage: $0 - Run a test"
echo ""
echo "$0 [EXECUTOR_NUMBER] [ADAPTER] [RC (optional)]"
exit 1
}
# Validate inputs
if [[ "$EXECUTOR_NUMBER" = "" || "$ADAPTER" = "" ]]; then
usage
fi
# Execute configuration script
cd adapters && ./$ADAPTER.sh $EXECUTOR_NUMBER $ADAPTER "$RC"

@ -1,145 +0,0 @@
#!/bin/sh -e
# Copyright (c) 2010-2011 Gluster, Inc. <http://www.gluster.com>
# This initial version of this file was taken from the source tree
# of GlusterFS. It was not directly attributed, but is assumed to be
# Copyright (c) 2010-2011 Gluster, Inc and release GPLv3
# Subsequent modifications are Copyright (c) 2011 OpenStack, LLC.
#
# GlusterFS is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; either version 3 of the License,
# or (at your option) any later version.
#
# GlusterFS is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see
# <http://www.gnu.org/licenses/>.
branch="master";
set_hooks_commit_msg()
{
top_dir=`git rev-parse --show-toplevel`
f="${top_dir}/.git/hooks/commit-msg";
u="https://review.openstack.org/tools/hooks/commit-msg";
if [ -x "$f" ]; then
return;
fi
curl -o $f $u || wget -O $f $u;
chmod +x $f;
GIT_EDITOR=true git commit --amend
}
add_remote()
{
username=$1
project=$2
echo "No remote set, testing ssh://$username@review.openstack.org:29418"
if project_list=`ssh -p29418 -o StrictHostKeyChecking=no $username@review.openstack.org gerrit ls-projects 2>/dev/null`
then
echo "$username@review.openstack.org:29418 worked."
if echo $project_list | grep $project >/dev/null
then
echo "Creating a git remote called gerrit that maps to:"
echo " ssh://$username@review.openstack.org:29418/$project"
git remote add gerrit ssh://$username@review.openstack.org:29418/$project
else
echo "The current project name, $project, is not a known project."
echo "Please either reclone from github/gerrit or create a"
echo "remote named gerrit that points to the intended project."
return 1
fi
return 0
fi
return 1
}
check_remote()
{
if ! git remote | grep gerrit >/dev/null 2>&1
then
origin_project=`git remote show origin | grep 'Fetch URL' | perl -nle '@fields = split(m|[:/]|); $len = $#fields; print $fields[$len-1], "/", $fields[$len];'`
if add_remote $USERNAME $origin_project
then
return 0
else
echo "Your local name doesn't work on Gerrit."
echo -n "Enter Gerrit username (same as launchpad): "
read gerrit_user
if add_remote $gerrit_user $origin_project
then
return 0
else
echo "Can't infer where gerrit is - please set a remote named"
echo "gerrit manually and then try again."
echo
echo "For more information, please see:"
echo "\thttp://wiki.openstack.org/GerritWorkflow"
exit 1
fi
fi
fi
}
rebase_changes()
{
git fetch;
GIT_EDITOR=true git rebase -i origin/$branch || exit $?;
}
assert_diverge()
{
if ! git diff origin/$branch..HEAD | grep -q .
then
echo "No changes between the current branch and origin/$branch."
exit 1
fi
}
main()
{
set_hooks_commit_msg;
check_remote;
rebase_changes;
assert_diverge;
bug=$(git show --format='%s %b' | perl -nle 'if (/\b([Bb]ug|[Ll][Pp])\s*[#:]?\s*(\d+)/) {print "$2"; exit}')
bp=$(git show --format='%s %b' | perl -nle 'if (/\b([Bb]lue[Pp]rint|[Bb][Pp])\s*[#:]?\s*([0-9a-zA-Z-_]+)/) {print "$2"; exit}')
if [ "$DRY_RUN" = 1 ]; then
drier='echo -e Please use the following command to send your commits to review:\n\n'
else
drier=
fi
local_branch=`git branch | grep -Ei "\* (.*)" | cut -f2 -d' '`
if [ -z "$bug" ]; then
if [ -z "$bp" ]; then
$drier git push gerrit HEAD:refs/for/$branch/$local_branch;
else
$drier git push gerrit HEAD:refs/for/$branch/bp/$bp;
fi
else
$drier git push gerrit HEAD:refs/for/$branch/bug/$bug;
fi
}
main "$@"

@ -1,29 +0,0 @@
import sys
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
from SimpleHTTPServer import SimpleHTTPRequestHandler
def main(host, port, HandlerClass = SimpleHTTPRequestHandler,
ServerClass = HTTPServer, protocol="HTTP/1.0"):
"""simple http server that listens on a give address:port"""
server_address = (host, port)
HandlerClass.protocol_version = protocol
httpd = ServerClass(server_address, HandlerClass)
sa = httpd.socket.getsockname()
print "Serving HTTP on", sa[0], "port", sa[1], "..."
httpd.serve_forever()
if __name__ == '__main__':
if sys.argv[1:]:
address = sys.argv[1]
else:
address = '0.0.0.0'
if ':' in address:
host, port = address.split(':')
else:
host = address
port = 8080
main(host, int(port))

@ -1,53 +0,0 @@
#!/usr/bin/env bash
# Echo commands
set -o xtrace
# Exit on error to stop unexpected errors
set -o errexit
# Keep track of the current directory
TOOLS_DIR=$(cd $(dirname "$0") && pwd)
TOP_DIR=`cd $TOOLS_DIR/..; pwd`
# Change dir to top of devstack
cd $TOP_DIR
# Echo usage
usage() {
echo "Cache OpenStack dependencies on a uec image to speed up performance."
echo ""
echo "Usage: $0 [full path to raw uec base image]"
}
# Make sure this is a raw image
if ! qemu-img info $1 | grep -q "file format: raw"; then
usage
exit 1
fi
# Make sure we are in the correct dir
if [ ! -d files/apts ]; then
echo "Please run this script from devstack/tools/"
exit 1
fi
# Mount the image
STAGING_DIR=/tmp/`echo $1 | sed "s/\//_/g"`.stage
mkdir -p $STAGING_DIR
umount $STAGING_DIR || true
sleep 1
mount -t ext4 -o loop $1 $STAGING_DIR
# Make sure that base requirements are installed
cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
# Perform caching on the base image to speed up subsequent runs
chroot $STAGING_DIR apt-get update
chroot $STAGING_DIR apt-get install -y --download-only `cat files/apts/* | grep NOPRIME | cut -d\# -f1`
chroot $STAGING_DIR apt-get install -y --force-yes `cat files/apts/* | grep -v NOPRIME | cut -d\# -f1` || true
mkdir -p $STAGING_DIR/var/cache/pip
PIP_DOWNLOAD_CACHE=/var/cache/pip chroot $STAGING_DIR pip install `cat files/pips/*` || true
# Unmount
umount $STAGING_DIR

@ -1,70 +0,0 @@
Getting Started With XenServer 5.6 and Devstack
===============================================
The purpose of the code in this directory it to help developers bootstrap
a XenServer 5.6 + Openstack development environment. This file gives
some pointers on how to get started.
Step 1: Install Xenserver
------------------------
Install XenServer 5.6 on a clean box. You can get XenServer by signing
up for an account on citrix.com, and then visiting:
https://www.citrix.com/English/ss/downloads/details.asp?downloadId=2311504&productId=683148
Here are some sample Xenserver network settings for when you are just
getting started (I use settings like this with a lappy + cheap wifi router):
* XenServer Host IP: 192.168.1.10
* XenServer Netmask: 255.255.255.0
* XenServer Gateway: 192.168.1.1
* XenServer DNS: 192.168.1.1
Step 2: Prepare DOM0
-------------------
At this point, your server is missing some critical software that you will
need to run devstack (like git). Do this to install required software:
wget --no-check-certificate https://github.com/cloudbuilders/devstack/raw/xen/tools/xen/prepare_dom0.sh
chmod 755 prepare_dom0.sh
./prepare_dom0.sh
This script will also clone devstack in /root/devstack
Step 3: Configure your localrc
-----------------------------
Devstack uses a localrc for user-specific configuration. Note that
the XENAPI_PASSWORD must be your dom0 root password.
Of course, use real passwords if this machine is exposed.
cat > /root/devstack/localrc <<EOF
MYSQL_PASSWORD=my_super_secret
SERVICE_TOKEN=my_super_secret
ADMIN_PASSWORD=my_super_secret
RABBIT_PASSWORD=my_super_secret
# This is the password for your guest (for both stack and root users)
GUEST_PASSWORD=my_super_secret
# IMPORTANT: The following must be set to your dom0 root password!
XENAPI_PASSWORD=my_super_secret
# Do not download the usual images yet!
IMAGE_URLS=""
# Explicitly set virt driver here
VIRT_DRIVER=xenserver
# Explicitly set multi-host
MULTI_HOST=1
# Give extra time for boot
ACTIVE_TIMEOUT=45
EOF
Step 4: Run ./build_domU.sh
--------------------------
This script does a lot of stuff, it is probably best to read it in its entirety.
But in a nutshell, it performs the following:
* Configures bridges and vlans for public, private, and management nets
* Creates and installs a OpenStack all-in-one domU in an HA-FlatDHCP configuration
* A script to create a multi-domU (ie. head node separated from compute) configuration is coming soon!
Step 5: Do cloudy stuff!
--------------------------
* Play with horizon
* Play with the CLI
* Log bugs to devstack and core projects, and submit fixes!

@ -1,374 +0,0 @@
#!/bin/bash
# Abort if localrc is not set
if [ ! -e ../../localrc ]; then
echo "You must have a localrc with ALL necessary passwords defined before proceeding."
echo "See the xen README for required passwords."
exit 1
fi
# This directory
TOP_DIR=$(cd $(dirname "$0") && pwd)
# Source params
cd ../.. && source ./stackrc && cd $TOP_DIR
# Echo commands
set -o xtrace
# Name of this guest
GUEST_NAME=${GUEST_NAME:-ALLINONE}
# dom0 ip
HOST_IP=${HOST_IP:-`ifconfig xenbr0 | grep "inet addr" | cut -d ":" -f2 | sed "s/ .*//"`}
# Our nova host's network info
VM_IP=${VM_IP:-10.255.255.255} # A host-only ip that let's the interface come up, otherwise unused
MGT_IP=${MGT_IP:-172.16.100.55}
PUB_IP=${PUB_IP:-192.168.1.55}
# Public network
PUB_BR=${PUB_BR:-xenbr0}
PUB_NETMASK=${PUB_NETMASK:-255.255.255.0}
# VM network params
VM_NETMASK=${VM_NETMASK:-255.255.255.0}
VM_BR=${VM_BR:-xenbr1}
VM_VLAN=${VM_VLAN:-100}
# MGMT network params
MGT_NETMASK=${MGT_NETMASK:-255.255.255.0}
MGT_BR=${MGT_BR:-xenbr2}
MGT_VLAN=${MGT_VLAN:-101}
# VM Password
GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
# Size of image
VDI_MB=${VDI_MB:-2500}
# Make sure we have git
if ! which git; then
GITDIR=/tmp/git-1.7.7
cd /tmp
rm -rf $GITDIR*
wget http://git-core.googlecode.com/files/git-1.7.7.tar.gz
tar xfv git-1.7.7.tar.gz
cd $GITDIR
./configure
make install
cd $TOP_DIR
fi
# Helper to create networks
function create_network() {
if ! xe network-list | grep bridge | grep -q $1; then
echo "Creating bridge $1"
xe network-create name-label=$1
fi
}
# Create host, vm, mgmt, pub networks
create_network xapi0
create_network $VM_BR
create_network $MGT_BR
create_network $PUB_BR
# Get the uuid for our physical (public) interface
PIF=`xe pif-list --minimal device=eth0`
# Create networks/bridges for vm and management
VM_NET=`xe network-list --minimal bridge=$VM_BR`
MGT_NET=`xe network-list --minimal bridge=$MGT_BR`
# Helper to create vlans
function create_vlan() {
pif=$1
vlan=$2
net=$3
if ! xe vlan-list | grep tag | grep -q $vlan; then
xe vlan-create pif-uuid=$pif vlan=$vlan network-uuid=$net
fi
}
# Create vlans for vm and management
create_vlan $PIF $VM_VLAN $VM_NET
create_vlan $PIF $MGT_VLAN $MGT_NET
# Setup host-only nat rules
HOST_NET=169.254.0.0/16
if ! iptables -L -v -t nat | grep -q $HOST_NET; then
iptables -t nat -A POSTROUTING -s $HOST_NET -j SNAT --to-source $HOST_IP
iptables -I FORWARD 1 -s $HOST_NET -j ACCEPT
/etc/init.d/iptables save
fi
# Set up ip forwarding
if ! grep -q "FORWARD_IPV4=YES" /etc/sysconfig/network; then
# FIXME: This doesn't work on reboot!
echo "FORWARD_IPV4=YES" >> /etc/sysconfig/network
fi
# Also, enable ip forwarding in rc.local, since the above trick isn't working
if ! grep -q "echo 1 >/proc/sys/net/ipv4/ip_forward" /etc/rc.local; then
echo "echo 1 >/proc/sys/net/ipv4/ip_forward" >> /etc/rc.local
fi
# Enable ip forwarding at runtime as well
echo 1 > /proc/sys/net/ipv4/ip_forward
# Directory where we stage the build
STAGING_DIR=$TOP_DIR/stage
# Option to clean out old stuff
CLEAN=${CLEAN:-0}
if [ "$CLEAN" = "1" ]; then
rm -rf $STAGING_DIR
fi
# Download our base image. This image is made using prepare_guest.sh
BASE_IMAGE_URL=${BASE_IMAGE_URL:-http://images.ansolabs.com/xen/stage.tgz}
if [ ! -e $STAGING_DIR ]; then
if [ ! -e /tmp/stage.tgz ]; then
wget $BASE_IMAGE_URL -O /tmp/stage.tgz
fi
tar xfz /tmp/stage.tgz
cd $TOP_DIR
fi
# Free up precious disk space
rm -f /tmp/stage.tgz
# Make sure we have a stage
if [ ! -d $STAGING_DIR/etc ]; then
echo "Stage is not properly set up!"
exit 1
fi
# Directory where our conf files are stored
FILES_DIR=$TOP_DIR/files
TEMPLATES_DIR=$TOP_DIR/templates
# Directory for supporting script files
SCRIPT_DIR=$TOP_DIR/scripts
# Version of ubuntu with which we are working
UBUNTU_VERSION=`cat $STAGING_DIR/etc/lsb-release | grep "DISTRIB_CODENAME=" | sed "s/DISTRIB_CODENAME=//"`
KERNEL_VERSION=`ls $STAGING_DIR/boot/vmlinuz* | head -1 | sed "s/.*vmlinuz-//"`
# Setup fake grub
rm -rf $STAGING_DIR/boot/grub/
mkdir -p $STAGING_DIR/boot/grub/
cp $TEMPLATES_DIR/menu.lst.in $STAGING_DIR/boot/grub/menu.lst
sed -e "s,@KERNEL_VERSION@,$KERNEL_VERSION,g" -i $STAGING_DIR/boot/grub/menu.lst
# Setup fstab, tty, and other system stuff
cp $FILES_DIR/fstab $STAGING_DIR/etc/fstab
cp $FILES_DIR/hvc0.conf $STAGING_DIR/etc/init/
# Put the VPX into UTC.
rm -f $STAGING_DIR/etc/localtime
# Configure dns (use same dns as dom0)
cp /etc/resolv.conf $STAGING_DIR/etc/resolv.conf
# Copy over devstack
rm -f /tmp/devstack.tar
tar --exclude='stage' --exclude='xen/xvas' --exclude='xen/nova' -cvf /tmp/devstack.tar $TOP_DIR/../../../devstack
cd $STAGING_DIR/opt/stack/
tar xf /tmp/devstack.tar
cd $TOP_DIR
# Configure OVA
VDI_SIZE=$(($VDI_MB*1024*1024))
PRODUCT_BRAND=${PRODUCT_BRAND:-openstack}
PRODUCT_VERSION=${PRODUCT_VERSION:-001}
BUILD_NUMBER=${BUILD_NUMBER:-001}
LABEL="$PRODUCT_BRAND $PRODUCT_VERSION-$BUILD_NUMBER"
OVA=$STAGING_DIR/tmp/ova.xml
cp $TEMPLATES_DIR/ova.xml.in $OVA
sed -e "s,@VDI_SIZE@,$VDI_SIZE,g" -i $OVA
sed -e "s,@PRODUCT_BRAND@,$PRODUCT_BRAND,g" -i $OVA
sed -e "s,@PRODUCT_VERSION@,$PRODUCT_VERSION,g" -i $OVA
sed -e "s,@BUILD_NUMBER@,$BUILD_NUMBER,g" -i $OVA
# Directory for xvas
XVA_DIR=$TOP_DIR/xvas
# Create xva dir
mkdir -p $XVA_DIR
# Clean nova if desired
if [ "$CLEAN" = "1" ]; then
rm -rf $TOP_DIR/nova
fi
# Checkout nova
if [ ! -d $TOP_DIR/nova ]; then
git clone git://github.com/cloudbuilders/nova.git
git checkout diablo
fi
# Run devstack on launch
cat <<EOF >$STAGING_DIR/etc/rc.local
GUEST_PASSWORD=$GUEST_PASSWORD STAGING_DIR=/ DO_TGZ=0 bash /opt/stack/devstack/tools/xen/prepare_guest.sh
su -c "/opt/stack/run.sh > /opt/stack/run.sh.log" stack
exit 0
EOF
# Install plugins
cp -pr $TOP_DIR/nova/plugins/xenserver/xenapi/etc/xapi.d /etc/
chmod a+x /etc/xapi.d/plugins/*
yum --enablerepo=base install -y parted
mkdir -p /boot/guest
# Set local storage il8n
SR_UUID=`xe sr-list --minimal name-label="Local storage"`
xe sr-param-set uuid=$SR_UUID other-config:i18n-key=local-storage
# Shutdown previous runs
DO_SHUTDOWN=${DO_SHUTDOWN:-1}
if [ "$DO_SHUTDOWN" = "1" ]; then
# Shutdown all domU's that created previously
xe vm-list --minimal name-label="$LABEL" | xargs ./scripts/uninstall-os-vpx.sh
# Destroy any instances that were launched
for uuid in `xe vm-list | grep -1 instance | grep uuid | sed "s/.*\: //g"`; do
echo "Shutting down nova instance $uuid"
xe vm-unpause uuid=$uuid || true
xe vm-shutdown uuid=$uuid
xe vm-destroy uuid=$uuid
done
# Destroy orphaned vdis
for uuid in `xe vdi-list | grep -1 Glance | grep uuid | sed "s/.*\: //g"`; do
xe vdi-destroy uuid=$uuid
done
fi
# Path to head xva. By default keep overwriting the same one to save space
USE_SEPARATE_XVAS=${USE_SEPARATE_XVAS:-0}
if [ "$USE_SEPARATE_XVAS" = "0" ]; then
XVA=$XVA_DIR/$UBUNTU_VERSION.xva
else
XVA=$XVA_DIR/$UBUNTU_VERSION.$GUEST_NAME.xva
fi
# Clean old xva. In the future may not do this every time.
rm -f $XVA
# Configure the hostname
echo $GUEST_NAME > $STAGING_DIR/etc/hostname
# Hostname must resolve for rabbit
cat <<EOF >$STAGING_DIR/etc/hosts
$MGT_IP $GUEST_NAME
127.0.0.1 localhost localhost.localdomain
EOF
# Configure the network
INTERFACES=$STAGING_DIR/etc/network/interfaces
cp $TEMPLATES_DIR/interfaces.in $INTERFACES
sed -e "s,@ETH1_IP@,$VM_IP,g" -i $INTERFACES
sed -e "s,@ETH1_NETMASK@,$VM_NETMASK,g" -i $INTERFACES
sed -e "s,@ETH2_IP@,$MGT_IP,g" -i $INTERFACES
sed -e "s,@ETH2_NETMASK@,$MGT_NETMASK,g" -i $INTERFACES
sed -e "s,@ETH3_IP@,$PUB_IP,g" -i $INTERFACES
sed -e "s,@ETH3_NETMASK@,$PUB_NETMASK,g" -i $INTERFACES
# Gracefully cp only if source file/dir exists
function cp_it {
if [ -e $1 ] || [ -d $1 ]; then
cp -pRL $1 $2
fi
}
# Copy over your ssh keys and env if desired
COPYENV=${COPYENV:-1}
if [ "$COPYENV" = "1" ]; then
cp_it ~/.ssh $STAGING_DIR/opt/stack/.ssh
cp_it ~/.ssh/id_rsa.pub $STAGING_DIR/opt/stack/.ssh/authorized_keys
cp_it ~/.gitconfig $STAGING_DIR/opt/stack/.gitconfig
cp_it ~/.vimrc $STAGING_DIR/opt/stack/.vimrc
cp_it ~/.bashrc $STAGING_DIR/opt/stack/.bashrc
fi
# Configure run.sh
cat <<EOF >$STAGING_DIR/opt/stack/run.sh
#!/bin/bash
cd /opt/stack/devstack
killall screen
UPLOAD_LEGACY_TTY=yes HOST_IP=$PUB_IP VIRT_DRIVER=xenserver FORCE=yes MULTI_HOST=1 $STACKSH_PARAMS ./stack.sh
EOF
chmod 755 $STAGING_DIR/opt/stack/run.sh
# Create xva
if [ ! -e $XVA ]; then
rm -rf /tmp/mkxva*
UID=0 $SCRIPT_DIR/mkxva -o $XVA -t xva -x $OVA $STAGING_DIR $VDI_MB /tmp/
fi
# Start guest
$TOP_DIR/scripts/install-os-vpx.sh -f $XVA -v $VM_BR -m $MGT_BR -p $PUB_BR
# If we have copied our ssh credentials, use ssh to monitor while the installation runs
WAIT_TILL_LAUNCH=${WAIT_TILL_LAUNCH:-1}
if [ "$WAIT_TILL_LAUNCH" = "1" ] && [ -e ~/.ssh/id_rsa.pub ] && [ "$COPYENV" = "1" ]; then
# Done creating the container, let's tail the log
echo
echo "============================================================="
echo " -- YAY! --"
echo "============================================================="
echo
echo "We're done launching the vm, about to start tailing the"
echo "stack.sh log. It will take a second or two to start."
echo
echo "Just CTRL-C at any time to stop tailing."
set +o xtrace
while ! ssh -q stack@$PUB_IP "[ -e run.sh.log ]"; do
sleep 1
done
ssh stack@$PUB_IP 'tail -f run.sh.log' &
TAIL_PID=$!
function kill_tail() {
kill $TAIL_PID
exit 1
}
# Let Ctrl-c kill tail and exit
trap kill_tail SIGINT
echo "Waiting stack.sh to finish..."
while ! ssh -q stack@$PUB_IP "grep -q 'stack.sh completed in' run.sh.log"; do
sleep 1
done
kill $TAIL_PID
if ssh -q stack@$PUB_IP "grep -q 'stack.sh failed' run.sh.log"; then
exit 1
fi
echo ""
echo "Finished - Zip-a-dee Doo-dah!"
echo "You can then visit the OpenStack Dashboard"
echo "at http://$PUB_IP, and contact other services at the usual ports."
else
echo "################################################################################"
echo ""
echo "All Finished!"
echo "Now, you can monitor the progress of the stack.sh installation by "
echo "tailing /opt/stack/run.sh.log from within your domU."
echo ""
echo "ssh into your domU now: 'ssh stack@$PUB_IP' using your password"
echo "and then do: 'tail -f /opt/stack/run.sh.log'"
echo ""
echo "When the script completes, you can then visit the OpenStack Dashboard"
echo "at http://$PUB_IP, and contact other services at the usual ports."
fi

@ -1,35 +0,0 @@
#!/usr/bin/env bash
# Echo commands
set -o xtrace
# Head node host, which runs glance, api, keystone
HEAD_PUB_IP=${HEAD_PUB_IP:-192.168.1.57}
HEAD_MGT_IP=${HEAD_MGT_IP:-172.16.100.57}
COMPUTE_PUB_IP=${COMPUTE_PUB_IP:-192.168.1.58}
COMPUTE_MGT_IP=${COMPUTE_MGT_IP:-172.16.100.58}
# Networking params
FLOATING_RANGE=${FLOATING_RANGE:-192.168.1.196/30}
# Variables common amongst all hosts in the cluster
COMMON_VARS="$STACKSH_PARAMS MYSQL_HOST=$HEAD_MGT_IP RABBIT_HOST=$HEAD_MGT_IP GLANCE_HOSTPORT=$HEAD_MGT_IP:9292 FLOATING_RANGE=$FLOATING_RANGE"
# Helper to launch containers
function build_domU {
GUEST_NAME=$1 PUB_IP=$2 MGT_IP=$3 DO_SHUTDOWN=$4 TERMINATE=$TERMINATE STACKSH_PARAMS="$COMMON_VARS $5" ./build_domU.sh
}
# Launch the head node - headnode uses a non-ip domain name,
# because rabbit won't launch with an ip addr hostname :(
build_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"
# Wait till the head node is up
while ! curl -L http://$HEAD_PUB_IP | grep -q username; do
echo "Waiting for head node ($HEAD_PUB_IP) to start..."
sleep 5
done
# Build the HA compute host
build_domU $COMPUTE_PUB_IP $COMPUTE_PUB_IP $COMPUTE_MGT_IP 0 "ENABLED_SERVICES=n-cpu,n-net,n-api"

@ -1,5 +0,0 @@
LABEL=vpxroot / ext3 defaults 1 1
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0

@ -1,10 +0,0 @@
# hvc0 - getty
#
# This service maintains a getty on hvc0 from the point the system is
# started until it is shut down again.
start on stopped rc RUNLEVEL=[2345]
stop on runlevel [!2345]
respawn
exec /sbin/getty -8 9600 hvc0

@ -1,41 +0,0 @@
#!/bin/sh
set -o xtrace
set -o errexit
# Install basics for vi and git
yum -y --enablerepo=base install gcc make vim-enhanced zlib-devel openssl-devel
# Simple but usable vimrc
if [ ! -e /root/.vimrc ]; then
cat > /root/.vimrc <<EOF
syntax on
se ts=4
se expandtab
se shiftwidth=4
EOF
fi
# Use the pretty vim
if [ -e /usr/bin/vim ]; then
rm /bin/vi
ln -s /usr/bin/vim /bin/vi
fi
# Install git
if ! which git; then
DEST=/tmp/
GITDIR=$DEST/git-1.7.7
cd $DEST
rm -rf $GITDIR*
wget http://git-core.googlecode.com/files/git-1.7.7.tar.gz
tar xfv git-1.7.7.tar.gz
cd $GITDIR
./configure
make install
fi
# Clone devstack
DEVSTACK=/root/devstack
if [ ! -d $DEVSTACK ]; then
git clone git://github.com/cloudbuilders/devstack.git $DEVSTACK
fi

@ -1,88 +0,0 @@
#!/bin/bash
# Configurable nuggets
GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
STAGING_DIR=${STAGING_DIR:-stage}
DO_TGZ=${DO_TGZ:-1}
KERNEL_VERSION=3.0.0-12-virtual
# Debootstrap base system
if [ ! -d $STAGING_DIR ]; then
apt-get install debootstrap
debootstrap --arch amd64 oneiric $STAGING_DIR http://us.archive.ubuntu.com/ubuntu/
fi
# Sources.list
cat <<EOF >$STAGING_DIR/etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu/ oneiric main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric main restricted
deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ oneiric-updates main restricted
deb http://us.archive.ubuntu.com/ubuntu/ oneiric universe
deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates universe
deb http://us.archive.ubuntu.com/ubuntu/ oneiric multiverse
deb http://us.archive.ubuntu.com/ubuntu/ oneiric-updates multiverse
EOF
# Install basics
chroot $STAGING_DIR apt-get update
chroot $STAGING_DIR apt-get install -y linux-image-$KERNEL_VERSION
chroot $STAGING_DIR apt-get install -y cracklib-runtime curl wget ssh openssh-server tcpdump ethtool
chroot $STAGING_DIR apt-get install -y curl wget ssh openssh-server python-pip git vim-nox sudo
chroot $STAGING_DIR pip install xenapi
# Install guest utilities
XEGUEST=xe-guest-utilities_5.6.100-651_amd64.deb
wget http://images.ansolabs.com/xen/$XEGUEST -O $XEGUEST
cp $XEGUEST $STAGING_DIR/root
chroot $STAGING_DIR dpkg -i /root/$XEGUEST
chroot $STAGING_DIR update-rc.d -f xe-linux-distribution remove
chroot $STAGING_DIR update-rc.d xe-linux-distribution defaults
# Make a small cracklib dictionary, so that passwd still works, but we don't
# have the big dictionary.
mkdir -p $STAGING_DIR/usr/share/cracklib
echo a | chroot $STAGING_DIR cracklib-packer
# Make /etc/shadow, and set the root password
chroot $STAGING_DIR "pwconv"
echo "root:$GUEST_PASSWORD" | chroot $STAGING_DIR chpasswd
# Put the VPX into UTC.
rm -f $STAGING_DIR/etc/localtime
# Add stack user
chroot $STAGING_DIR groupadd libvirtd
chroot $STAGING_DIR useradd stack -s /bin/bash -d /opt/stack -G libvirtd
echo stack:$GUEST_PASSWORD | chroot $STAGING_DIR chpasswd
echo "stack ALL=(ALL) NOPASSWD: ALL" >> $STAGING_DIR/etc/sudoers
# Give ownership of /opt/stack to stack user
chroot $STAGING_DIR chown -R stack /opt/stack
# Make our ip address hostnames look nice at the command prompt
echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $STAGING_DIR/opt/stack/.bashrc
echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $STAGING_DIR/root/.bashrc
echo "export PS1='${debian_chroot:+($debian_chroot)}\\u@\\H:\\w\\$ '" >> $STAGING_DIR/etc/profile
function setup_vimrc {
if [ ! -e $1 ]; then
# Simple but usable vimrc
cat > $1 <<EOF
syntax on
se ts=4
se expandtab
se shiftwidth=4
EOF
fi
}
# Setup simple .vimrcs
setup_vimrc $STAGING_DIR/root/.vimrc
setup_vimrc $STAGING_DIR/opt/stack/.vimrc
if [ "$DO_TGZ" = "1" ]; then
# Compress
rm -f stage.tgz
tar cfz stage.tgz stage
fi

@ -1,507 +0,0 @@
#!/bin/bash
#
# Copyright (c) 2011 Citrix Systems, Inc.
# Copyright 2011 OpenStack LLC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
set -eux
. /etc/xensource-inventory
NAME="XenServer OpenStack VPX"
DATA_VDI_SIZE="500MiB"
BRIDGE_M=
BRIDGE_P=
KERNEL_PARAMS=
VPX_FILE=os-vpx.xva
AS_TEMPLATE=
FROM_TEMPLATE=
RAM=
WAIT_FOR_NETWORK=
BALLOONING=
usage()
{
cat << EOF
Usage: $0 [-f FILE_PATH] [-d DISK_SIZE] [-v BRIDGE_NAME] [-m BRIDGE_NAME] [-p BRIDGE_NAME]
[-k PARAMS] [-r RAM] [-i|-c] [-w] [-b]
Installs XenServer OpenStack VPX.
OPTIONS:
-h Shows this message.
-i Install OpenStack VPX as template.
-c Clone from existing template.
-w Wait for the network settings to show up before exiting.
-b Enable memory ballooning. When set min_RAM=RAM/2 max_RAM=RAM.
-f path Specifies the path to the XVA.
Default to ./os-vpx.xva.
-d disk-size Specifies the size in MiB for the data disk.
Defaults to 500 MiB.
-m bridge Specifies the bridge for the isolated management network.
Defaults to xenbr0.
-v bridge Specifies the bridge for the vm network
-p bridge Specifies the bridge for the externally facing network.
-k params Specifies kernel parameters.
-r MiB Specifies RAM used by the VPX, in MiB.
By default it will take the value from the XVA.
EXAMPLES:
Create a VPX that connects to the isolated management network using the
default bridge with a data disk of 1GiB:
install-os-vpx.sh -f /root/os-vpx-devel.xva -d 1024
Create a VPX that connects to the isolated management network using xenbr1
as bridge:
install-os-vpx.sh -m xenbr1
Create a VPX that connects to both the management and public networks
using xenbr1 and xapi4 as bridges:
install-os-vpx.sh -m xenbr1 -p xapi4
Create a VPX that connects to both the management and public networks
using the default for management traffic:
install-os-vpx.sh -m xapi4
Create a VPX that automatically becomes the master:
install-os-vpx.sh -k geppetto_master=true
EOF
}
get_params()
{
while getopts "hicwbf:d:v:m:p:k:r:" OPTION;
do
case $OPTION in
h) usage
exit 1
;;
i)
AS_TEMPLATE=1
;;
c)
FROM_TEMPLATE=1
;;
w)
WAIT_FOR_NETWORK=1
;;
b)
BALLOONING=1
;;
f)
VPX_FILE=$OPTARG
;;
d)
DATA_VDI_SIZE="${OPTARG}MiB"
;;
m)
BRIDGE_M=$OPTARG
;;
p)
BRIDGE_P=$OPTARG
;;
k)
KERNEL_PARAMS=$OPTARG
;;
r)
RAM=$OPTARG
;;
v)
BRIDGE_V=$OPTARG
;;
?)
usage
exit
;;
esac
done
if [[ -z $BRIDGE_M ]]
then
BRIDGE_M=xenbr0
fi
}
xe_min()
{
local cmd="$1"
shift
xe "$cmd" --minimal "$@"
}
get_dest_sr()
{
IFS=,
sr_uuids=$(xe sr-list --minimal other-config:i18n-key=local-storage)
dest_sr=""
for sr_uuid in $sr_uuids
do
pbd=$(xe pbd-list --minimal sr-uuid=$sr_uuid host-uuid=$INSTALLATION_UUID)
if [ "$pbd" ]
then
echo "$sr_uuid"
unset IFS
return
fi
done
unset IFS
dest_sr=$(xe_min sr-list uuid=$(xe_min pool-list params=default-SR))
if [ "$dest_sr" = "" ]
then
echo "No local storage and no default storage; cannot import VPX." >&2
exit 1
else
echo "$dest_sr"
fi
}
find_network()
{
result=$(xe_min network-list bridge="$1")
if [ "$result" = "" ]
then
result=$(xe_min network-list name-label="$1")
fi
echo "$result"
}
find_template()
{
xe_min template-list other-config:os-vpx=true
}
renumber_system_disk()
{
local v="$1"
local vdi_uuid=$(xe_min vbd-list vm-uuid="$v" type=Disk userdevice=xvda \
params=vdi-uuid)
if [ "$vdi_uuid" ]
then
local vbd_uuid=$(xe_min vbd-list vm-uuid="$v" vdi-uuid="$vdi_uuid")
xe vbd-destroy uuid="$vbd_uuid"
local new_vbd_uuid=$(xe vbd-create vm-uuid="$v" vdi-uuid="$vdi_uuid" \
device=0 bootable=true type=Disk)
xe vbd-param-set other-config:owner uuid="$new_vbd_uuid"
fi
}
create_vif()
{
xe vif-create vm-uuid="$1" network-uuid="$2" device="$3"
}
create_gi_vif()
{
local v="$1"
# Note that we've made the outbound device eth1, so that it comes up after
# the guest installer VIF, which means that the outbound one wins in terms
# of gateway.
local gi_network_uuid=$(xe_min network-list \
other-config:is_guest_installer_network=true)
create_vif "$v" "$gi_network_uuid" "0" >/dev/null
}
create_vm_vif()
{
local v="$1"
echo "Installing management interface on $BRIDGE_V."
local out_network_uuid=$(find_network "$BRIDGE_V")
create_vif "$v" "$out_network_uuid" "1" >/dev/null
}
create_management_vif()
{
local v="$1"
echo "Installing management interface on $BRIDGE_M."
local out_network_uuid=$(find_network "$BRIDGE_M")
create_vif "$v" "$out_network_uuid" "2" >/dev/null
}
# This installs the interface for public traffic, only if a bridge is specified
# The interface is not configured at this stage, but it will be, once the admin
# tasks are complete for the services of this VPX
create_public_vif()
{
local v="$1"
if [[ -z $BRIDGE_P ]]
then
echo "Skipping installation of interface for public traffic."
else
echo "Installing public interface on $BRIDGE_P."
pub_network_uuid=$(find_network "$BRIDGE_P")
create_vif "$v" "$pub_network_uuid" "3" >/dev/null
fi
}
label_system_disk()
{
local v="$1"
local vdi_uuid=$(xe_min vbd-list vm-uuid="$v" type=Disk userdevice=0 \
params=vdi-uuid)
xe vdi-param-set \
name-label="$NAME system disk" \
other-config:os-vpx=true \
uuid=$vdi_uuid
}
create_data_disk()
{
local v="$1"
local sys_vdi_uuid=$(xe_min vbd-list vm-uuid="$v" type=Disk params=vdi-uuid)
local data_vdi_uuid=$(xe_min vdi-list other-config:os-vpx-data=true)
if echo "$data_vdi_uuid" | grep -q ,
then
echo "Multiple data disks found -- assuming that you want a new one."
data_vdi_uuid=""
else
data_in_use=$(xe_min vbd-list vdi-uuid="$data_vdi_uuid")
if [ "$data_in_use" != "" ]
then
echo "Data disk already in use -- will create another one."
data_vdi_uuid=""
fi
fi
if [ "$data_vdi_uuid" = "" ]
then
echo -n "Creating new data disk ($DATA_VDI_SIZE)... "
sr_uuid=$(xe_min vdi-list params=sr-uuid uuid="$sys_vdi_uuid")
data_vdi_uuid=$(xe vdi-create name-label="$NAME data disk" \
sr-uuid="$sr_uuid" \
type=user \
virtual-size="$DATA_VDI_SIZE")
xe vdi-param-set \
other-config:os-vpx-data=true \
uuid="$data_vdi_uuid"
dom0_uuid=$(xe_min vm-list is-control-domain=true)
vbd_uuid=$(xe vbd-create device=autodetect type=Disk \
vdi-uuid="$data_vdi_uuid" vm-uuid="$dom0_uuid")
xe vbd-plug uuid=$vbd_uuid
dev=$(xe_min vbd-list params=device uuid=$vbd_uuid)
mke2fs -q -j -m0 /dev/$dev
e2label /dev/$dev vpxstate
xe vbd-unplug uuid=$vbd_uuid
xe vbd-destroy uuid=$vbd_uuid
else
echo -n "Attaching old data disk... "
fi
vbd_uuid=$(xe vbd-create device=2 type=Disk \
vdi-uuid="$data_vdi_uuid" vm-uuid="$v")
xe vbd-param-set other-config:os-vpx-data=true uuid=$vbd_uuid
echo "done."
}
set_kernel_params()
{
local v="$1"
local args=$KERNEL_PARAMS
local cmdline=$(cat /proc/cmdline)
for word in $cmdline
do
if echo "$word" | grep -q "geppetto"
then
args="$word $args"
fi
done
if [ "$args" != "" ]
then
echo "Passing Geppetto args to VPX: $args."
xe vm-param-set PV-args="$args" uuid="$v"
fi
}
set_memory()
{
local v="$1"
if [ "$RAM" != "" ]
then
echo "Setting RAM to $RAM MiB."
[ "$BALLOONING" == 1 ] && RAM_MIN=$(($RAM / 2)) || RAM_MIN=$RAM
xe vm-memory-limits-set static-min=16MiB static-max=${RAM}MiB \
dynamic-min=${RAM_MIN}MiB dynamic-max=${RAM}MiB \
uuid="$v"
fi
}
# Make the VM auto-start on server boot.
set_auto_start()
{
local v="$1"
xe vm-param-set uuid="$v" other-config:auto_poweron=true
}
set_all()
{
local v="$1"
set_kernel_params "$v"
set_memory "$v"
set_auto_start "$v"
label_system_disk "$v"
create_gi_vif "$v"
create_vm_vif "$v"
create_management_vif "$v"
create_public_vif "$v"
}
log_vifs()
{
local v="$1"
(IFS=,
for vif in $(xe_min vif-list vm-uuid="$v")
do
dev=$(xe_min vif-list uuid="$vif" params=device)
mac=$(xe_min vif-list uuid="$vif" params=MAC | sed -e 's/:/-/g')
echo "eth$dev has MAC $mac."
done
unset IFS) | sort
}
destroy_vifs()
{
local v="$1"
IFS=,
for vif in $(xe_min vif-list vm-uuid="$v")
do
xe vif-destroy uuid="$vif"
done
unset IFS
}
get_params "$@"
thisdir=$(dirname "$0")
if [ "$FROM_TEMPLATE" ]
then
template_uuid=$(find_template)
name=$(xe_min template-list params=name-label uuid="$template_uuid")
echo -n "Cloning $name... "
vm_uuid=$(xe vm-clone vm="$template_uuid" new-name-label="$name")
xe vm-param-set is-a-template=false uuid="$vm_uuid"
echo $vm_uuid.
destroy_vifs "$vm_uuid"
set_all "$vm_uuid"
else
if [ ! -f "$VPX_FILE" ]
then
# Search $thisdir/$VPX_FILE too. In particular, this is used when
# installing the VPX from the supp-pack, because we want to be able to
# invoke this script from the RPM and the firstboot script.
if [ -f "$thisdir/$VPX_FILE" ]
then
VPX_FILE="$thisdir/$VPX_FILE"
else
echo "$VPX_FILE does not exist." >&2
exit 1
fi
fi
echo "Found OS-VPX File: $VPX_FILE. "
dest_sr=$(get_dest_sr)
echo -n "Installing $NAME... "
vm_uuid=$(xe vm-import filename=$VPX_FILE sr-uuid="$dest_sr")
echo $vm_uuid.
renumber_system_disk "$vm_uuid"
nl=$(xe_min vm-list params=name-label uuid=$vm_uuid)
xe vm-param-set \
"name-label=${nl/ import/}" \
other-config:os-vpx=true \
uuid=$vm_uuid
set_all "$vm_uuid"
create_data_disk "$vm_uuid"
if [ "$AS_TEMPLATE" ]
then
xe vm-param-set uuid="$vm_uuid" is-a-template=true \
other-config:instant=true
echo -n "Installing VPX from template... "
vm_uuid=$(xe vm-clone vm="$vm_uuid" new-name-label="${nl/ import/}")
xe vm-param-set is-a-template=false uuid="$vm_uuid"
echo "$vm_uuid."
fi
fi
log_vifs "$vm_uuid"
echo -n "Starting VM... "
xe vm-start uuid=$vm_uuid
echo "done."
show_ip()
{
ip_addr=$(echo "$1" | sed -n "s,^.*"$2"/ip: \([^;]*\).*$,\1,p")
echo -n "IP address for $3: "
if [ "$ip_addr" = "" ]
then
echo "did not appear."
else
echo "$ip_addr."
fi
}
if [ "$WAIT_FOR_NETWORK" ]
then
echo "Waiting for network configuration... "
i=0
while [ $i -lt 600 ]
do
ip=$(xe_min vm-list params=networks uuid=$vm_uuid)
if [ "$ip" != "<not in database>" ]
then
show_ip "$ip" "1" "$BRIDGE_M"
if [[ $BRIDGE_P ]]
then
show_ip "$ip" "2" "$BRIDGE_P"
fi
echo "Installation complete."
exit 0
fi
sleep 10
let i=i+1
done
fi

@ -1,365 +0,0 @@
#!/bin/bash
#
# Copyright (c) 2011 Citrix Systems, Inc.
# Copyright 2011 OpenStack LLC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
set -eu
set -o xtrace
VBOX_IMG=/output/packages/vbox-img
usage() {
cat >&2 <<EOF
$0 -o <output filenames> -t <types> -x <xml files> <fs-staging-dir> <fs-size-MiB> <tmpdir>
-o: Colon-separated list of output filenames (one for each type).
-p: Create a disk label and partition within the output image
-t: Colon-separated list of types of output file. xva and ovf supported.
-x: XML filenames (one for each type)
EOF
exit 1
}
# parse cmdline
OPT_USE_PARTITION=
OPT_TYPES=
OPT_OUTPUT_FILES=
OPT_XML_FILES=
while getopts o:pt:x: o
do case "$o" in
o) OPT_OUTPUT_FILES=$(echo "$OPTARG" | sed -e 's/\s*:\s*/ /g')
;;
p) OPT_USE_PARTITION=1
;;
t) OPT_TYPES=$(echo "$OPTARG" | sed -e 's/\s*:\s*/ /g')
;;
x) OPT_XML_FILES=$(echo "$OPTARG" | sed -e 's/\s*:\s*/ /g')
;;
[?]) usage
;;
esac
done
shift $((OPTIND-1))
[ $# -ne 3 ] && usage
FS_STAGING="$1"
FS_SIZE_MIB="$2"
TMPDIR="$3"
if [ "$UID" = "0" ]
then
SUDO=
else
SUDO=sudo
fi
if [ "$FS_SIZE_MIB" = "0" ]
then
# Just create a dummy file. This allows developers to bypass bits of
# the build by setting the size to 0.
touch $OPT_OUTPUT_FILES
exit 0
fi
# create temporary files and dirs
FS_TMPFILE=$(mktemp "$TMPDIR/mkxva-fsimg-XXXXX")
XVA_TARBALL_STAGING=$(mktemp -d "$TMPDIR/mkxva-tarball-staging-XXXXX")
OVF_STAGING=$(mktemp -d "$TMPDIR/mkxva-ovf-staging-XXXXX")
# Find udevsettle and udevtrigger on this installation
if [ -x "/sbin/udevsettle" ] ; then
UDEVSETTLE="/sbin/udevsettle --timeout=30"
elif [ -x "/sbin/udevadm" ] ; then
UDEVSETTLE='/sbin/udevadm settle'
else
UDEVSETTLE='/bin/true'
fi
if [ -x "/sbin/udevtrigger" ] ; then
UDEVTRIGGER=/sbin/udevtrigger
elif [ -x "/sbin/udevadm" ] ; then
UDEVTRIGGER='/sbin/udevadm trigger'
else
UDEVTRIGGER=
fi
# CLEAN_ variables track devices and mounts that must be taken down
# no matter how the script exits. Loop devices are vulnerable to
# exhaustion so we make every effort to remove them
CLEAN_KPARTX=
CLEAN_LOSETUP=
CLEAN_MOUNTPOINT=
cleanup_devices () {
if [ -n "$CLEAN_MOUNTPOINT" ] ; then
echo "Mountpoint $CLEAN_MOUNTPOINT removed on abnormal exit"
$SUDO umount "$CLEAN_MOUNTPOINT" || echo "umount failed"
rmdir "$CLEAN_MOUNTPOINT" || echo "rmdir failed"
fi
if [ -n "$CLEAN_KPARTX" ] ; then
echo "kpartx devices for $CLEAN_KPARTX removed on abnormal exit"
$SUDO kpartx -d "$CLEAN_KPARTX" || echo "kpartx -d failed"
fi
if [ -n "$CLEAN_LOSETUP" ] ; then
echo "Loop device $CLEAN_LOSETUP removed on abnormal exit"
$SUDO losetup -d "$CLEAN_LOSETUP" # Allow losetup errors to propagate
fi
}
trap "cleanup_devices" EXIT
make_fs_inner () {
local staging="$1"
local output="$2"
local options="$3"
CLEAN_MOUNTPOINT=$(mktemp -d "$TMPDIR/mkfs-XXXXXX")
# copy staging dir contents to fs image
$SUDO mount $options "$output" "$CLEAN_MOUNTPOINT"
$SUDO tar -C "$staging" -c . | tar -C "$CLEAN_MOUNTPOINT" -x
$SUDO umount "$CLEAN_MOUNTPOINT"
rmdir "$CLEAN_MOUNTPOINT"
CLEAN_MOUNTPOINT=
}
# Turn a staging dir into an ext3 filesystem within a partition
make_fs_in_partition () {
local staging="$1"
local output="$2"
# create new empty disk
dd if=/dev/zero of="$output" bs=1M count=$FS_SIZE_MIB
# Set up a loop device on the empty disk image
local loopdevice=$($SUDO losetup -f)
$SUDO losetup "$loopdevice" "$output"
CLEAN_LOSETUP="$loopdevice"
# Create a partition table and single partition.
# Start partition at sector 63 to allow space for grub
cat <<EOF
Errors from sfdisk below are expected because the new disk is uninitialised
Expecting: sfdisk: ERROR: sector 0 does not have an msdos signature
Expecting: /dev/loop0: unrecognized partition table type
EOF
$SUDO sfdisk -uS "$CLEAN_LOSETUP" <<EOF
63 - - *
EOF
# kpartx creates a device for the new partition
# in the form /dev/mapper/loop1p1
$SUDO kpartx -av "$CLEAN_LOSETUP"
CLEAN_KPARTX="$CLEAN_LOSETUP"
# Wait for the device to appear
$UDEVTRIGGER
$UDEVSETTLE || echo "udev settle command return code non-zero"
# Infer the name of the partition device
local partition="${CLEAN_LOSETUP/dev/dev/mapper}p1"
# Set permissive privileges on the device
$SUDO chmod 0777 "$partition"
# Make an ext3 filesystem on the partition
/sbin/mkfs.ext3 -I 128 -m0 -F "$partition"
/sbin/e2label "$partition" vpxroot
make_fs_inner "$staging" "$partition" ""
# Now run grub on the image we've created
CLEAN_MOUNTPOINT=$(mktemp -d "$TMPDIR/mkfs-XXXXXX")
# copy Set up[ grub files prior to installing grub within the image
$SUDO mount "$partition" "$CLEAN_MOUNTPOINT"
$SUDO cp $CLEAN_MOUNTPOINT/usr/share/grub/i386-redhat/* "$CLEAN_MOUNTPOINT/boot/grub"
kernel_version=$($SUDO chroot "$CLEAN_MOUNTPOINT" rpm -qv kernel | sed -e 's/kernel-//')
kernel_version_xen=$($SUDO chroot "$CLEAN_MOUNTPOINT" rpm -qv kernel-xen | sed -e 's/kernel-xen-//')
$SUDO cat > "$CLEAN_MOUNTPOINT/boot/grub/grub.conf" <<EOF
default 0
timeout 2
title vmlinuz-$kernel_version (HVM)
root (hd0,0)
kernel /boot/vmlinuz-$kernel_version ro root=LABEL=vpxroot
initrd /boot/initrd-$kernel_version.img
title vmlinuz-${kernel_version_xen}xen (PV)
root (hd0,0)
kernel /boot/vmlinuz-${kernel_version_xen}xen ro root=LABEL=vpxroot console=xvc0
initrd /boot/initrd-${kernel_version_xen}xen.img
EOF
$SUDO umount "$CLEAN_MOUNTPOINT"
CLEAN_MOUNTPOINT=
# Grub expects a disk with name /dev/xxxx with a first partition
# named /dev/xxxx1, so we give it what it wants using symlinks
# Note: /dev is linked to the real /dev of the build machine, so
# must be cleaned up
local disk_name="/dev/osxva$$bld"
local disk_part1_name="${disk_name}1"
rm -f "$disk_name"
rm -f "$disk_part1_name"
ln -s "$CLEAN_LOSETUP" "$disk_name"
ln -s "$partition" "$disk_part1_name"
# Feed commands into the grub shell to setup the disk
grub --no-curses --device-map=/dev/null <<EOF
device (hd0) $disk_name
setup (hd0) (hd0,0)
quit
EOF
# Cleanup
rm -f "$disk_name"
rm -f "$disk_part1_name"
$SUDO kpartx -dv "$CLEAN_KPARTX"
CLEAN_KPARTX=
$SUDO losetup -d "$CLEAN_LOSETUP"
CLEAN_LOSETUP=
}
# turn a staging dir into an ext3 filesystem image
make_fs () {
local staging="$1"
local output="$2"
# create new empty fs
dd if=/dev/zero of="$output" bs=1M count=0 seek=$FS_SIZE_MIB
/sbin/mkfs.ext3 -m0 -F "$output"
/sbin/e2label "$output" vpxroot
make_fs_inner "$staging" "$output" "-oloop"
}
# split a virtual disk image into the format expected inside an xva file
splitvdi () {
local diskimg="$1"
local outputdir="$2"
local rio="$3"
local n_bytes=$(stat --printf=%s "$diskimg")
local n_meg=$((($n_bytes+$((1024*1024 -1)))/$((1024*1024))))
local i=0
while [ $i -lt $n_meg ] ; do
if [ $rio -eq 0 ] ; then
local file="$outputdir"/chunk-$(printf "%08d" $i)
dd if="$diskimg" of="$file" skip=$i bs=1M count=1 2>/dev/null
gzip "$file"
else
local file="$outputdir"/$(printf "%08d" $i)
dd if="$diskimg" of="$file" skip=$i bs=1M count=1 2>/dev/null
local chksum=$(sha1sum -b "$file")
echo -n "${chksum/ */}" > "$file.checksum"
fi
i=$(($i + 1))
done
}
if [ -n "$OPT_USE_PARTITION" ] ; then
make_fs_in_partition "$FS_STAGING" "$FS_TMPFILE"
else
make_fs "$FS_STAGING" "$FS_TMPFILE"
fi
VDI_SIZE=$(stat --format=%s "$FS_TMPFILE")
make_xva () {
local output_file="$1"
local xml_file="$2"
local subdir
local rio
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>" ]]
then
# it's a rio style xva
subdir="${BASH_REMATCH[1]}";
rio=1
else
# it's a geneva style xva
subdir="xvda"
rio=0
fi
cp "$xml_file" "$XVA_TARBALL_STAGING"/ova.xml
sed -i -e "s/@VDI_SIZE@/$VDI_SIZE/" "$XVA_TARBALL_STAGING"/ova.xml
mkdir "$XVA_TARBALL_STAGING/$subdir"
splitvdi "$FS_TMPFILE" "$XVA_TARBALL_STAGING/$subdir" "$rio"
TARFILE_MEMBERS=$(cd "$XVA_TARBALL_STAGING" && echo ova.xml $subdir/*)
tar -C "$XVA_TARBALL_STAGING" --format=v7 -c $TARFILE_MEMBERS -f "$output_file.tmp"
mv "$output_file.tmp" "$output_file"
}
make_ovf () {
local output_dir="$1"
local xml_file="$2"
local output_base=$(basename "$output_dir")
local disk="$output_dir/${output_base}.vmdk"
local manifest="$output_dir/${output_base}.mf"
local ovf="$output_dir/${output_base}.ovf"
mkdir -p "$output_dir"
rm -f "$disk"
$VBOX_IMG convert --srcfilename="$FS_TMPFILE" --dstfilename="$disk" \
--srcformat RAW --dstformat VMDK --variant Stream
chmod 0644 "$disk"
local n_bytes=$(stat --printf=%s "$disk")
cp "$xml_file" "$ovf"
sed -i -e "s/@MKXVA_DISK_FULLSIZE@/$VDI_SIZE/" "$ovf"
sed -i -e "s/@MKXVA_DISK_SIZE@/$n_bytes/" "$ovf"
sed -i -e "s/@MKXVA_DISK_MIB_SIZE@/$FS_SIZE_MIB/" "$ovf"
sed -i -e "s/@MKXVA_DISK_FILENAME@/${output_base}.vmdk/" "$ovf"
for to_sign in "$ovf" "$disk"
do
local sha1_sum=$(sha1sum "$to_sign" | cut -d' ' -f1)
echo "SHA1($(basename "$to_sign"))= $sha1_sum" >> $manifest
done
}
output_files="$OPT_OUTPUT_FILES"
xml_files="$OPT_XML_FILES"
# Iterate through the type list creating the relevant VMs
for create_type in $OPT_TYPES
do
# Shift one parameter from the front of the lists
create_output_file="${output_files%% *}"
output_files="${output_files#* }"
create_xml_file="${xml_files%% *}"
xml_files="${xml_files#* }"
echo "Creating $create_type appliance $create_output_file using metadata file $create_xml_file"
case "$create_type" in
xva)
make_xva "$create_output_file" "$create_xml_file"
;;
ovf)
make_ovf "$create_output_file" "$create_xml_file"
;;
*)
echo "Unknown VM type '$create_type'"
exit 1
;;
esac
done
# cleanup
if [ -z "${DO_NOT_CLEANUP:-}" ] ; then
rm -rf "$XVA_TARBALL_STAGING"
rm -f "$FS_TMPFILE"
fi

@ -1,101 +0,0 @@
#!/bin/bash
#
# Copyright (c) 2011 Citrix Systems, Inc.
# Copyright 2011 OpenStack LLC.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
remove_data=
if [ "$1" = "--remove-data" ]
then
remove_data=1
fi
set -eu
xe_min()
{
local cmd="$1"
shift
/opt/xensource/bin/xe "$cmd" --minimal "$@"
}
destroy_vdi()
{
local vbd_uuid="$1"
local type=$(xe_min vbd-list uuid=$vbd_uuid params=type)
local dev=$(xe_min vbd-list uuid=$vbd_uuid params=userdevice)
local vdi_uuid=$(xe_min vbd-list uuid=$vbd_uuid params=vdi-uuid)
if [ "$type" = 'Disk' ] && [ "$dev" != 'xvda' ] && [ "$dev" != '0' ]
then
echo -n "Destroying data disk... "
xe vdi-destroy uuid=$vdi_uuid
echo "done."
fi
}
uninstall()
{
local vm_uuid="$1"
local power_state=$(xe_min vm-list uuid=$vm_uuid params=power-state)
if [ "$power_state" != "halted" ]
then
echo -n "Shutting down VM... "
xe vm-shutdown vm=$vm_uuid force=true
echo "done."
fi
if [ "$remove_data" = "1" ]
then
for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g')
do
destroy_vdi "$v"
done
fi
echo -n "Deleting VM... "
xe vm-uninstall vm=$vm_uuid force=true >/dev/null
echo "done."
}
uninstall_template()
{
local vm_uuid="$1"
if [ "$remove_data" = "1" ]
then
for v in $(xe_min vbd-list vm-uuid=$vm_uuid | sed -e 's/,/ /g')
do
destroy_vdi "$v"
done
fi
echo -n "Deleting template... "
xe template-uninstall template-uuid=$vm_uuid force=true >/dev/null
echo "done."
}
for u in $(xe_min vm-list other-config:os-vpx=true | sed -e 's/,/ /g')
do
uninstall "$u"
done
for u in $(xe_min template-list other-config:os-vpx=true | sed -e 's/,/ /g')
do
uninstall_template "$u"
done

@ -1,8 +0,0 @@
127.0.0.1 localhost
127.0.0.1 %HOSTNAME%
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

@ -1,21 +0,0 @@
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address @ETH1_IP@
netmask @ETH1_NETMASK@
post-up ethtool -K eth1 tx off
auto eth2
iface eth2 inet static
address @ETH2_IP@
netmask @ETH2_NETMASK@
auto eth3
iface eth3 inet static
address @ETH3_IP@
netmask @ETH3_NETMASK@

@ -1,6 +0,0 @@
default 0
title default
root (hd0,0)
kernel /boot/vmlinuz-@KERNEL_VERSION@ ro root=LABEL=vpxroot console=xvc0
initrd /boot/initrd.img-@KERNEL_VERSION@

@ -1,14 +0,0 @@
<?xml version="1.0" ?>
<appliance version="0.1">
<vm name="vm">
<label>
@PRODUCT_BRAND@ @PRODUCT_VERSION@-@BUILD_NUMBER@
</label>
<shortdesc></shortdesc>
<config mem_set="671088640" vcpus="1"/>
<hacks is_hvm="false"/>
<vbd device="xvda" function="root" mode="w" vdi="vdi_xvda"/>
</vm>
<vdi name="vdi_xvda" size="@VDI_SIZE@" source="file://xvda" type="dir-gzipped-chunks" variety="system"/>
</appliance>
Loading…
Cancel
Save