X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=jjb%2Fodl-openstack-cleanup-orphaned-nodes.sh;h=df598b473d83eba76ae30b3803f28df1afadfe3d;hb=6181ae15d4dc986b88a03d1d39fce38f3101bc7a;hp=953dadc81cded07e11715ce8beb1f77d54e9fa56;hpb=580538afd2795b61a826ccd08195628c729d63cb;p=releng%2Fbuilder.git diff --git a/jjb/odl-openstack-cleanup-orphaned-nodes.sh b/jjb/odl-openstack-cleanup-orphaned-nodes.sh index 953dadc81..df598b473 100644 --- a/jjb/odl-openstack-cleanup-orphaned-nodes.sh +++ b/jjb/odl-openstack-cleanup-orphaned-nodes.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -l # SPDX-License-Identifier: EPL-1.0 ############################################################################## # Copyright (c) 2017 - 2018 The Linux Foundation and others. @@ -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. @@ -48,11 +45,12 @@ minion_in_jenkins() { # 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') ############################# ## DELETE ORPHANED SERVERS ## ############################# + # 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 +62,7 @@ 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