3f95743809
Uses the new location of openstack-virtual-baremetal as it was imported to openstack organization earlier today. Change-Id: I409c0cd172bbec4c19089b6ebe3fd7200ba2fa75
127 lines
5.5 KiB
Bash
Executable File
127 lines
5.5 KiB
Bash
Executable File
#!/bin/bash
|
|
set -ex
|
|
|
|
ENVNUM=${1:-$(date +%s)}
|
|
NODECOUNT=${2:-2}
|
|
UCINSTANCE=${3:-}
|
|
CREATE_UNDERCLOUD=${4:-""}
|
|
SSH_KEY=${5:-""}
|
|
# We recognize 3 values for NETISO: none, multi-nic, public-bond
|
|
NETISO=${6:-'multi-nic'}
|
|
COMPUTE_NODECOUNT=${7:-0}
|
|
EXTRA_NODECOUNT=${8:-0}
|
|
PROVISIONNET=provision-${ENVNUM}
|
|
PUBLICNET=public-${ENVNUM}
|
|
ENVFILE=env-${ENVNUM}-base.yaml
|
|
COMPUTE_ENVFILE=env-${ENVNUM}-compute.yaml
|
|
EXTRA_ENVFILE=env-${ENVNUM}-extra.yaml
|
|
ROLE_ARGS=
|
|
|
|
set +x
|
|
source /etc/nodepoolrc
|
|
set -x
|
|
|
|
if [ ! -e /opt/stack/openstack-virtual-baremetal ] ; then
|
|
sudo git clone https://git.openstack.org/openstack/openstack-virtual-baremetal.git /opt/stack/openstack-virtual-baremetal
|
|
sudo chown -R $USER /opt/stack/openstack-virtual-baremetal
|
|
fi
|
|
|
|
cd /opt/stack/openstack-virtual-baremetal/
|
|
|
|
if [ -n "$SSH_KEY" ]; then
|
|
echo "$SSH_KEY" > temp-key-$ENVNUM.pub
|
|
KEY_NAME="tripleo-ci-key-$ENVNUM"
|
|
openstack keypair create --public-key temp-key-$ENVNUM.pub $KEY_NAME
|
|
else
|
|
KEY_NAME="tripleo-cd-admins"
|
|
fi
|
|
|
|
BUILD_NODES_JSON_EXTRA_ARGS=""
|
|
|
|
/bin/cp --remove-destination environments/base.yaml $ENVFILE
|
|
sed -i -e "s/bmc_image:.*/bmc_image: bmc-template/" $ENVFILE
|
|
sed -i -e "s/key_name:.*/key_name: ${KEY_NAME}/" $ENVFILE
|
|
sed -i -e "s/node_count:.*/node_count: ${NODECOUNT}/" $ENVFILE
|
|
sed -i -e "s/provision_net_shared:.*/provision_net_shared: true/" $ENVFILE
|
|
sed -i -e "s/public_net_shared:.*/public_net_shared: true/" $ENVFILE
|
|
if [[ $NODEPOOL_PROVIDER == "rdo-cloud-tripleo" ]] || [[ $NODEPOOL_PROVIDER == "vexxhost-rdo-ca-ymq-1" ]]; then
|
|
sed -i -e "s/provision_net_shared:.*/provision_net_shared: false/" $ENVFILE
|
|
sed -i -e "s/public_net_shared:.*/public_net_shared: false/" $ENVFILE
|
|
sed -i -e "s/bmc_flavor:.*/bmc_flavor: ${BMC_FLAVOR}/" $ENVFILE
|
|
sed -i -e "s/baremetal_flavor:.*/baremetal_flavor: ${BAREMETAL_FLAVOR}/" $ENVFILE
|
|
fi
|
|
if [ -n "$CREATE_UNDERCLOUD" ]; then
|
|
sed -i -e "s/undercloud_name:.*/undercloud_name: extra-node/" $ENVFILE
|
|
sed -i -e "s/undercloud_flavor:.*/undercloud_flavor: ${UNDERCLOUD_FLAVOR}/" $ENVFILE
|
|
BUILD_NODES_JSON_EXTRA_ARGS="--add_undercloud"
|
|
fi
|
|
ENVIRONMENT_ARGS="-e $ENVFILE -e environments/bmc-use-cache.yaml -e environments/undercloud-floating-none.yaml"
|
|
|
|
if [ $COMPUTE_NODECOUNT -gt 0 ]; then
|
|
sed -i -e "s/role:.*/role: control/" $ENVFILE
|
|
fi
|
|
|
|
if [ -z "$CREATE_UNDERCLOUD" ]; then
|
|
ENVIRONMENT_ARGS="$ENVIRONMENT_ARGS -e environments/quintupleo-no-undercloud.yaml"
|
|
fi
|
|
|
|
if [ $NETISO == 'multi-nic' ]; then
|
|
ENVIRONMENT_ARGS="$ENVIRONMENT_ARGS -e environments/all-networks-port-security.yaml"
|
|
elif [ $NETISO == 'public-bond' ]; then
|
|
ENVIRONMENT_ARGS="$ENVIRONMENT_ARGS -e environments/all-networks-public-bond-port-security.yaml"
|
|
else
|
|
ENVIRONMENT_ARGS="$ENVIRONMENT_ARGS -e environments/port-security.yaml"
|
|
fi
|
|
|
|
if [ $COMPUTE_NODECOUNT -gt 0 ]; then
|
|
/bin/cp --remove-destination environments/base-role.yaml $COMPUTE_ENVFILE
|
|
sed -i -e "s/baremetal_flavor:.*/baremetal_flavor: baremetal-compute/" $COMPUTE_ENVFILE
|
|
sed -i -e "s/key_name:.*/key_name: ${KEY_NAME}/" $COMPUTE_ENVFILE
|
|
sed -i -e "s/node_count:.*/node_count: ${COMPUTE_NODECOUNT}/" $COMPUTE_ENVFILE
|
|
# This is already the default in the template, but just to be safe.
|
|
sed -i -e "s/role:.*/role: compute/" $COMPUTE_ENVFILE
|
|
ROLE_ARGS="--role $COMPUTE_ENVFILE"
|
|
fi
|
|
|
|
if [ $EXTRA_NODECOUNT -gt 0 ]; then
|
|
EXTRA_NODE_KEY_NAME="extra_node_key"
|
|
/bin/cp --remove-destination environments/base-extra-node.yaml $EXTRA_ENVFILE
|
|
sed -i -e "s/baremetal_flavor:.*/baremetal_flavor: ${EXTRA_NODE_FLAVOR}/" $EXTRA_ENVFILE
|
|
sed -i -e "s/key_name:.*/key_name: ${EXTRA_NODE_KEY_NAME}/" $EXTRA_ENVFILE
|
|
sed -i -e "s/node_count:.*/node_count: ${EXTRA_NODECOUNT}/" $EXTRA_ENVFILE
|
|
sed -i -e "s/baremetal_image:.*/baremetal_image: ${BAREMETAL_IMAGE}/" $EXTRA_ENVFILE
|
|
# We changed the path of the environment, so we need to fix the relative
|
|
# path in the resource registry too.
|
|
sed -i -e "s|../templates/baremetal-ports-extra-node-port-security.yaml|templates/baremetal-ports-extra-node-port-security.yaml|" $EXTRA_ENVFILE
|
|
ROLE_ARGS="--role $EXTRA_ENVFILE"
|
|
BUILD_NODES_JSON_EXTRA_ARGS="$BUILD_NODES_JSON_EXTRA_ARGS --network_details"
|
|
fi
|
|
|
|
/opt/stack/openstack-virtual-baremetal/bin/deploy.py --name baremetal_${ENVNUM} --quintupleo --id ${ENVNUM} $ENVIRONMENT_ARGS $ROLE_ARGS
|
|
|
|
while ! heat stack-show baremetal_${ENVNUM} | grep CREATE_COMPLETE ; do
|
|
sleep 10
|
|
if heat stack-show baremetal_${ENVNUM} | grep CREATE_FAILED ; then
|
|
echo "Failed creating OVB stack" > $TE_DATAFILE
|
|
heat stack-show baremetal_${ENVNUM} >> $TE_DATAFILE 2>&1
|
|
openstack stack failures list --long baremetal_${ENVNUM} >> $TE_DATAFILE 2>&1 || echo 'Failed to list stack failures' >> $TE_DATAFILE
|
|
exit 0
|
|
fi
|
|
done
|
|
|
|
undercloud_networks="$PROVISIONNET"
|
|
nova interface-attach --net-id $(neutron net-show -F id -f value $PROVISIONNET) $UCINSTANCE
|
|
if [ $NETISO != 'none' ]; then
|
|
nova interface-attach --net-id $(neutron net-show -F id -f value $PUBLICNET) $UCINSTANCE
|
|
undercloud_networks="$undercloud_networks $PUBLICNET"
|
|
fi
|
|
|
|
for PORT_SECURITY_NET in $undercloud_networks; do
|
|
neutron port-update $(openstack port list --network $PORT_SECURITY_NET --server $UCINSTANCE -f value -c ID) \
|
|
--no-security-groups --port-security-enabled=False
|
|
done
|
|
|
|
# This writes out the env file as env-ID.yaml while overwrites the one we have created
|
|
/opt/stack/openstack-virtual-baremetal/bin/build-nodes-json --env env-${ENVNUM}.yaml --network_details \
|
|
--nodes_json ${TE_DATAFILE:-~/instackenv.json} $BUILD_NODES_JSON_EXTRA_ARGS
|