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
changes/72/213972/1
Angus Salkeld 7 years ago
parent 8746d9e1dc
commit 881e4d051a
  1. 2
      heat/engine/resource.py
  2. 6
      heat/engine/stack.py
  3. 2
      heat/engine/worker.py
  4. 4
      heat/tests/engine/test_engine_worker.py
  5. 12
      heat/tests/test_stack.py

@ -1428,7 +1428,7 @@ class Resource(object):
:results: the id or name of the resource.
'''
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:
return six.text_type(self.resource_id)

@ -1611,13 +1611,13 @@ class Stack(collections.Mapping):
return (self.cache_data is not None and
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(
resource_name, {}).get('physical_resource_id')
resource_name, {}).get('reference_id')
def cache_data_resource_attribute(self, resource_name, attribute_key):
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):
'''

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

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

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

Loading…
Cancel
Save