Merge "RFC: fix(cleanup): neutron"

This commit is contained in:
Zuul 2020-06-30 20:17:36 +00:00 committed by Gerrit Code Review
commit 84b27c895d

View File

@ -822,14 +822,42 @@ conf:
force_project_purge: false force_project_purge: false
run_tempest: false run_tempest: false
clean_up: | clean_up: |
ROUTERS=$(openstack router list -f value | awk '$2 ~ /^[sc]_rally_/ { print $1 }') # NOTE: We will make the best effort to clean up rally generated networks and routers,
if [ -n "$ROUTERS" ]; then # but should not block further automated deployment.
echo $ROUTERS | xargs openstack router delete set +e
fi PATTERN="^[sc]_rally_"
NETWORKS=$(openstack network list -f value | awk '$2 ~ /^[sc]_rally_/ { print $1 }')
if [ -n "$NETWORKS" ]; then ROUTERS=$(openstack router list --format=value -c Name | grep -e $PATTERN | sort | tr -d '\r')
echo $NETWORKS | xargs openstack network delete NETWORKS=$(openstack network list --format=value -c Name | grep -e $PATTERN | sort | tr -d '\r')
fi
for ROUTER in $ROUTERS
do
openstack router unset --external-gateway $ROUTER
openstack router set --disable --no-ha $ROUTER
SUBNS=$(openstack router show $ROUTER -c interfaces_info --format=value | jq .[].subnet_id | tr -d '\r\"')
for SUBN in $SUBNS
do
openstack router remove subnet $ROUTER $SUBN
done
for PORT in $(openstack port list --router $ROUTER --format=value -c ID | tr -d '\r')
do
openstack router remove port $ROUTER $PORT
done
openstack router delete $ROUTER
done
for NETWORK in $NETWORKS
do
for PORT in $(openstack port list --network $NETWORK --format=value -c ID | tr -d '\r')
do
openstack port delete $PORT
done
openstack network delete $NETWORK
done
set -e
tests: tests:
NeutronNetworks.create_and_delete_networks: NeutronNetworks.create_and_delete_networks:
- args: - args: