Use the ResourceDefinition.Diff API in resources
Now that we have an API for determining the difference between resource definitions in Heat, use it instead of treating the tmpl_diff argument to handle_update() like a diff of snippets from a CloudFormation template. Change-Id: Ib54ff610065ad8d4eabc7d6a45213fde93e425c8
This commit is contained in:
parent
75b56789e6
commit
f89cfcc662
@ -650,7 +650,9 @@ class ScalingPolicy(resource.Resource):
|
||||
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
asclient = self.auto_scale()
|
||||
args = self._get_args(tmpl_diff['Properties'])
|
||||
props = json_snippet.properties(self.properties_schema,
|
||||
self.context)
|
||||
args = self._get_args(props)
|
||||
args['policy'] = self._get_policy_id()
|
||||
asclient.replace_policy(**args)
|
||||
|
||||
|
@ -259,7 +259,7 @@ class AutoScalingGroup(instgrp.InstanceGroup, cooldown.CooldownMixin):
|
||||
"""
|
||||
if tmpl_diff:
|
||||
# parse update policy
|
||||
if 'UpdatePolicy' in tmpl_diff:
|
||||
if tmpl_diff.update_policy_changed():
|
||||
up = json_snippet.update_policy(self.update_policy_schema,
|
||||
self.context)
|
||||
self.update_policy = up
|
||||
|
@ -217,7 +217,7 @@ class LaunchConfiguration(resource.Resource):
|
||||
self._update_stored_properties()
|
||||
|
||||
def needs_replace_with_tmpl_diff(self, tmpl_diff):
|
||||
return 'Metadata' in tmpl_diff
|
||||
return tmpl_diff.metadata_changed()
|
||||
|
||||
def get_reference_id(self):
|
||||
return self.physical_resource_name_or_FnGetRefId()
|
||||
|
@ -730,8 +730,8 @@ class Instance(resource.Resource, sh.SchedulerHintsMixin):
|
||||
return updaters
|
||||
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
if 'Metadata' in tmpl_diff:
|
||||
self.metadata_set(tmpl_diff['Metadata'])
|
||||
if tmpl_diff.metadata_changed():
|
||||
self.metadata_set(json_snippet.metadata())
|
||||
updaters = []
|
||||
server = None
|
||||
if self.TAGS in prop_diff:
|
||||
|
@ -190,7 +190,7 @@ class InstanceGroup(stack_resource.StackResource):
|
||||
"""
|
||||
if tmpl_diff:
|
||||
# parse update policy
|
||||
if rsrc_defn.UPDATE_POLICY in tmpl_diff:
|
||||
if tmpl_diff.update_policy_changed():
|
||||
up = json_snippet.update_policy(self.update_policy_schema,
|
||||
self.context)
|
||||
self.update_policy = up
|
||||
|
@ -388,7 +388,7 @@ class ResourceGroup(stack_resource.StackResource):
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
if tmpl_diff:
|
||||
# parse update policy
|
||||
if rsrc_defn.UPDATE_POLICY in tmpl_diff:
|
||||
if tmpl_diff.update_policy_changed():
|
||||
up = json_snippet.update_policy(self.update_policy_schema,
|
||||
self.context)
|
||||
self.update_policy = up
|
||||
|
@ -549,7 +549,9 @@ class Workflow(signal_responder.SignalResponder,
|
||||
if prop in prop_diff:
|
||||
del prop_diff[prop]
|
||||
if len(prop_diff) > 0:
|
||||
new_props = self.prepare_properties(tmpl_diff['Properties'])
|
||||
props = json_snippet.properties(self.properties_schema,
|
||||
self.context)
|
||||
new_props = self.prepare_properties(props)
|
||||
try:
|
||||
workflow = self.client().workflows.update(new_props)
|
||||
except Exception as ex:
|
||||
|
@ -1178,20 +1178,21 @@ class Server(stack_user.StackUser, sh.SchedulerHintsMixin,
|
||||
return ud_update_policy == 'REPLACE'
|
||||
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
if 'Metadata' in tmpl_diff:
|
||||
if tmpl_diff.metadata_changed():
|
||||
# If SOFTWARE_CONFIG user_data_format is enabled we require
|
||||
# the "deployments" and "os-collect-config" keys for Deployment
|
||||
# polling. We can attempt to merge the occ data, but any
|
||||
# metadata update containing deployments will be discarded.
|
||||
new_md = json_snippet.metadata()
|
||||
if self.user_data_software_config():
|
||||
metadata = self.metadata_get(True) or {}
|
||||
new_occ_md = tmpl_diff['Metadata'].get('os-collect-config', {})
|
||||
new_occ_md = new_md.get('os-collect-config', {})
|
||||
occ_md = metadata.get('os-collect-config', {})
|
||||
occ_md.update(new_occ_md)
|
||||
tmpl_diff['Metadata']['os-collect-config'] = occ_md
|
||||
new_md['os-collect-config'] = occ_md
|
||||
deployment_md = metadata.get('deployments', [])
|
||||
tmpl_diff['Metadata']['deployments'] = deployment_md
|
||||
self.metadata_set(tmpl_diff['Metadata'])
|
||||
new_md['deployments'] = deployment_md
|
||||
self.metadata_set(new_md)
|
||||
|
||||
updaters = []
|
||||
server = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user