From 44bb725f41c6690dc13e3a350a5675469f24750a Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Tue, 4 Sep 2012 17:08:34 +0100 Subject: [PATCH] heat tests : FuncUtils add get_stack_output function Add a function to FuncUtils which allows us to easily parse the stack outputs defined in a template Change-Id: Ie1891cb11f54d019315350d449bdc5e22e340458 Signed-off-by: Steven Hardy --- heat/tests/functional/util.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/heat/tests/functional/util.py b/heat/tests/functional/util.py index c8116fcc..0b1d946d 100644 --- a/heat/tests/functional/util.py +++ b/heat/tests/functional/util.py @@ -350,6 +350,22 @@ class FuncUtils: with open(filepaths[file]) as f: assert data == f.read() + def get_stack_output(self, output_key): + ''' + Extract a specified output from the DescribeStacks details + ''' + # Get the DescribeStacks result for this stack + parameters = {'StackName': self.stackname} + c = self.get_heat_client() + result = c.describe_stacks(**parameters) + + # Extract the OutputValue for the specified OutputKey + root = etree.fromstring(result) + output_list = root.xpath('//member[OutputKey="' + output_key + '"]') + output = output_list.pop() + value = output.findtext('OutputValue') + return value + def cleanup(self): self.ssh.close() subprocess.call(['heat', 'delete', self.stackname]) -- 2.45.2