From 57fd866dbf45d26ffa686976636ea3b44b41df93 Mon Sep 17 00:00:00 2001 From: Justin SB Date: Mon, 16 Jan 2012 03:41:31 +0000 Subject: [PATCH 1/2] Initial port to illumos --- files/dpkgs/general | 6 + files/dpkgs/glance | 0 files/dpkgs/keystone | 0 files/dpkgs/nova | 0 files/smfs/rabbitmq.xml | 61 +++++++++ stack.sh | 266 +++++++++++++++++++++++++++++++++++----- 6 files changed, 301 insertions(+), 32 deletions(-) create mode 100644 files/dpkgs/general create mode 100644 files/dpkgs/glance create mode 100644 files/dpkgs/keystone create mode 100644 files/dpkgs/nova create mode 100644 files/smfs/rabbitmq.xml diff --git a/files/dpkgs/general b/files/dpkgs/general new file mode 100644 index 00000000..197d558a --- /dev/null +++ b/files/dpkgs/general @@ -0,0 +1,6 @@ +runtime/gcc +python-26 +setuptools-26 +gcc-3 +header-math +# The system provided erlang crashes with rabbitmq (it's an old version) diff --git a/files/dpkgs/glance b/files/dpkgs/glance new file mode 100644 index 00000000..e69de29b diff --git a/files/dpkgs/keystone b/files/dpkgs/keystone new file mode 100644 index 00000000..e69de29b diff --git a/files/dpkgs/nova b/files/dpkgs/nova new file mode 100644 index 00000000..e69de29b diff --git a/files/smfs/rabbitmq.xml b/files/smfs/rabbitmq.xml new file mode 100644 index 00000000..f9054238 --- /dev/null +++ b/files/smfs/rabbitmq.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/stack.sh b/stack.sh index c3fe990f..912cbfab 100755 --- a/stack.sh +++ b/stack.sh @@ -20,11 +20,22 @@ # Sanity Check # ============ +HOSTNAME=`hostname` + +OS="linux" +UNAME=`uname` + +if [[ ${UNAME} =~ (SunOS) ]]; then + echo "Detected Illumos/OpenIndiana" + OS="illumos" + DISTRO='openindiana' +else + DISTRO=$(lsb_release -c -s) +fi + # Warn users who aren't on oneiric, but allow them to override check and attempt # installation with ``FORCE=yes ./stack`` -DISTRO=$(lsb_release -c -s) - -if [[ ! ${DISTRO} =~ (oneiric) ]]; then +if [[ (! ${DISTRO} =~ (oneiric) ) && ( ! ${DISTRO} == 'openindiana' ) ]]; then echo "WARNING: this script has only been tested on oneiric" if [[ "$FORCE" != "yes" ]]; then echo "If you wish to run this script anyway run with FORCE=yes" @@ -85,8 +96,32 @@ function apt_get() { [[ "$OFFLINE" = "True" ]] && return local sudo="sudo" [ "$(id -u)" = "0" ] && sudo="env" - $sudo DEBIAN_FRONTEND=noninteractive apt-get \ + [[ "$OS" == "linux" ]] && $sudo DEBIAN_FRONTEND=noninteractive apt-get \ --option "Dpkg::Options::=--force-confold" --assume-yes "$@" + [[ "$OS" == "illumos" ]] && $sudo pkg "$@" +} + +function apt_get_update() { + [[ "$OS" == "linux" ]] && apt_get update + [[ "$OS" == "illumos" ]] && apt_get refresh +} + +function apt_get_install() { + [[ "$OS" == "linux" ]] && apt_get install "$@" + if [[ "$OS" == "illumos" ]]; then + local installed=1 + pkg list $@ || installed=0 + if [[ "$installed" == 0 ]]; then + local r=0 + apt_get install --no-refresh "$@" || r=$? + if [[ ($r == 0) || ($r == 4) ]]; then + # 4 = no updates necessary (?) + echo "OK" + else + failed + fi + fi + fi } # Check to see if we are already running a stack.sh @@ -110,7 +145,7 @@ if [[ $EUID -eq 0 ]]; then # since this script runs as a normal user, we need to give that user # ability to run sudo - dpkg -l sudo || apt_get update && apt_get install sudo + dpkg -l sudo || apt_get_update && apt_get_install sudo if ! getent passwd stack >/dev/null; then echo "Creating a user called stack" @@ -186,7 +221,9 @@ Q_PORT=${Q_PORT:-9696} Q_HOST=${Q_HOST:-localhost} # Specify which services to launch. These generally correspond to screen tabs -ENABLED_SERVICES=${ENABLED_SERVICES:-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,horizon,mysql,rabbit,openstackx} +DEFAULT_SERVICES=-g-api,g-reg,key,n-api,n-cpu,n-net,n-sch,n-vnc,mysql,rabbit,openstackx +[[ ! "$OS" == "illumos" ]] && DEFAULT_SERVICES=${DEFAULT_SERVICES},horizon +[[ "$ENABLED_SERVICES" == "" ]] && ENABLED_SERVICES=${DEFAULT_SERVICES} # Name of the lvm volume group to use/create for iscsi volumes VOLUME_GROUP=${VOLUME_GROUP:-nova-volumes} @@ -456,9 +493,12 @@ function get_packages() { local file_to_parse="general" local service + local subdir="apts" + [[ "$OS" = "illumos" ]] && subdir="dpkgs" + for service in ${ENABLED_SERVICES//,/ }; do # Allow individual services to specify dependencies - if [[ -e $FILES/apts/${service} ]]; then + if [[ -e $FILES/${subdir}/${service} ]]; then file_to_parse="${file_to_parse} $service" fi if [[ $service == n-* ]]; then @@ -477,7 +517,7 @@ function get_packages() { done for file in ${file_to_parse}; do - local fname=${FILES}/apts/${file} + local fname=${FILES}/${subdir}/${file} local OIFS line package distros distro [[ -e $fname ]] || { echo "missing: $fname"; exit 1 ;} @@ -508,9 +548,66 @@ function pip_install { sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install --use-mirrors $@ } +function easy_install { + [[ "$OFFLINE" = "True" ]] && return + sudo easy_install $@ +} + + +function install_python_gflags() { + [[ -f ~/openstack/python-gflags/python-gflags-1.7 ]] && return + mkdir -p ~/openstack/python-gflags + pushd ~/openstack/python-gflags + + wget -N "http://python-gflags.googlecode.com/files/python-gflags-1.7.tar.gz" + tar zxf python-gflags-1.7.tar.gz + cd python-gflags-1.7 + sudo python ./setup.py install + popd +} + +function illumos_fixes { + [[ "$OS" != "illumos" ]] && return + + # Git / curl certificates aren't configured correctly + if [[ ! -f /etc/curl/curlCA ]]; then + sudo mkdir -p /etc/curl + cat /etc/certs/CA/*.pem | sudo tee /etc/curl/curlCA > /dev/null + fi + + # PyCrypto uses the 'wrong' path for gmp.h + [[ -f /usr/include/gmp.h ]] || sudo ln -s /usr/include/gmp/gmp.h /usr/include/gmp.h + + # We need pip + easy_install pip + + # Other dependencies that it's easiest to install here + # (we don't necessarily have packages for them) + # TODO: Should/can we install using pip? + easy_install netaddr + easy_install eventlet + pip_install lockfile #==0.8 + pip_install WebOb #==1.0.8 + + pip_install boto + pip_install carrot + pip_install kombu + pip_install paste + pip_install PasteDeploy #==1.5.0 + pip_install routes #==1.12.3 + pip_install SQLAlchemy + pip_install sqlalchemy-migrate + + apt_get_install python-mysql-26 + + install_python_gflags +} + # install apt requirements -apt_get update -apt_get install $(get_packages) +apt_get_update +apt_get_install $(get_packages) + +illumos_fixes # install python requirements pip_install `cat $FILES/pips/* | uniq` @@ -638,7 +735,7 @@ fi # --------- if [[ $SYSLOG != "False" ]]; then - apt_get install -y rsyslog-relp + apt_get_install -y rsyslog-relp if [[ "$SYSLOG_HOST" = "$HOST_IP" ]]; then # Configure the master host to receive cat </tmp/90-stack-m.conf @@ -659,13 +756,87 @@ fi # Rabbit # --------- -if [[ "$ENABLED_SERVICES" =~ "rabbit" ]]; then - # Install and start rabbitmq-server - # the temp file is necessary due to LP: #878600 +function build_erlang() { + if [[ -d /opt/erlang_r14b04 ]]; then + return + fi + + mkdir -p ~/openstack/erlang_r14 + pushd ~/openstack/erlang_r14 + wget -N "http://www.erlang.org/download/otp_src_R14B04.tar.gz" + tar zxf otp_src_R14B04.tar.gz +ERLANG_HOME=/opt/erlang_r14b04 +cd otp_src_R14B04 + +# Fix same bug as http://hg.services.openoffice.org/hg/cws/hr77/rev/966db5af43a8 +patch erts/emulator/drivers/common/inet_drv.c << EOF +4169c4169 +< #ifdef SIOCGIFHWADDR +--- +> #if defined(SIOCGIFHWADDR) && !defined(__sun) +EOF + +LANG=C +export LANG +./configure --prefix=${ERLANG_HOME} +gmake +sudo gmake install +} + + +function build_rabbitmq() { + build_erlang + + if [[ -f /usr/sbin/rabbitmq ]]; then + return + fi + + mkdir -p ~/openstack/rabbitmq + pushd ~/openstack/rabbitmq + wget -N "http://www.rabbitmq.com/releases/rabbitmq-server/v2.7.1/rabbitmq-server-generic-unix-2.7.1.tar.gz" + tar zxf rabbitmq-server-generic-unix-2.7.1.tar.gz + sudo mv rabbitmq_server-2.7.1 /opt + cd /opt + sudo ln -s /opt/rabbitmq_server-2.7.1 /opt/rabbitmq + cd /usr/sbin/ + sudo ln -s /opt/rabbitmq/sbin/rabbitmq + sudo ln -s /opt/rabbitmq/sbin/rabbitmqctl + sudo ln -s /opt/rabbitmq/sbin/rabbitmq-env + popd + + sudo groupadd rabbitmq + sudo useradd -c "RabbitMQ user" -m -d /export/home/rabbitmq -g rabbitmq -s /bin/bash rabbitmq + + sudo mkdir -p /var/lib/rabbitmq/mnesia + sudo mkdir -p /var/log/rabbitmq + + sudo chown -R rabbitmq:rabbitmq /var/lib/rabbitmq + sudo chown -R rabbitmq:rabbitmq /var/log/rabbitmq + + sudo svccfg import ${FILES}/smfs/rabbitmq.xml +} + +function install_rabbitmq() { + if [[ "$OS" == "illumos" ]]; then + build_rabbitmq + return + fi + tfile=$(mktemp) - apt_get install rabbitmq-server > "$tfile" 2>&1 + apt_get_install rabbitmq-server > "$tfile" 2>&1 cat "$tfile" rm -f "$tfile" +} + +if [[ "$ENABLED_SERVICES" =~ "rabbit" ]]; then + # Install and start rabbitmq-server + # the temp file is necessary due to LP: #878600 + install_rabbitmq + + # Copy the erlang cookie so the root user can use it + # TODO(justinsb): How does this work for other OSes? + sudo cp ~rabbitmq/.erlang.cookie /root/ + # change the rabbit password since the default is "guest" sudo rabbitmqctl change_password guest $RABBIT_PASSWORD fi @@ -673,15 +844,22 @@ fi # Mysql # --------- +function restart_service() { + sudo svcadm disable -s $@ + sudo svcadm enable -s $@ +} + if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then # Seed configuration with mysql password so that apt-get install doesn't # prompt us for a password upon install. - cat < natty ]]; then - apt_get install cgroup-lite + apt_get_install cgroup-lite else cgline="none /cgroup cgroup cpuacct,memory,devices,cpu,freezer,blkio 0 0" sudo mkdir -p /cgroup @@ -856,11 +1053,11 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then # The user that nova runs as needs to be member of libvirtd group otherwise # nova-compute will be unable to use libvirt. - sudo usermod -a -G libvirtd `whoami` + [[ "$OS" == "linux" ]] && sudo usermod -a -G libvirtd `whoami` # libvirt detects various settings on startup, as we potentially changed # the system configuration (modules, filesystems), we need to restart # libvirt to detect those changes. - sudo /etc/init.d/libvirt-bin restart + [[ "$OS" == "linux" ]] && sudo /etc/init.d/libvirt-bin restart # Instance Storage @@ -966,7 +1163,7 @@ if [[ "$ENABLED_SERVICES" =~ "swift" ]]; then # We install the memcache server as this is will be used by the # middleware to cache the tokens auths for a long this is needed. - apt_get install memcached + apt_get_install memcached # We need a special version of bin/swift which understand the # OpenStack api 2.0, we download it until this is getting @@ -1053,7 +1250,7 @@ if [[ "$ENABLED_SERVICES" =~ "n-vol" ]]; then # # By default, the backing file is 2G in size, and is stored in /opt/stack. - apt_get install iscsitarget-dkms iscsitarget + apt_get_install iscsitarget-dkms iscsitarget if ! sudo vgs $VOLUME_GROUP; then VOLUME_BACKING_FILE=${VOLUME_BACKING_FILE:-$DEST/nova-volumes-backing-file} @@ -1096,6 +1293,11 @@ add_nova_flag "--allow_admin_api" add_nova_flag "--scheduler_driver=$SCHEDULER" add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf" add_nova_flag "--fixed_range=$FIXED_RANGE" + +# Don't try to start the metadata service on illumos (it requires iptables) +[[ "$OS" = "illumos" ]] && add_nova_flag "--enabled_apis=ec2,osapi_compute,osapi_volume" + + if [[ "$ENABLED_SERVICES" =~ "quantum" ]]; then add_nova_flag "--network_manager=nova.network.quantum.manager.QuantumManager" add_nova_flag "--quantum_connection_host=$Q_HOST" @@ -1292,7 +1494,7 @@ if [[ "$ENABLED_SERVICES" =~ "q-svc" ]]; then if [[ "$Q_PLUGIN" = "openvswitch" ]]; then # Install deps # FIXME add to files/apts/quantum, but don't install if not needed! - apt_get install openvswitch-switch openvswitch-datapath-dkms + apt_get_install openvswitch-switch openvswitch-datapath-dkms # Create database for the plugin/agent if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then mysql -u$MYSQL_USER -p$MYSQL_PASSWORD -e 'CREATE DATABASE IF NOT EXISTS ovs_quantum;' @@ -1439,7 +1641,7 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-ramdisk" is_public=true container_format=ari disk_format=ari < "$RAMDISK"` RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` fi - glance add -A $SERVICE_TOKEN name="${IMAGE_NAME%.img}" is_public=true container_format=ami disk_format=ami ${KERNEL_ID:+kernel_id=$KERNEL_ID} ${RAMDISK_ID:+ramdisk_id=$RAMDISK_ID} < <(zcat --force "${IMAGE}") + glance add -A $SERVICE_TOKEN name="${IMAGE_NAME%.img}" is_public=true container_format=ami disk_format=ami ${KERNEL_ID:+kernel_id=$KERNEL_ID} ${RAMDISK_ID:+ramdisk_id=$RAMDISK_ID} < <(zcat "${IMAGE}") done fi From 18eaa1401e2ef6cdda4183cfb40eb7652760a058 Mon Sep 17 00:00:00 2001 From: Justin SB Date: Fri, 20 Jan 2012 02:57:07 +0000 Subject: [PATCH 2/2] Changes for illumos support --- exercises/euca.sh | 5 +++- exercises/floating_ips.sh | 9 ++++--- exercises/volumes.sh | 5 +++- files/dpkgs/general | 3 +++ helpers.sh | 7 +++++ illumos.sh | 47 ++++++++++++++++++++++++++++++++++ stack.sh | 54 ++++++++++++++++++++++++++++++--------- 7 files changed, 113 insertions(+), 17 deletions(-) create mode 100644 helpers.sh create mode 100644 illumos.sh diff --git a/exercises/euca.sh b/exercises/euca.sh index 2f7a17b0..0683dcfe 100755 --- a/exercises/euca.sh +++ b/exercises/euca.sh @@ -15,6 +15,9 @@ set -o xtrace # Settings # ======== +# Common functions +source ./helpers.sh + # Use openrc + stackrc + localrc for settings pushd $(cd $(dirname "$0")/.. && pwd) source ./openrc @@ -51,7 +54,7 @@ euca-authorize -P icmp -s 0.0.0.0/0 -t -1:-1 $SECGROUP # Test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds ASSOCIATE_TIMEOUT=${ASSOCIATE_TIMEOUT:-10} -if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then +if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ${PING_CMD} $FLOATING_IP; do sleep 1; done"; then echo "Couldn't ping server with floating ip" exit 1 fi diff --git a/exercises/floating_ips.sh b/exercises/floating_ips.sh index 9c207cd8..053360a8 100755 --- a/exercises/floating_ips.sh +++ b/exercises/floating_ips.sh @@ -19,6 +19,9 @@ set -o xtrace # Settings # ======== +# Common functions +source ./helpers.sh + # Use openrc + stackrc + localrc for settings pushd $(cd $(dirname "$0")/.. && pwd) source ./openrc @@ -117,7 +120,7 @@ if [ "$MULTI_HOST" = "0" ]; then # sometimes the first ping fails (10 seconds isn't enough time for the VM's # network to respond?), so let's ping for a default of 15 seconds with a # timeout of a second for each ping. - if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $IP; do sleep 1; done"; then + if ! timeout $BOOT_TIMEOUT sh -c "while ! ${PING_CMD} $IP; do sleep 1; done"; then echo "Couldn't ping server" exit 1 fi @@ -148,7 +151,7 @@ fi nova add-floating-ip $NAME $FLOATING_IP # test we can ping our floating ip within ASSOCIATE_TIMEOUT seconds -if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then +if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ! ${PING_CMD} $FLOATING_IP; do sleep 1; done"; then echo "Couldn't ping server with floating ip" exit 1 fi @@ -168,7 +171,7 @@ nova secgroup-delete-rule $SECGROUP icmp -1 -1 0.0.0.0/0 # FIXME (anthony): make xs support security groups if [ "$VIRT_DRIVER" != "xenserver" ]; then # test we can aren't able to ping our floating ip within ASSOCIATE_TIMEOUT seconds - if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ping -c1 -w1 $FLOATING_IP; do sleep 1; done"; then + if ! timeout $ASSOCIATE_TIMEOUT sh -c "while ${PING_CMD} $FLOATING_IP; do sleep 1; done"; then print "Security group failure - ping should not be allowed!" echo "Couldn't ping server with floating ip" exit 1 diff --git a/exercises/volumes.sh b/exercises/volumes.sh index 6ea9a516..7fc35c9d 100755 --- a/exercises/volumes.sh +++ b/exercises/volumes.sh @@ -14,6 +14,9 @@ set -o xtrace # Settings # ======== +# Common functions +source ./helpers.sh + # Use openrc + stackrc + localrc for settings pushd $(cd $(dirname "$0")/.. && pwd) source ./openrc @@ -98,7 +101,7 @@ if [ "$MULTI_HOST" = "0" ]; then # sometimes the first ping fails (10 seconds isn't enough time for the VM's # network to respond?), so let's ping for a default of 15 seconds with a # timeout of a second for each ping. - if ! timeout $BOOT_TIMEOUT sh -c "while ! ping -c1 -w1 $IP; do sleep 1; done"; then + if ! timeout $BOOT_TIMEOUT sh -c "while ! ${PING_CMD} $IP; do sleep 1; done"; then echo "Couldn't ping server" exit 1 fi diff --git a/files/dpkgs/general b/files/dpkgs/general index 197d558a..93d8e2f4 100644 --- a/files/dpkgs/general +++ b/files/dpkgs/general @@ -4,3 +4,6 @@ setuptools-26 gcc-3 header-math # The system provided erlang crashes with rabbitmq (it's an old version) +# erlang +qemu + diff --git a/helpers.sh b/helpers.sh new file mode 100644 index 00000000..b2f68348 --- /dev/null +++ b/helpers.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +OS=`uname -o` + +PING_CMD="ping -c1 -w1 " +[[ "${OS}" == "Solaris" ]] && PING_CMD="ping " + diff --git a/illumos.sh b/illumos.sh new file mode 100644 index 00000000..2bdf9f4d --- /dev/null +++ b/illumos.sh @@ -0,0 +1,47 @@ +# One-off config + +# Import the SMF for KVM +sudo svccfg import /opt/stack/nova/smf/kvm.xml +sudo ln -s /opt/stack/nova/smf/kvm-instance-smf /usr/bin + +# Touching this file means "don't use hardware acceleration" - great for VMs / Zones +sudo touch /etc/qemu/disable-kvm + +# We +sudo dladm create-vnic -l rge0 vnic_metadata_0 +sudo ifconfig vnic_metadata_0 plumb +sudo ifconfig vnic_metadata_0 169.254.169.254 +sudo ifconfig vnic_metadata_0 up + +WHO_AM_I=`whoami` + +# How to find these: http://developers.sun.com/developer/technicalArticles/opensolaris/pfexec.html + +# Network Management - for dladm +# ZFS File System Management - to chown the zvol device so we can write to it +# ZFS File System Management - for zfs volumes +# TODO: Better to use zfs delegated administration than ZFS File System Management?? +# http://blogs.oracle.com/marks/entry/zfs_delegated_administration +# NOTE: These overwrite the profiles +#sudo usermod -P'Object Access Management,Network Management,ZFS File System Management' ${WHO_AM_I} + +# I couldn't get the above to work; specifically chmod on the zvol device is failing +sudo usermod -P'Primary Administrator' ${WHO_AM_I} + + +# My main ZFS pool isn't called rpool (!) +export EXTRA_FLAGS="--illumos_zvol_base=rpool1/kvm --setup_nat_for_metadata=false" +export PUBLIC_INTERFACE=rge0 +export HOST_IP=127.0.0.1 + +export FLAT_INTERFACE=${PUBLIC_INTERFACE} + +./stack.sh + + +# USERNAME is set to the USERNAME, which screws up NOVA_USERNAME. Clear it. +USERNAME= +source ./openrc +./exercise.sh + + diff --git a/stack.sh b/stack.sh index 912cbfab..b200370b 100755 --- a/stack.sh +++ b/stack.sh @@ -315,7 +315,8 @@ PUBLIC_INTERFACE=${PUBLIC_INTERFACE:-eth0} FIXED_RANGE=${FIXED_RANGE:-10.0.0.0/24} FIXED_NETWORK_SIZE=${FIXED_NETWORK_SIZE:-256} FLOATING_RANGE=${FLOATING_RANGE:-172.24.4.224/28} -NET_MAN=${NET_MAN:-FlatDHCPManager} +[[ "$OS" != "illumos" ]] && NET_MAN=${NET_MAN:-FlatDHCPManager} +[[ "$OS" == "illumos" ]] && NET_MAN=${NET_MAN:-FlatManager} EC2_DMZ_HOST=${EC2_DMZ_HOST:-$SERVICE_HOST} FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-br100} VLAN_INTERFACE=${VLAN_INTERFACE:-$PUBLIC_INTERFACE} @@ -597,6 +598,7 @@ function illumos_fixes { pip_install routes #==1.12.3 pip_install SQLAlchemy pip_install sqlalchemy-migrate + pip_install Cheetah apt_get_install python-mysql-26 @@ -1013,6 +1015,28 @@ function clean_iptables() { [[ "$OS" == "illumos" ]] && clean_iptables_illumos } +function destroy_old_instances_linux() { + instances=`virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"` + if [ ! $instances = "" ]; then + echo $instances | xargs -n1 virsh destroy || true + echo $instances | xargs -n1 virsh undefine || true + fi +} + +function destroy_old_instances_illumos() { + instances="" + instances=`svcs -H -o fmri svc:/site/kvm` || true + if [[ $instances != "" ]]; then + echo $instances | xargs -n1 svcadm disable -s || true + echo $instances | xargs -n1 svccfg delete || true + fi +} + +function destroy_old_instances() { + [[ "$OS" == "linux" ]] && destroy_old_instances_linux + [[ "$OS" == "illumos" ]] && destroy_old_instances_illumos +} + if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then # Virtualization Configuration @@ -1080,11 +1104,7 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then clean_iptables # Destroy old instances - instances=`virsh list --all | grep $INSTANCE_NAME_PREFIX | sed "s/.*\($INSTANCE_NAME_PREFIX[0-9a-fA-F]*\).*/\1/g"` - if [ ! $instances = "" ]; then - echo $instances | xargs -n1 virsh destroy || true - echo $instances | xargs -n1 virsh undefine || true - fi + destroy_old_instances # Clean out the instances directory. sudo rm -rf $NOVA_DIR/instances/* @@ -1294,10 +1314,15 @@ add_nova_flag "--scheduler_driver=$SCHEDULER" add_nova_flag "--dhcpbridge_flagfile=$NOVA_DIR/bin/nova.conf" add_nova_flag "--fixed_range=$FIXED_RANGE" -# Don't try to start the metadata service on illumos (it requires iptables) -[[ "$OS" = "illumos" ]] && add_nova_flag "--enabled_apis=ec2,osapi_compute,osapi_volume" +if [[ "$OS" == "illumos" ]]; then + # Don't try to start the metadata service on illumos (it requires iptables) + # add_nova_flag "--enabled_apis=ec2,osapi_compute,osapi_volume" + + # Use the illumos stuff + #add_nova_flag "--flat_network_bridge=br100" + add_nova_flag "--connection_type=illumos" +fi - if [[ "$ENABLED_SERVICES" =~ "quantum" ]]; then add_nova_flag "--network_manager=nova.network.quantum.manager.QuantumManager" add_nova_flag "--quantum_connection_host=$Q_HOST" @@ -1336,7 +1361,9 @@ add_nova_flag "--ec2_dmz_host=$EC2_DMZ_HOST" add_nova_flag "--rabbit_host=$RABBIT_HOST" add_nova_flag "--rabbit_password=$RABBIT_PASSWORD" add_nova_flag "--glance_api_servers=$GLANCE_HOSTPORT" -add_nova_flag "--force_dhcp_release" + +[[ "$OS" != "illumos" ]] && add_nova_flag "--force_dhcp_release" + if [ -n "$INSTANCES_PATH" ]; then add_nova_flag "--instances_path=$INSTANCES_PATH" fi @@ -1545,7 +1572,8 @@ fi # ``libvirtd`` to our user in this script, when nova-compute is run it is # within the context of our original shell (so our groups won't be updated). # Use 'sg' to execute nova-compute as a member of the libvirtd group. -screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_DIR/bin/nova-compute" +[[ "$OS" != "illumos" ]] && screen_it n-cpu "cd $NOVA_DIR && sg libvirtd $NOVA_DIR/bin/nova-compute" +[[ "$OS" == "illumos" ]] && screen_it n-cpu "cd $NOVA_DIR && $NOVA_DIR/bin/nova-compute" screen_it n-vol "cd $NOVA_DIR && $NOVA_DIR/bin/nova-volume" screen_it n-net "cd $NOVA_DIR && $NOVA_DIR/bin/nova-network" screen_it n-sch "cd $NOVA_DIR && $NOVA_DIR/bin/nova-scheduler" @@ -1599,6 +1627,7 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then KERNEL="" RAMDISK="" + STREAM_IMAGE="cat" case "$IMAGE_FNAME" in *.tar.gz|*.tgz) # Extract ami and aki files @@ -1625,6 +1654,7 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then *.img.gz) IMAGE="$FILES/${IMAGE_FNAME}" IMAGE_NAME=$(basename "$IMAGE" ".img.gz") + STREAM_IMAGE="zcat" ;; *) echo "Do not know what to do with $IMAGE_FNAME"; false;; esac @@ -1641,7 +1671,7 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then RVAL=`glance add -A $SERVICE_TOKEN name="$IMAGE_NAME-ramdisk" is_public=true container_format=ari disk_format=ari < "$RAMDISK"` RAMDISK_ID=`echo $RVAL | cut -d":" -f2 | tr -d " "` fi - glance add -A $SERVICE_TOKEN name="${IMAGE_NAME%.img}" is_public=true container_format=ami disk_format=ami ${KERNEL_ID:+kernel_id=$KERNEL_ID} ${RAMDISK_ID:+ramdisk_id=$RAMDISK_ID} < <(zcat "${IMAGE}") + glance add -A $SERVICE_TOKEN name="${IMAGE_NAME%.img}" is_public=true container_format=ami disk_format=ami ${KERNEL_ID:+kernel_id=$KERNEL_ID} ${RAMDISK_ID:+ramdisk_id=$RAMDISK_ID} < <(${STREAM_IMAGE} "${IMAGE}") done fi