Update StackDefinition resource data on metadata refresh
After refreshing the metadata of a resource its attributes may change, so we need to update the StackDefinition with the new data. Change-Id: Iec521317bffc0b381a0d965daef7939b1146ce50 Partially-Implements: blueprint stack-definition
This commit is contained in:
parent
82721f8865
commit
119f3e4aa5
|
@ -55,6 +55,7 @@ from heat.engine import service_software_config
|
|||
from heat.engine import service_stack_watch
|
||||
from heat.engine import stack as parser
|
||||
from heat.engine import stack_lock
|
||||
from heat.engine import stk_defn
|
||||
from heat.engine import support
|
||||
from heat.engine import template as templatem
|
||||
from heat.engine import update
|
||||
|
@ -1849,10 +1850,12 @@ class EngineService(service.ServiceBase):
|
|||
# update metadata which is used by other resources, e.g
|
||||
# when signalling a WaitConditionHandle resource, and other
|
||||
# resources may refer to WaitCondition Fn::GetAtt Data
|
||||
for r in stack.dependencies:
|
||||
if (r.name != rsrc.name and r.id is not None and
|
||||
r.action != r.INIT):
|
||||
r.metadata_update()
|
||||
for r in stack._explicit_dependencies():
|
||||
if r.action != r.INIT:
|
||||
if r.name != rsrc.name:
|
||||
r.metadata_update()
|
||||
stk_defn.update_resource_data(stack.defn, r.name,
|
||||
r.node_data())
|
||||
|
||||
s = self._get_stack(cnxt, stack_identity)
|
||||
|
||||
|
|
|
@ -13,10 +13,10 @@
|
|||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import timeutils
|
||||
import six
|
||||
|
||||
from heat.common import context
|
||||
from heat.engine import stack
|
||||
from heat.engine import stk_defn
|
||||
from heat.engine import watchrule
|
||||
from heat.objects import stack as stack_object
|
||||
from heat.objects import watch_rule as watch_rule_object
|
||||
|
@ -88,8 +88,10 @@ class StackWatch(object):
|
|||
def run_alarm_action(stk, actions, details):
|
||||
for action in actions:
|
||||
action(details=details)
|
||||
for res in six.itervalues(stk):
|
||||
for res in stk._explicit_dependencies():
|
||||
res.metadata_update()
|
||||
stk_defn.update_resource_data(stk.defn, res.name,
|
||||
res.node_data())
|
||||
|
||||
for wr in wrs:
|
||||
rule = watchrule.WatchRule.load(stk.context, watch=wr)
|
||||
|
|
|
@ -47,7 +47,8 @@ policy_template = '''
|
|||
}
|
||||
},
|
||||
"Random" : {
|
||||
"Type" : "OS::Heat::RandomString"
|
||||
"Type" : "OS::Heat::RandomString",
|
||||
"DependsOn" : "WebServerScaleDownPolicy"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ from heat.engine.resources.openstack.nova import server
|
|||
from heat.engine import scheduler
|
||||
from heat.engine import service
|
||||
from heat.engine import stack as stk
|
||||
from heat.engine import stk_defn
|
||||
from heat.engine import template as tmpl
|
||||
from heat.tests import common
|
||||
from heat.tests import utils
|
||||
|
@ -190,8 +191,11 @@ class MetadataRefreshTest(common.HeatTestCase):
|
|||
s2.attributes.reset_resolved_values()
|
||||
|
||||
# Run metadata update to pick up the new value from S2
|
||||
s1.metadata_update()
|
||||
# (simulating run_alarm_action() in service_stack_watch)
|
||||
s2.metadata_update()
|
||||
stk_defn.update_resource_data(stack.defn, s2.name, s2.node_data())
|
||||
s1.metadata_update()
|
||||
stk_defn.update_resource_data(stack.defn, s1.name, s1.node_data())
|
||||
|
||||
# Verify the updated value is correct in S1
|
||||
content = self._get_metadata_content(s1.metadata_get())
|
||||
|
@ -324,6 +328,7 @@ class MetadataRefreshServerTest(common.HeatTestCase):
|
|||
self.assertEqual((stack.CREATE, stack.COMPLETE), stack.state)
|
||||
|
||||
s1 = stack['instance1']
|
||||
s2 = stack['instance2']
|
||||
md = s1.metadata_get()
|
||||
self.assertEqual({u'template_data': '192.0.2.1'}, md)
|
||||
|
||||
|
@ -334,6 +339,8 @@ class MetadataRefreshServerTest(common.HeatTestCase):
|
|||
s1.metadata_set(new_md)
|
||||
md = s1.metadata_get(refresh=True)
|
||||
self.assertEqual(new_md, md)
|
||||
s2.attributes.reset_resolved_values()
|
||||
stk_defn.update_resource_data(stack.defn, s2.name, s2.node_data())
|
||||
s1.metadata_update()
|
||||
md = s1.metadata_get(refresh=True)
|
||||
self.assertEqual(new_md, md)
|
||||
|
|
Loading…
Reference in New Issue