Use physical_resource_name to generate the resource ID

The SwiftSignalHandle URL can be too long for the database column,
resulting in an unhandled exception and failed stack.

Use the SwiftSignalHandle's physical_resource_name() method to generate
the resource ID and use FnGetRefId to fetch the handle URL instead.

Change-Id: Iee5fc684b1f2f64ed543022a9e51612c1f80bb1e
Closes-Bug: #1398927
This commit is contained in:
Jason Dunsmore 2014-12-03 12:33:10 -06:00
parent 8b8d8db3d6
commit 837a093a24
2 changed files with 11 additions and 6 deletions

View File

@ -91,8 +91,8 @@ class SwiftSignalHandle(resource.Resource):
cplugin = self.client_plugin()
url = cplugin.get_signal_url(self.stack.id,
self.physical_resource_name())
self.data_set('endpoint', url)
self.resource_id_set(url)
self.data_set(self.ENDPOINT, url)
self.resource_id_set(self.physical_resource_name())
def update(self, after, before=None, prev_resource=None):
raise resource.UpdateReplace(self.name)
@ -102,9 +102,10 @@ class SwiftSignalHandle(resource.Resource):
if key == self.TOKEN:
return '' # HeatWaitConditionHandle compatibility
elif key == self.ENDPOINT:
return self.data().get('endpoint')
return self.data().get(self.ENDPOINT)
elif key == self.CURL_CLI:
return ('curl -i -X PUT \'%s\'' % self.data().get('endpoint'))
return ('curl -i -X PUT \'%s\'' %
self.data().get(self.ENDPOINT))
def handle_delete(self):
cplugin = self.client_plugin()
@ -128,7 +129,10 @@ class SwiftSignalHandle(resource.Resource):
else:
raise
self.data_delete('endpoint')
self.data_delete(self.ENDPOINT)
def FnGetRefId(self):
return self.data().get(self.ENDPOINT)
class SwiftSignal(resource.Resource):

View File

@ -143,7 +143,8 @@ class SwiftSignalHandleTest(common.HeatTestCase):
"\?temp_url_sig=[0-9a-f]{40}&temp_url_expires=[0-9]{10}"
% st.id)
res_id = st.resources['test_wait_condition_handle'].resource_id
self.assertThat(res_id, matchers.MatchesRegex(regexp))
self.assertEqual(res_id, handle.physical_resource_name())
self.assertThat(handle.FnGetRefId(), matchers.MatchesRegex(regexp))
# Since the account key is mocked out above
self.assertFalse(mock_swift_object.post_account.called)