diff options
Diffstat (limited to 'controller/bin')
-rw-r--r-- | controller/bin/dtf-get-machine.in | 1 | ||||
-rw-r--r-- | controller/bin/dtf-return-machine.in | 45 |
2 files changed, 46 insertions, 0 deletions
diff --git a/controller/bin/dtf-get-machine.in b/controller/bin/dtf-get-machine.in index 54a3253..0c51f11 100644 --- a/controller/bin/dtf-get-machine.in +++ b/controller/bin/dtf-get-machine.in @@ -26,6 +26,7 @@ Options: --distro-version=VERSION E.g. 20 for Fedora 20 --openstack-instance=ID --name=NAME Name of the machine + --quite Print only the VM IP address to stdout EOHELP test -n "$1" && exit "$1" } diff --git a/controller/bin/dtf-return-machine.in b/controller/bin/dtf-return-machine.in new file mode 100644 index 0000000..799a1f4 --- /dev/null +++ b/controller/bin/dtf-return-machine.in @@ -0,0 +1,45 @@ +#!/bin/bash + +. "@sysconfdir@/dtf.sh" || exit 1 +opt_openstack_instance="$DTF_OPENSTACK_DEFAULT_ID" + +die() { echo "$@" ; exit 1 ; } + +longopts="openstack-instance:" +ARGS=$(getopt -o "" -l "help,$longopts" -n "$0" -- "$@") \ + || exit 1 +eval set -- "$ARGS" +while true; do + case "$1" in + --openstack-instance) + opt=$(sed -e 's/^--//' -e 's/[^[a-zA-Z0-9]/_/g'<<<"$1") + eval "opt_$opt=\"${2,,}\"" + shift 2 + ;; + --) + shift + break; + ;; + *) + echo >&2 "programmer mistake" + exit 1 + ;; + esac +done + +test -z "$opt_openstack_instance" && die "no openstack intance ID used" +. "@pkgdatadir@/parse_credsfile" "$opt_openstack_instance" || exit 1 + +IP="$1" + +test -z "$IP" && die "no IP passed" + +NOVACMD="@libexecdir@/dtf-nova" + +$NOVACMD list --fields 'networks' | \ + while IFS=" " read id networks; do + if [[ "$networks" == *$IP* ]]; then + nova delete "$id" + exit $? + fi + done |