105 lines
3.5 KiB
Bash
Executable File
105 lines
3.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -ex
|
|
|
|
if [ -z "$INSTACK_ROOT" ]; then
|
|
DEVTEST_VARIABLES=/usr/libexec/openstack-tripleo/devtest_variables.sh
|
|
export RCFILE=/usr/share/instack-undercloud/deploy-virt-overcloudrc
|
|
export ANSWERSFILE=/usr/share/instack-undercloud/instack.answers.sample
|
|
export ELEMENTS_PATH=/usr/share/tripleo-image-elements:/usr/share/diskimage-builder/elements:/usr/share/instack-undercloud
|
|
else
|
|
DEVTEST_VARIABLES=$INSTACK_ROOT/tripleo-incubator/scripts/devtest_variables.sh
|
|
export RCFILE=$INSTACK_ROOT/instack-undercloud/deploy-virt-overcloudrc
|
|
export ANSWERSFILE=$INSTACK_ROOT/instack-undercloud/instack.answers.sample
|
|
export TRIPLEO_ROOT=$INSTACK_ROOT
|
|
|
|
if [ ! -d "$INSTACK_ROOT/diskimage-builder" ]; then
|
|
git clone https://git.openstack.org/openstack/diskimage-builder
|
|
export PATH="$PATH:$INSTACK_ROOT/diskimage-builder/bin/"
|
|
fi
|
|
|
|
if [ ! -d "$INSTACK_ROOT/dib-utils" ]; then
|
|
git clone https://git.openstack.org/openstack/dib-utils
|
|
|
|
pushd $INSTACK_ROOT/dib-utils
|
|
# environment.d sort fix, plus other fixes
|
|
git fetch https://review.openstack.org/openstack/dib-utils refs/changes/12/122412/2 && git cherry-pick FETCH_HEAD || true
|
|
popd
|
|
|
|
export PATH="$PATH:$INSTACK_ROOT/dib-utils/bin/"
|
|
fi
|
|
|
|
if [ ! -d "$INSTACK_ROOT/tripleo-image-elements" ]; then
|
|
git clone https://git.openstack.org/openstack/tripleo-image-elements
|
|
fi
|
|
|
|
export ELEMENTS_PATH=$INSTACK_ROOT/tripleo-image-elements/elements:$INSTACK_ROOT/instack-undercloud/elements
|
|
|
|
fi
|
|
|
|
|
|
# We use $NODE_COUNT here instead of the $NODE_CNT from devtest_variables.sh so
|
|
# that it can still be overrideable *after* sourcing devtest_variables.sh
|
|
export NODE_COUNT=${NODE_COUNT:-4}
|
|
export NODE_CNT=$NODE_COUNT
|
|
|
|
export NODE_DIST=${NODE_DIST:-"fedora"}
|
|
export NODE_ARCH=${NODE_ARCH:-x86_64}
|
|
export NODE_MEM=${NODE_MEM:-4096}
|
|
|
|
source $DEVTEST_VARIABLES
|
|
|
|
export TE_DATAFILE=instackenv.json
|
|
tripleo devtest_testenv.sh $TE_DATAFILE
|
|
|
|
sudo virsh undefine --remove-all-storage seed
|
|
|
|
MACS=$(for i in $(seq 0 3); do echo -n $(tripleo get-vm-mac baremetal_$i)" "; done)
|
|
cp $RCFILE /tmp/deploy-virt-overcloudrc
|
|
sed -i "s/MACS=\"\"/MACS=\"$MACS\"/" /tmp/deploy-virt-overcloudrc
|
|
|
|
export UNDERCLOUD_VM_NAME=${UNDERCLOUD_VM_NAME:-"instack"}
|
|
export UNDERCLOUD_OS=${UNDERCLOUD_OS:-"fedora-20"}
|
|
export UNDERCLOUD_INSTALL=${UNDERCLOUD_INSTALL:-1}
|
|
|
|
if [ "$UNDERCLOUD_INSTALL" = "1" ]; then
|
|
|
|
cp $ANSWERSFILE /tmp/instack.answers
|
|
|
|
disk-image-create \
|
|
--image-size 30 \
|
|
-a amd64 \
|
|
$NODE_DIST instack-vm \
|
|
-o $UNDERCLOUD_VM_NAME
|
|
|
|
sudo cp $UNDERCLOUD_VM_NAME.qcow2 /var/lib/libvirt/images/$UNDERCLOUD_VM_NAME.qcow2
|
|
else
|
|
sudo qemu-img create -f qcow2 /var/lib/libvirt/images/$UNDERCLOUD_VM_NAME.qcow2 30G
|
|
fi
|
|
|
|
tripleo configure-vm \
|
|
--name $UNDERCLOUD_VM_NAME \
|
|
--image /var/lib/libvirt/images/$UNDERCLOUD_VM_NAME.qcow2 \
|
|
--seed \
|
|
--libvirt-nic-driver virtio \
|
|
--arch x86_64 \
|
|
--memory 3145728 \
|
|
--cpus 1
|
|
|
|
virsh start $UNDERCLOUD_VM_NAME
|
|
|
|
timeout_seconds=180
|
|
elapsed_seconds=0
|
|
while true; do
|
|
IP=$(cat /var/lib/libvirt/dnsmasq/default.leases | grep $(tripleo get-vm-mac $UNDERCLOUD_VM_NAME) | awk '{print $3;}')
|
|
if [ -n "$IP" ]; then
|
|
echo "$UNDERCLOUD_VM_NAME vm IP address is $IP"
|
|
break
|
|
fi
|
|
sleep 3
|
|
(( elapsed_seconds += 3 ))
|
|
if [ $elapsed_seconds -ge $timeout_seconds ]; then
|
|
echo "$UNDERCLOUD_VM_NAME never got an IP address from the libvirt default network."
|
|
fi
|
|
done
|