Add support for "signals" to os-refresh-config

The new software config / deployments resources use signals.

A subtle difference between wait condition handles and signals in Heat
is that signals use POST, but wait conditions use PUT. This has
historical reasons that mostly are due to Amazon compatibility. We need
to continue to support both until we can eliminate all use of wait
conditions.

Change-Id: I69d9103b07100f700fb71a2cbbf267042625e7a7
This commit is contained in:
Clint Byrum 2014-03-27 16:00:33 -07:00
parent 8dada7907d
commit b277adeddf
1 changed files with 10 additions and 2 deletions

View File

@ -2,9 +2,17 @@
set -eux
HANDLE=$(os-apply-config --key completion-handle --type raw --key-default "")
SIGNAL=$(os-apply-config --key completion-signal --type raw --key-default "")
ID=$(os-apply-config --key instance-id --type raw --key-default "")
[ -n "$HANDLE" ] || exit 0
[ -n "$ID" ] || exit 0
curl -X PUT -H 'Content-Type:' --data-binary "{\"Status\" : \"SUCCESS\",\"Reason\" : \"Configuration Complete\",\"UniqueId\" : \"$ID\",\"Data\" : \"Finished os-refresh-config.\"}" "$(os-apply-config --key completion-handle --type raw)"
call_curl() {
local method=$1
local url=$2
curl -X $method -H 'Content-Type:' --data-binary "{\"Status\" : \"SUCCESS\",\"Reason\" : \"Configuration Complete\",\"UniqueId\" : \"$ID\",\"Data\" : \"Finished os-refresh-config.\"}" $url
}
# Signals use POST, wait handles use PUT
[ -n "$HANDLE" ] && call_curl PUT $HANDLE
[ -n "$SIGNAL" ] && call_curl POST $SIGNAL