Convergence: input_data physical_resource_id -> reference_id

1. we are caching the result of FnGetRefId which can be the name
2. cache_data_resource_attribute() was trying to access "attributes"
   instead of "attrs".

Change-Id: I59d55dcee2af521924fdb5da14e012dcc7b4dd3f
This commit is contained in:
Angus Salkeld 2015-08-18 11:43:49 +10:00
parent 8746d9e1dc
commit 881e4d051a
5 changed files with 13 additions and 13 deletions

View File

@ -1428,7 +1428,7 @@ class Resource(object):
:results: the id or name of the resource. :results: the id or name of the resource.
''' '''
if self.stack.has_cache_data(self.name): if self.stack.has_cache_data(self.name):
return self.stack.cache_data_resource_id(self.name) return self.stack.cache_data_reference_id(self.name)
if self.resource_id is not None: if self.resource_id is not None:
return six.text_type(self.resource_id) return six.text_type(self.resource_id)

View File

@ -1611,13 +1611,13 @@ class Stack(collections.Mapping):
return (self.cache_data is not None and return (self.cache_data is not None and
self.cache_data.get(resource_name) is not None) self.cache_data.get(resource_name) is not None)
def cache_data_resource_id(self, resource_name): def cache_data_reference_id(self, resource_name):
return self.cache_data.get( return self.cache_data.get(
resource_name, {}).get('physical_resource_id') resource_name, {}).get('reference_id')
def cache_data_resource_attribute(self, resource_name, attribute_key): def cache_data_resource_attribute(self, resource_name, attribute_key):
return self.cache_data.get( return self.cache_data.get(
resource_name, {}).get('attributes', {}).get(attribute_key) resource_name, {}).get('attrs', {}).get(attribute_key)
def mark_complete(self, traversal_id): def mark_complete(self, traversal_id):
''' '''

View File

@ -321,7 +321,7 @@ def construct_input_data(rsrc):
input_data = {'id': rsrc.id, input_data = {'id': rsrc.id,
'name': rsrc.name, 'name': rsrc.name,
'physical_resource_id': rsrc.resource_id, 'reference_id': rsrc.FnGetRefId(),
'attrs': resolved_attributes} 'attrs': resolved_attributes}
return input_data return input_data

View File

@ -527,7 +527,7 @@ class MiscMethodsTest(common.HeatTestCase):
def test_construct_input_data_ok(self): def test_construct_input_data_ok(self):
expected_input_data = {'attrs': {'value': None}, expected_input_data = {'attrs': {'value': None},
'id': mock.ANY, 'id': mock.ANY,
'physical_resource_id': None, 'reference_id': 'A',
'name': 'A'} 'name': 'A'}
actual_input_data = worker.construct_input_data(self.resource) actual_input_data = worker.construct_input_data(self.resource)
self.assertEqual(expected_input_data, actual_input_data) self.assertEqual(expected_input_data, actual_input_data)
@ -535,7 +535,7 @@ class MiscMethodsTest(common.HeatTestCase):
def test_construct_input_data_exception(self): def test_construct_input_data_exception(self):
expected_input_data = {'attrs': {}, expected_input_data = {'attrs': {},
'id': mock.ANY, 'id': mock.ANY,
'physical_resource_id': None, 'reference_id': 'A',
'name': 'A'} 'name': 'A'}
self.resource.FnGetAtt = mock.Mock( self.resource.FnGetAtt = mock.Mock(
side_effect=exception.InvalidTemplateAttribute(resource='A', side_effect=exception.InvalidTemplateAttribute(resource='A',

View File

@ -278,8 +278,8 @@ class StackTest(common.HeatTestCase):
{'A': {'Type': 'GenericResourceType'}, {'A': {'Type': 'GenericResourceType'},
'B': {'Type': 'GenericResourceType'}}} 'B': {'Type': 'GenericResourceType'}}}
cache_data = {'A': {'physical_resource_id': 'A-id'}, cache_data = {'A': {'reference_id': 'A-id'},
'B': {'physical_resource_id': 'B-id'}} 'B': {'reference_id': 'B-id'}}
self.stack = stack.Stack(self.ctx, 'test_stack', self.stack = stack.Stack(self.ctx, 'test_stack',
template.Template(tpl), template.Template(tpl),
@ -1918,8 +1918,8 @@ class StackTest(common.HeatTestCase):
} }
}) })
cache_data = {'foo': {'physical_resource_id': 'foo-id', cache_data = {'foo': {'reference_id': 'foo-id',
'attributes': {'bar': 'baz'}}, 'attrs': {'bar': 'baz'}},
'bar': {'reference_id': 'bar-id'}} 'bar': {'reference_id': 'bar-id'}}
tmpl_stack = stack.Stack(self.ctx, 'test', tmpl) tmpl_stack = stack.Stack(self.ctx, 'test', tmpl)
tmpl_stack.store() tmpl_stack.store()
@ -1953,8 +1953,8 @@ class StackTest(common.HeatTestCase):
} }
}) })
cache_data = {'foo': {'physical_resource_id': 'physical-resource-id'}, cache_data = {'foo': {'reference_id': 'physical-resource-id'},
'bar': {'physical_resource_id': 'physical-resource-id'}} 'bar': {'reference_id': 'bar-id'}}
tmpl_stack = stack.Stack(self.ctx, 'test', tmpl) tmpl_stack = stack.Stack(self.ctx, 'test', tmpl)
tmpl_stack.store() tmpl_stack.store()
lightweight_stack = stack.Stack.load(self.ctx, stack_id=tmpl_stack.id, lightweight_stack = stack.Stack.load(self.ctx, stack_id=tmpl_stack.id,