destroyAllRunningVM.sh 2.21 KB
Newer Older
Raphael Defosseux's avatar
Raphael Defosseux committed
1
#!/bin/bash
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements.  See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
# * the OAI Public License, Version 1.1  (the "License"); you may not use this file
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# *      http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# *      contact@openairinterface.org
# */
Raphael Defosseux's avatar
Raphael Defosseux committed
22

23 24
function destroy_usage {
    echo "OAI CI VM script"
Raphael Defosseux's avatar
Raphael Defosseux committed
25
    echo "   Original Author: Raphael Defosseux"
26 27
    echo "   Requirements:"
    echo "     -- uvtool uvtool-libvirt apt-cacher"
Raphael Defosseux's avatar
Raphael Defosseux committed
28 29 30
    echo ""
    echo "Usage:"
    echo "------"
31
    echo "    oai-ci-vm-tool destroy [OPTIONS]"
Raphael Defosseux's avatar
Raphael Defosseux committed
32
    echo ""
33
    echo "Mandatory Options:"
Raphael Defosseux's avatar
Raphael Defosseux committed
34 35 36 37 38 39 40
    echo "--------"
    echo "    --job-name #### OR -jn ####"
    echo "    Specify the name of the Jenkins job."
    echo ""
    echo "    --build-id #### OR -id ####"
    echo "    Specify the build ID of the Jenkins job."
    echo ""
41 42
    echo "Options:"
    echo "--------"
Raphael Defosseux's avatar
Raphael Defosseux committed
43 44 45 46 47
    echo "    --help OR -h"
    echo "    Print this help message."
    echo ""
}

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
function destroy_vm {
    echo "############################################################"
    echo "OAI CI VM script"
    echo "############################################################"
    echo "VM_TEMPLATE         = $VM_TEMPLATE"

    LIST_CI_VM=`uvt-kvm list | grep $VM_TEMPLATE`

    for CI_VM in $LIST_CI_VM
    do
        VM_IP_ADDR=`uvt-kvm ip $CI_VM`
        echo "VM to destroy: $CI_VM -- IP $VM_IP_ADDR"
        uvt-kvm destroy $CI_VM
        ssh-keygen -R $VM_IP_ADDR
    done
}