Separate out build_xva process so that it can be run on a machine besides dom0
Change-Id: I3a6e1ef874c83d79d09a8df1f086ec06d39db2df
This commit is contained in:
parent
efa578aabe
commit
af6d47cb3d
@ -54,7 +54,16 @@ Of course, use real passwords if this machine is exposed.
|
|||||||
ACTIVE_TIMEOUT=45
|
ACTIVE_TIMEOUT=45
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
Step 4: Run ./build_domU.sh
|
Step 4: Run ./build_xva.sh
|
||||||
|
--------------------------
|
||||||
|
This script prpares your nova xva image. This script can be run on a separate machine
|
||||||
|
and copied to dom0. If you run this on a different machine, copy the resulting xva
|
||||||
|
file to tools/xen/xvas/[GUEST_NAME].xva (by default tools/xen/xvas/ALLINONE.xva)
|
||||||
|
|
||||||
|
It is likely that for XS6 you will need to build_xva.sh on a separate machine due
|
||||||
|
to dom0 space constraints.
|
||||||
|
|
||||||
|
Step 5: Run ./build_domU.sh
|
||||||
--------------------------
|
--------------------------
|
||||||
This script does a lot of stuff, it is probably best to read it in its entirety.
|
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:
|
But in a nutshell, it performs the following:
|
||||||
@ -63,7 +72,7 @@ But in a nutshell, it performs the following:
|
|||||||
* Creates and installs a OpenStack all-in-one domU in an HA-FlatDHCP configuration
|
* 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!
|
* A script to create a multi-domU (ie. head node separated from compute) configuration is coming soon!
|
||||||
|
|
||||||
Step 5: Do cloudy stuff!
|
Step 6: Do cloudy stuff!
|
||||||
--------------------------
|
--------------------------
|
||||||
* Play with horizon
|
* Play with horizon
|
||||||
* Play with the CLI
|
* Play with the CLI
|
||||||
|
@ -10,42 +10,18 @@ fi
|
|||||||
# This directory
|
# This directory
|
||||||
TOP_DIR=$(cd $(dirname "$0") && pwd)
|
TOP_DIR=$(cd $(dirname "$0") && pwd)
|
||||||
|
|
||||||
# Source params
|
# Source params - override xenrc params in your localrc to suite your taste
|
||||||
cd ../.. && source ./stackrc && cd $TOP_DIR
|
source xenrc
|
||||||
|
|
||||||
# Echo commands
|
# Echo commands
|
||||||
set -o xtrace
|
set -o xtrace
|
||||||
|
|
||||||
# Name of this guest
|
# Check for xva file
|
||||||
GUEST_NAME=${GUEST_NAME:-ALLINONE}
|
if [ ! -e $XVA ]; then
|
||||||
|
echo "Missing xva file. Please run build_xva.sh (ideally on a non dom0 host since the build can require lots of space)."
|
||||||
# dom0 ip
|
echo "Place the resulting xva file in $XVA"
|
||||||
HOST_IP=${HOST_IP:-`ifconfig xenbr0 | grep "inet addr" | cut -d ":" -f2 | sed "s/ .*//"`}
|
exit 1
|
||||||
|
fi
|
||||||
# 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:-xapi1}
|
|
||||||
VM_VLAN=${VM_VLAN:-100}
|
|
||||||
|
|
||||||
# MGMT network params
|
|
||||||
MGT_NETMASK=${MGT_NETMASK:-255.255.255.0}
|
|
||||||
MGT_BR=${MGT_BR:-xapi2}
|
|
||||||
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
|
# Make sure we have git
|
||||||
if ! which git; then
|
if ! which git; then
|
||||||
@ -95,6 +71,9 @@ function create_vlan() {
|
|||||||
create_vlan $PIF $VM_VLAN $VM_NET
|
create_vlan $PIF $VM_VLAN $VM_NET
|
||||||
create_vlan $PIF $MGT_VLAN $MGT_NET
|
create_vlan $PIF $MGT_VLAN $MGT_NET
|
||||||
|
|
||||||
|
# dom0 ip
|
||||||
|
HOST_IP=${HOST_IP:-`ifconfig xenbr0 | grep "inet addr" | cut -d ":" -f2 | sed "s/ .*//"`}
|
||||||
|
|
||||||
# Setup host-only nat rules
|
# Setup host-only nat rules
|
||||||
HOST_NET=169.254.0.0/16
|
HOST_NET=169.254.0.0/16
|
||||||
if ! iptables -L -v -t nat | grep -q $HOST_NET; then
|
if ! iptables -L -v -t nat | grep -q $HOST_NET; then
|
||||||
@ -117,86 +96,9 @@ fi
|
|||||||
# Enable ip forwarding at runtime as well
|
# Enable ip forwarding at runtime as well
|
||||||
echo 1 > /proc/sys/net/ipv4/ip_forward
|
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||||
|
|
||||||
# Directory where we stage the build
|
# Set local storage il8n
|
||||||
STAGING_DIR=$TOP_DIR/stage
|
SR_UUID=`xe sr-list --minimal name-label="Local storage"`
|
||||||
|
xe sr-param-set uuid=$SR_UUID other-config:i18n-key=local-storage
|
||||||
# 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
|
# Clean nova if desired
|
||||||
if [ "$CLEAN" = "1" ]; then
|
if [ "$CLEAN" = "1" ]; then
|
||||||
@ -210,24 +112,12 @@ if [ ! -d $TOP_DIR/nova ]; then
|
|||||||
git checkout $NOVA_BRANCH
|
git checkout $NOVA_BRANCH
|
||||||
fi
|
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
|
# Install plugins
|
||||||
cp -pr $TOP_DIR/nova/plugins/xenserver/xenapi/etc/xapi.d /etc/
|
cp -pr $TOP_DIR/nova/plugins/xenserver/xenapi/etc/xapi.d /etc/
|
||||||
chmod a+x /etc/xapi.d/plugins/*
|
chmod a+x /etc/xapi.d/plugins/*
|
||||||
yum --enablerepo=base install -y parted
|
yum --enablerepo=base install -y parted
|
||||||
mkdir -p /boot/guest
|
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
|
# Shutdown previous runs
|
||||||
DO_SHUTDOWN=${DO_SHUTDOWN:-1}
|
DO_SHUTDOWN=${DO_SHUTDOWN:-1}
|
||||||
if [ "$DO_SHUTDOWN" = "1" ]; then
|
if [ "$DO_SHUTDOWN" = "1" ]; then
|
||||||
@ -248,68 +138,6 @@ if [ "$DO_SHUTDOWN" = "1" ]; then
|
|||||||
done
|
done
|
||||||
fi
|
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
|
# Start guest
|
||||||
$TOP_DIR/scripts/install-os-vpx.sh -f $XVA -v $VM_BR -m $MGT_BR -p $PUB_BR
|
$TOP_DIR/scripts/install-os-vpx.sh -f $XVA -v $VM_BR -m $MGT_BR -p $PUB_BR
|
||||||
|
|
||||||
|
164
tools/xen/build_xva.sh
Executable file
164
tools/xen/build_xva.sh
Executable file
@ -0,0 +1,164 @@
|
|||||||
|
#!/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 - override xenrc params in your localrc to suite your taste
|
||||||
|
source xenrc
|
||||||
|
|
||||||
|
# Echo commands
|
||||||
|
set -o xtrace
|
||||||
|
|
||||||
|
# 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-//"`
|
||||||
|
|
||||||
|
# Directory for xvas
|
||||||
|
XVA_DIR=$TOP_DIR/xvas
|
||||||
|
|
||||||
|
# Create xva dir
|
||||||
|
mkdir -p $XVA_DIR
|
||||||
|
|
||||||
|
# Path to xva
|
||||||
|
XVA=$XVA_DIR/$GUEST_NAME.xva
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
echo "Built $XVA. If your dom0 is on a different machine, copy this to [devstackdir]/tools/xen/$XVA"
|
38
tools/xen/xenrc
Normal file
38
tools/xen/xenrc
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Name of this guest
|
||||||
|
GUEST_NAME=${GUEST_NAME:-ALLINONE}
|
||||||
|
|
||||||
|
# Size of image
|
||||||
|
VDI_MB=${VDI_MB:-2500}
|
||||||
|
|
||||||
|
# VM Password
|
||||||
|
GUEST_PASSWORD=${GUEST_PASSWORD:-secrete}
|
||||||
|
|
||||||
|
# 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:-xapi1}
|
||||||
|
VM_VLAN=${VM_VLAN:-100}
|
||||||
|
|
||||||
|
# MGMT network params
|
||||||
|
MGT_NETMASK=${MGT_NETMASK:-255.255.255.0}
|
||||||
|
MGT_BR=${MGT_BR:-xapi2}
|
||||||
|
MGT_VLAN=${MGT_VLAN:-101}
|
||||||
|
|
||||||
|
# XVA Directory
|
||||||
|
XVA_DIR=${XVA_DIR:-xvas}
|
||||||
|
|
||||||
|
# Path to xva file
|
||||||
|
XVA=${XVA:-$XVA_DIR/$GUEST_NAME.xva }
|
||||||
|
|
||||||
|
# Source params
|
||||||
|
cd ../.. && source ./stackrc && cd $TOP_DIR
|
Loading…
Reference in New Issue
Block a user