blob: 799a1f4b0f4b508bfe8f3db66f74c17086667128 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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
|