copr-be: vm-delete + vm-release - fix for yaml data
This commit is contained in:
parent
b4deaaed17
commit
6b9547b3f0
2 changed files with 14 additions and 4 deletions
|
@ -5,11 +5,16 @@ die(){ echo >&2 "!! $*"; exit 1; }
|
||||||
test -z "$RESALLOC_NAME" && die "no vm specified, empty \$RESALLOC_NAME variable"
|
test -z "$RESALLOC_NAME" && die "no vm specified, empty \$RESALLOC_NAME variable"
|
||||||
|
|
||||||
# Try to, best effort, remove the entitlement.
|
# Try to, best effort, remove the entitlement.
|
||||||
set -- $(echo "$RESALLOC_RESOURCE_DATA" | base64 --decode)
|
decoded=$(echo "$RESALLOC_RESOURCE_DATA" | base64 --decode)
|
||||||
|
IP=$(echo "$decoded" | yq .host || :)
|
||||||
|
if test -z "$IP"; then
|
||||||
|
set -- $(echo "$decoded")
|
||||||
|
IP=$1
|
||||||
|
fi
|
||||||
|
|
||||||
# Don't give-up unregistering after the first attempt
|
# Don't give-up unregistering after the first attempt
|
||||||
for _ in a b c; do
|
for _ in a b c; do
|
||||||
timeout 180 ssh root@"$1" "subscription-manager unregister" && break
|
timeout 180 ssh root@"$IP" "subscription-manager unregister" && break
|
||||||
sleep 5
|
sleep 5
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,11 @@ test -n "$RESALLOC_NAME"
|
||||||
test -n "$RESALLOC_RESOURCE_DATA"
|
test -n "$RESALLOC_RESOURCE_DATA"
|
||||||
|
|
||||||
# we only put IP out in spawning script, nothing else
|
# we only put IP out in spawning script, nothing else
|
||||||
set -- $(echo "$RESALLOC_RESOURCE_DATA" | base64 --decode)
|
decoded=$(echo "$RESALLOC_RESOURCE_DATA" | base64 --decode)
|
||||||
IP=$1
|
IP=$(echo "$decoded" | yq .host || :)
|
||||||
|
if test -z "$IP"; then
|
||||||
|
set -- $(echo "$decoded")
|
||||||
|
IP=$1
|
||||||
|
fi
|
||||||
|
|
||||||
ssh -o ConnectTimeout=10 "root@$IP" copr-builder-cleanup
|
ssh -o ConnectTimeout=10 "root@$IP" copr-builder-cleanup
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue