diff options
author | Hans Feldt <hans.feldt@ericsson.com> | 2015-06-03 10:50:48 +0200 |
---|---|---|
committer | Hans Feldt <hans.feldt@ericsson.com> | 2015-06-15 11:07:12 +0000 |
commit | 585a2483e9fb021d853b0946f185d066335adea4 (patch) | |
tree | 828834e6a3dc8617eaaf9422087a6f847b3fe804 /yardstick/orchestrator/heat.py | |
parent | 7492216de2f198e42bcd5e1539c8b21886a78d8c (diff) |
Add support for external HOT template
An external HOT template is a separate yaml file in native
Heat format HOT. The external template is referenced in the task
file and used as template for a "context". Parameters required at
template instantiation are also configured in the task file.
See new sample file ping-hot.yaml
Change-Id: Ie2b7ea96ea90b75ca4e08a29e2223ceeb1474724
JIRA: YARDSTICK-24
Signed-off-by: Hans Feldt <hans.feldt@ericsson.com>
Diffstat (limited to 'yardstick/orchestrator/heat.py')
-rw-r--r-- | yardstick/orchestrator/heat.py | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/yardstick/orchestrator/heat.py b/yardstick/orchestrator/heat.py index ddab89640..a3179a6f1 100644 --- a/yardstick/orchestrator/heat.py +++ b/yardstick/orchestrator/heat.py @@ -21,6 +21,9 @@ import json import heatclient.client import keystoneclient +from yardstick.common import template_format + + log = logging.getLogger(__name__) @@ -145,14 +148,7 @@ class HeatStack(HeatObject): class HeatTemplate(HeatObject): '''Describes a Heat template and a method to deploy template to a stack''' - def __init__(self, name): - super(HeatTemplate, self).__init__() - self.name = name - self.state = "NOT_CREATED" - self.keystone_client = None - self.heat_client = None - - # Heat template + def _init_template(self): self._template = {} self._template['heat_template_version'] = '2013-05-23' @@ -161,13 +157,35 @@ class HeatTemplate(HeatObject): '''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, name) + timestamp, self.name) # short hand for resources part of template self.resources = self._template['resources'] = {} self._template['outputs'] = {} + def __init__(self, name, template_file=None, heat_parameters=None): + super(HeatTemplate, self).__init__() + self.name = name + self.state = "NOT_CREATED" + self.keystone_client = None + self.heat_client = None + self.heat_parameters = {} + + # heat_parameters is passed to heat in stack create, empty dict when + # yardstick creates the template (no get_param in resources part) + if heat_parameters: + self.heat_parameters = heat_parameters + + if template_file: + with open(template_file) as stream: + print "Parsing external template:", template_file + template_str = stream.read() + self._template = template_format.parse(template_str) + self._parameters = heat_parameters + else: + self._init_template() + # holds results of requested output after deployment self.outputs = {} @@ -404,7 +422,8 @@ class HeatTemplate(HeatObject): json_template = json.dumps(self._template) start_time = time.time() stack.uuid = self.uuid = heat.stacks.create( - stack_name=self.name, template=json_template)['stack']['id'] + stack_name=self.name, template=json_template, + parameters=self.heat_parameters)['stack']['id'] status = self.status() |