diff --git a/hot/software-config/elements/heat-config/bin/heat-config-notify b/hot/software-config/elements/heat-config/bin/heat-config-notify index 8812507d..711b7c0c 100755 --- a/hot/software-config/elements/heat-config/bin/heat-config-notify +++ b/hot/software-config/elements/heat-config/bin/heat-config-notify @@ -69,10 +69,15 @@ def main(argv=sys.argv, stdin=sys.stdin): if 'deploy_signal_id' in iv: sigurl = iv.get('deploy_signal_id') + sigverb = iv.get('deploy_signal_verb', 'POST') signal_data = json.dumps(signal_data) - log.debug('Signalling to %s' % sigurl) - r = requests.post(sigurl, data=signal_data, - headers={'content-type': None}) + log.debug('Signaling to %s via %s' % (sigurl, sigverb)) + if sigverb == 'PUT': + r = requests.put(sigurl, data=signal_data, + headers={'content-type': None}) + else: + r = requests.post(sigurl, data=signal_data, + headers={'content-type': None}) log.debug('Response %s ' % r) if 'deploy_auth_url' in iv: diff --git a/tests/software_config/test_heat_config_notify.py b/tests/software_config/test_heat_config_notify.py index e046b7e6..5aea988a 100644 --- a/tests/software_config/test_heat_config_notify.py +++ b/tests/software_config/test_heat_config_notify.py @@ -34,6 +34,19 @@ class HeatConfigNotifyTest(common.RunScriptTest): 'config': 'five' } + data_signal_id_put = { + 'id': '5555', + 'group': 'script', + 'inputs': [{ + 'name': 'deploy_signal_id', + 'value': 'mock://192.0.2.3/foo' + }, { + 'name': 'deploy_signal_verb', + 'value': 'PUT' + }], + 'config': 'five' + } + data_heat_signal = { 'id': '5555', 'group': 'script', @@ -107,6 +120,24 @@ class HeatConfigNotifyTest(common.RunScriptTest): data=signal_data, headers={'content-type': None}) + def test_notify_signal_id_put(self): + requests = mock.MagicMock() + hcn.requests = requests + + requests.post.return_value = '[200]' + + signal_data = json.dumps({'foo': 'bar'}) + stdin = cStringIO.StringIO(signal_data) + + with self.write_config_file(self.data_signal_id_put) as config_file: + self.assertEqual( + 0, hcn.main(['heat-config-notify', config_file.name], stdin)) + + requests.put.assert_called_once_with( + 'mock://192.0.2.3/foo', + data=signal_data, + headers={'content-type': None}) + def test_notify_signal_id_empty_data(self): requests = mock.MagicMock() hcn.requests = requests