diff options
author | Ross Brattain <ross.b.brattain@intel.com> | 2018-03-01 16:17:51 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2018-03-01 16:17:51 +0000 |
commit | 9316c6c49957f2d8c680ed8acfaccac9070ed2f4 (patch) | |
tree | 9c9a780e089b59210415ad22bde4f65e4b4e795f /yardstick/orchestrator/heat.py | |
parent | de8ce9889cfc9e9d62e26e53b5f27b2f4cd9ff06 (diff) | |
parent | 3c2924769969733632d22e128b48fccee0043069 (diff) |
Merge "Add methods to get an existing stack"
Diffstat (limited to 'yardstick/orchestrator/heat.py')
-rw-r--r-- | yardstick/orchestrator/heat.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/yardstick/orchestrator/heat.py b/yardstick/orchestrator/heat.py index cd4eb7234..20be89f57 100644 --- a/yardstick/orchestrator/heat.py +++ b/yardstick/orchestrator/heat.py @@ -44,6 +44,13 @@ class HeatStack(object): self._cloud = shade.openstack_cloud() self._stack = None + def _update_stack_tracking(self): + outputs = self._stack.outputs + self.outputs = {output['output_key']: output['output_value'] for output + in outputs} + if self.uuid: + _DEPLOYED_STACKS[self.uuid] = self._stack + def create(self, template, heat_parameters, wait, timeout): """Creates an OpenStack stack from a template""" with tempfile.NamedTemporaryFile('wb', delete=False) as template_file: @@ -52,11 +59,21 @@ class HeatStack(object): self._stack = self._cloud.create_stack( self.name, template_file=template_file.name, wait=wait, timeout=timeout, **heat_parameters) - outputs = self._stack.outputs - self.outputs = {output['output_key']: output['output_value'] for output - in outputs} - if self.uuid: - _DEPLOYED_STACKS[self.uuid] = self._stack + + self._update_stack_tracking() + + def get(self): + """Retrieves an existing stack from the target cloud + + Returns a bool indicating whether the stack exists in the target cloud + If the stack exists, it will be stored as self._stack + """ + self._stack = self._cloud.get_stack(self.name) + if not self._stack: + return False + + self._update_stack_tracking() + return True @staticmethod def stacks_exist(): |