43 lines
1.3 KiB
Bash
Executable File
43 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
set -xe
|
|
|
|
ENVNUM=${1:-$(date +%s)}
|
|
PROVISIONNET=provision-${ENVNUM}
|
|
PUBLICNET=public-${ENVNUM}
|
|
ENVFILE=env-${ENVNUM}.yaml
|
|
|
|
rm -f /opt/stack/openstack-virtual-baremetal/$ENVFILE
|
|
rm -f /opt/stack/openstack-virtual-baremetal/temp-key-$ENVNUM.pub
|
|
|
|
source /etc/nodepoolrc
|
|
|
|
function delete_ports() {
|
|
local subnetid=$1
|
|
for PORT in $(neutron port-list | grep $subnetid | awk '{print $2}') ; do
|
|
neutron port-delete $PORT
|
|
done
|
|
}
|
|
|
|
# Delete the ports that have been attached to the undercloud
|
|
SUBNETID=$(neutron subnet-show $PUBLICNET | awk '$2=="id" {print $4}')
|
|
delete_ports $SUBNETID
|
|
SUBNETID=$(neutron subnet-show $PROVISIONNET | awk '$2=="id" {print $4}')
|
|
delete_ports $SUBNETID
|
|
|
|
# If there was a keypair for this specific run, delete it.
|
|
openstack keypair delete "tripleo-ci-key-$ENVNUM" || true
|
|
|
|
# NOTE(bnemec): I'm periodically seeing the stack-delete fail to connect to
|
|
# Heat. It looks like a transient network issue, so let's just retry when it happens.
|
|
for i in $(seq 10); do
|
|
heat stack-delete -y baremetal_${ENVNUM} && break
|
|
sleep 5
|
|
done
|
|
while heat stack-show baremetal_${ENVNUM} 2>&1 > /dev/null ; do
|
|
# If the delete failed, try again
|
|
if heat stack-show baremetal_${ENVNUM} | grep DELETE_FAILED ; then
|
|
heat stack-delete -y baremetal_${ENVNUM} || true
|
|
fi
|
|
sleep 20
|
|
done
|