diff options
author | Simon Pasquier <simon.pasquier@bull.net> | 2014-01-03 14:11:54 +0100 |
---|---|---|
committer | Simon Pasquier <simon.pasquier@bull.net> | 2014-02-18 18:14:12 +0100 |
commit | 4ece05a829845ccdbf1e78b030719614255bfc28 (patch) | |
tree | 7f4d3f0bbbf3037fa0cfd14f8f4d9878c4cde8ac /bin | |
parent | a61e2219504101ac487c0266d51422b03a766111 (diff) | |
download | heat-cfntools-4ece05a829845ccdbf1e78b030719614255bfc28.tar.gz |
cfn-signal provides a unique default id
Unless the parameter is provided, cfn-signal will use the instance UUID
from the Nova metadata as the id sent back to the WaitCondition.
In case the Nova metadata isn't available, it will use the hostname as a
fallback.
Change-Id: I1e5847c7babd7c6295d8c3e21f6cfa110a9b3026
Closes-bug: 1223429
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/cfn-signal | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/bin/cfn-signal b/bin/cfn-signal index 9dfbde7..e3d1190 100755 --- a/bin/cfn-signal +++ b/bin/cfn-signal @@ -43,7 +43,7 @@ parser.add_argument('-d', '--data', parser.add_argument('-i', '--id', dest="unique_id", help="the unique id to send back to the WaitCondition", - default='00000', + default=None, required=False) parser.add_argument('-e', '--exit-code', dest="exit_code", @@ -80,10 +80,21 @@ else: if args.success == 'true': status = 'SUCCESS' +unique_id = args.unique_id +if unique_id is None: + LOG.debug('No id passed from the command line') + md = cfn_helper.Metadata('not-used', None) + unique_id = md.get_instance_id() + if unique_id is None: + LOG.error('Could not get the instance id from metadata!') + import socket + unique_id = socket.getfqdn() +LOG.debug('id: %s' % (unique_id)) + body = { "Status": status, "Reason": args.reason, - "UniqueId": args.unique_id, + "UniqueId": unique_id, "Data": args.data } |