Convergence: pass the resource name into has_cache()
Change-Id: I2bfac4ce6a8806acc85c17466429d63a5d93d79f
This commit is contained in:
parent
4513dbc2ca
commit
8746d9e1dc
|
@ -200,7 +200,7 @@ class GetAtt(function.Function):
|
|||
return r.FnGetAtt(attribute)
|
||||
# NOTE(sirushtim): Add r.INIT to states above once convergence
|
||||
# is the default.
|
||||
elif r.stack.has_cache_data() and r.action == r.INIT:
|
||||
elif r.stack.has_cache_data(r.name) and r.action == r.INIT:
|
||||
return r.FnGetAtt(attribute)
|
||||
else:
|
||||
return None
|
||||
|
|
|
@ -234,7 +234,7 @@ class Resource(object):
|
|||
self.replaced_by = None
|
||||
self.current_template_id = None
|
||||
|
||||
if not stack.has_cache_data():
|
||||
if not stack.has_cache_data(name):
|
||||
resource = stack.db_resource_get(name)
|
||||
if resource:
|
||||
self._load_data(resource)
|
||||
|
@ -1427,7 +1427,7 @@ class Resource(object):
|
|||
|
||||
:results: the id or name of the resource.
|
||||
'''
|
||||
if self.stack.has_cache_data():
|
||||
if self.stack.has_cache_data(self.name):
|
||||
return self.stack.cache_data_resource_id(self.name)
|
||||
|
||||
if self.resource_id is not None:
|
||||
|
@ -1450,7 +1450,7 @@ class Resource(object):
|
|||
:param path: a list of path components to select from the attribute.
|
||||
:returns: the attribute value.
|
||||
'''
|
||||
if self.stack.has_cache_data():
|
||||
if self.stack.has_cache_data(self.name):
|
||||
# Load from cache for lightweight resources.
|
||||
attribute = self.stack.cache_data_resource_attribute(
|
||||
self.name, key)
|
||||
|
|
|
@ -1607,11 +1607,9 @@ class Stack(collections.Mapping):
|
|||
for res in six.itervalues(self.resources):
|
||||
res.attributes.reset_resolved_values()
|
||||
|
||||
def has_cache_data(self):
|
||||
if self.cache_data is not None:
|
||||
return True
|
||||
|
||||
return False
|
||||
def has_cache_data(self, resource_name):
|
||||
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):
|
||||
return self.cache_data.get(
|
||||
|
|
|
@ -277,10 +277,14 @@ class StackTest(common.HeatTestCase):
|
|||
'Resources':
|
||||
{'A': {'Type': 'GenericResourceType'},
|
||||
'B': {'Type': 'GenericResourceType'}}}
|
||||
|
||||
cache_data = {'A': {'physical_resource_id': 'A-id'},
|
||||
'B': {'physical_resource_id': 'B-id'}}
|
||||
|
||||
self.stack = stack.Stack(self.ctx, 'test_stack',
|
||||
template.Template(tpl),
|
||||
status_reason='blarg',
|
||||
cache_data={})
|
||||
cache_data=cache_data)
|
||||
|
||||
def get_more(nested_depth=0):
|
||||
yield 'X'
|
||||
|
@ -1914,7 +1918,9 @@ class StackTest(common.HeatTestCase):
|
|||
}
|
||||
})
|
||||
|
||||
cache_data = {'foo': {'attributes': {'bar': 'baz'}}}
|
||||
cache_data = {'foo': {'physical_resource_id': 'foo-id',
|
||||
'attributes': {'bar': 'baz'}},
|
||||
'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,
|
||||
|
@ -1947,7 +1953,8 @@ class StackTest(common.HeatTestCase):
|
|||
}
|
||||
})
|
||||
|
||||
cache_data = {'foo': {'physical_resource_id': 'physical-resource-id'}}
|
||||
cache_data = {'foo': {'physical_resource_id': 'physical-resource-id'},
|
||||
'bar': {'physical_resource_id': 'physical-resource-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…
Reference in New Issue