X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Fodl-openstack-cleanup-orphaned-nodes.sh;h=1b7f0c68e47389c6ab0d7cd2f2d63f12bf48b0f2;hb=4dd0f93bdcc602f444719a3b5c95a5447866af85;hp=953dadc81cded07e11715ce8beb1f77d54e9fa56;hpb=7d16ac5800cc99d4b31f8a4a8070be9c6407e167;p=releng%2Fbuilder.git diff --git a/jjb/odl-openstack-cleanup-orphaned-nodes.sh b/jjb/odl-openstack-cleanup-orphaned-nodes.sh index 953dadc81..1b7f0c68e 100644 --- a/jjb/odl-openstack-cleanup-orphaned-nodes.sh +++ b/jjb/odl-openstack-cleanup-orphaned-nodes.sh @@ -10,9 +10,6 @@ ############################################################################## echo "---> Cleanup orphaned servers" -# shellcheck source=/tmp/v/openstack/bin/activate disable=SC1091 -source "/tmp/v/openstack/bin/activate" - minion_in_jenkins() { # Usage: check_stack_in_jenkins STACK_NAME JENKINS_URL [JENKINS_URL...] # Returns: 0 If stack is in Jenkins and 1 if stack is not in Jenkins. @@ -46,13 +43,22 @@ minion_in_jenkins() { # Fetch server list before fetching active minions to minimize race condition # where we might be trying to delete servers while jobs are trying to start +# shellcheck source=/tmp/v/openstack/bin/activate disable=SC1091 +source "/tmp/v/openstack/bin/activate" + # We purposely need word splitting here to create the OS_SERVERS array. # shellcheck disable=SC2207 -OS_SERVERS=($(openstack server list -f value -c "Name" | grep -E 'prd|snd')) +mapfile -t OS_SERVERS < <(openstack server list -f value -c "Name" | grep -E 'prd|snd') + +deactivate ############################# ## DELETE ORPHANED SERVERS ## ############################# + +# shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091 +source "/tmp/v/lftools/bin/activate" + # Search for servers that are not in use by either releng or sandbox silos and # delete them. for server in "${OS_SERVERS[@]}"; do @@ -64,6 +70,9 @@ for server in "${OS_SERVERS[@]}"; do continue else echo "Deleting $server" - openstack server delete "$server" + lftools openstack --os-cloud vex \ + server remove --minutes 15 "$server" fi done + +deactivate