From: Steven Hardy Date: Tue, 29 Jan 2013 18:20:04 +0000 (+0000) Subject: heat engine : WaitConditionHandle use creation time for timestamp X-Git-Tag: 2014.1~948 X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=01a0fa8991d35ead1dc59580e07c0059cb07fd66;p=openstack-build%2Fheat-build.git heat engine : WaitConditionHandle use creation time for timestamp Use the resource creation time for the pre-signed URL timestamp, otherwise you get a different timestamp/signature every time you refer to the resource, which makes things like comparing templates for update more difficult. Change-Id: Ieb4a6269cfcaf1214c08442db03772fdd7570d59 Signed-off-by: Steven Hardy --- diff --git a/heat/engine/resources/wait_condition.py b/heat/engine/resources/wait_condition.py index a88b08c0..373ea1e9 100644 --- a/heat/engine/resources/wait_condition.py +++ b/heat/engine/resources/wait_condition.py @@ -72,8 +72,9 @@ class WaitConditionHandle(resource.Resource): 'params': {'SignatureMethod': 'HmacSHA256', 'SignatureVersion': '2', 'AWSAccessKeyId': credentials.access, - 'Timestamp': time.strftime("%Y-%m-%dT%H:%M:%SZ", - time.gmtime())}} + 'Timestamp': + self.created_time.strftime("%Y-%m-%dT%H:%M:%SZ") + }} # Sign the request signer = Ec2Signer(credentials.secret) request['params']['Signature'] = signer.generate(request) diff --git a/heat/tests/test_waitcondition.py b/heat/tests/test_waitcondition.py index 36fdc080..1a4ea000 100644 --- a/heat/tests/test_waitcondition.py +++ b/heat/tests/test_waitcondition.py @@ -16,6 +16,7 @@ import mox import uuid import time +import datetime import eventlet import unittest @@ -299,13 +300,10 @@ class WaitConditionHandleTest(unittest.TestCase): return stack def test_handle(self): - # Stub time to a fixed value so we can get an expected signature - t = time.gmtime(1354196977) - self.m.StubOutWithMock(time, 'gmtime') - time.gmtime().MultipleTimes().AndReturn(t) - self.m.ReplayAll() + created_time = datetime.datetime(2012, 11, 29, 13, 49, 37) resource = self.stack.resources['WaitHandle'] + resource.created_time = created_time self.assertEqual(resource.state, 'CREATE_COMPLETE') expected_url = "".join([