fe70aa5b32
Conflicts: scripts/instack-build-images
75 lines
2.7 KiB
Bash
Executable File
75 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -ex
|
|
|
|
if [ -z "$INSTACK_ROOT" ]; then
|
|
DEVTEST_VARIABLES=/usr/libexec/openstack-tripleo/devtest_variables.sh
|
|
RCFILE=/usr/share/doc/instack-undercloud/deploy-virt-overcloudrc
|
|
ANSWERSFILE=/usr/share/doc/instack-undercloud/instack-virt.answers.sample
|
|
else
|
|
DEVTEST_VARIABLES=$INSTACK_ROOT/tripleo-incubator/scripts/devtest_variables.sh
|
|
RCFILE=$INSTACK_ROOT/instack-undercloud/deploy-virt-overcloudrc
|
|
ANSWERSFILE=$INSTACK_ROOT/instack-undercloud/instack-virt.answers.sample
|
|
export TRIPLEO_ROOT=$INSTACK_ROOT
|
|
export NODE_CNT=4
|
|
export NODE_MEM=3072
|
|
fi
|
|
|
|
source $DEVTEST_VARIABLES
|
|
|
|
export NODE_ARCH=${NODE_ARCH:-amd64}
|
|
export NODE_MEM=${NODE_MEM:-3072}
|
|
|
|
tripleo devtest_testenv.sh instackenv.json
|
|
|
|
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
|
|
|
|
UNDERCLOUD_ROOT_PASSWORD=${UNDERCLOUD_ROOT_PASSWORD:-""}
|
|
UNDERCLOUD_PASSWORD_ARG=
|
|
if [ $UNDERCLOUD_ROOT_PASSWORD ]; then
|
|
UNDERCLOUD_PASSWORD_ARG="--root-password password:$UNDERCLOUD_ROOT_PASSWORD"
|
|
fi
|
|
|
|
export UNDERCLOUD_VM_NAME=${UNDERCLOUD_VM_NAME:-"instack"}
|
|
export UNDERCLOUD_OS=${UNDERCLOUD_OS:-"fedora-20"}
|
|
|
|
# We must restore the default label for /etc/resolv.conf, hence the
|
|
# --firstboot-command that calls restorecon /etc/resolv.conf, see:
|
|
# https://bugzilla.redhat.com/show_bug.cgi?id=1089100
|
|
virt-builder $UNDERCLOUD_OS $UNDERCLOUD_PASSWORD_ARG \
|
|
--size 30G \
|
|
--format qcow2 \
|
|
-o $UNDERCLOUD_VM_NAME.qcow2 \
|
|
--install net-tools,yum-utils,git \
|
|
--mkdir /home/stack/.ssh \
|
|
--upload ~/.ssh/id_rsa_virt_power:/home/stack/.ssh/id_rsa_virt_power \
|
|
--upload ~/.ssh/id_rsa_virt_power.pub:/home/stack/.ssh/id_rsa_virt_power.pub \
|
|
--upload /tmp/deploy-virt-overcloudrc:/home/stack/deploy-overcloudrc \
|
|
--upload $ANSWERSFILE:/home/stack/instack.answers \
|
|
--run-command \
|
|
'useradd -m -G wheel -p "" stack ; echo "stack:stack" | chpasswd;
|
|
echo "stack ALL=(root) NOPASSWD:ALL" >> /etc/sudoers.d/stack ; chmod 0440 /etc/sudoers.d/stack;
|
|
chmod 0755 /home/stack;
|
|
chmod 0700 /home/stack/.ssh;
|
|
chmod 0600 /home/stack/.ssh/id_rsa_virt_power /home/stack/.ssh/id_rsa_virt_power.pub;
|
|
cp /etc/skel/.* /home/stack/;
|
|
chown -R stack:stack /home/stack' \
|
|
--firstboot-command \
|
|
'restorecon /etc/resolv.conf' \
|
|
--selinux-relabel
|
|
|
|
sudo cp $UNDERCLOUD_VM_NAME.qcow2 /var/lib/libvirt/images/$UNDERCLOUD_VM_NAME.qcow2
|
|
|
|
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
|