Fix parsing of metadata

I broke metadata in bece6593f0 by no longer
updating the parsed template in the database. We need to resolve references
runtime data before storing the parsed template, because the metadata code
uses this directly.

Change-Id: I753fe199779ae1b0046366abadca0111a81463c6
Signed-off-by: Zane Bitter <zbitter@redhat.com>
changes/31/131/1
Zane Bitter 10 years ago
parent 5c3fc7bb61
commit 3c33de8b9f
  1. 2
      heat/engine/cloud_watch.py
  2. 3
      heat/engine/instance.py
  3. 5
      heat/engine/parser.py
  4. 7
      heat/engine/resources.py
  5. 7
      heat/engine/wait_condition.py

@ -70,7 +70,7 @@ class CloudWatchAlarm(Resource):
wr_values = {
'name': self.name,
'rule': self.t['Properties'],
'rule': self.parsed_template()['Properties'],
'state': 'NORMAL',
'stack_name': self.stack.name
}

@ -190,7 +190,8 @@ class Instance(Resource):
mime_blob.attach(msg)
if 'Metadata' in self.t:
msg = MIMEText(json.dumps(self.t['Metadata']),
metadata = self.parsed_template()['Metadata']
msg = MIMEText(json.dumps(metadata),
_subtype='x-cfninitdata')
msg.add_header('Content-Disposition', 'attachment',
filename='cfn-init-data')

@ -163,7 +163,10 @@ class Stack(object):
pt = db_api.parsed_template_get(self.context, self.parsed_template_id)
if pt:
pt.update_and_save({'template': self.t.copy()})
template = self.t.copy()
template['Resources'] = dict((k, r.parsed_template())
for (k, r) in self.resources.items())
pt.update_and_save({'template': template})
else:
logger.warn('Cant find parsed template to update %d' %
self.parsed_template_id)

@ -76,6 +76,9 @@ class Resource(object):
self.id = None
self._nova = {}
def parsed_template(self):
return self.stack.resolve_runtime_data(self.t)
def nova(self, service_type='compute'):
if service_type in self._nova:
return self._nova[service_type]
@ -97,9 +100,7 @@ class Resource(object):
return self._nova[service_type]
def calculate_properties(self):
template = self.stack.resolve_runtime_data(self.t)
for p, v in template['Properties'].items():
for p, v in self.parsed_template()['Properties'].items():
self.properties[p] = v
def create(self):

@ -78,9 +78,10 @@ class WaitCondition(Resource):
def _get_handle_resource_id(self):
if self.resource_id is None:
self.handle_url = self.properties['Handle']
self.resource_id = self.handle_url.split('/')[-1]
return self.resource_id
self.calculate_properties()
handle_url = self.properties['Handle']
self.resource_id = handle_url.split('/')[-1]
return self.resource_id
def create(self):
if self.state is not None:

Loading…
Cancel
Save