From 2350849a5c764822f267ca5c9efc4a847c9132e6 Mon Sep 17 00:00:00 2001 From: Ross Brattain Date: Mon, 13 Feb 2017 11:31:49 -0800 Subject: heat: use dict literal in init_template prefer dict literals when possible over increment assignment. Change-Id: Ia40bbc04eed61feb036a1e9ec3b3110b03c095e1 Signed-off-by: Ross Brattain --- yardstick/orchestrator/heat.py | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'yardstick') diff --git a/yardstick/orchestrator/heat.py b/yardstick/orchestrator/heat.py index ea9bd1b08..864f1f9ec 100644 --- a/yardstick/orchestrator/heat.py +++ b/yardstick/orchestrator/heat.py @@ -149,21 +149,28 @@ class HeatStack(HeatObject): class HeatTemplate(HeatObject): """Describes a Heat template and a method to deploy template to a stack""" - def _init_template(self): - self._template = {} - self._template['heat_template_version'] = '2013-05-23' + DESCRIPTION_TEMPLATE = """\ +Stack built by the yardstick framework for %s on host %s %s. +All referred generated resources are prefixed with the template +name (i.e. %s).\ +""" + def _init_template(self): timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") - self._template['description'] = \ - """Stack built by the yardstick framework for %s on host %s %s. - All referred generated resources are prefixed with the template - name (i.e. %s).""" % (getpass.getuser(), socket.gethostname(), - timestamp, self.name) + self._template = { + 'heat_template_version': '2013-05-23', + 'description': self.DESCRIPTION_TEMPLATE % ( + getpass.getuser(), + socket.gethostname(), + timestamp, + self.name + ), + 'resources': {}, + 'outputs': {} + } # short hand for resources part of template - self.resources = self._template['resources'] = {} - - self._template['outputs'] = {} + self.resources = self._template['resources'] def __init__(self, name, template_file=None, heat_parameters=None): super(HeatTemplate, self).__init__() -- cgit 1.2.3-korg