]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
heat tests : FuncUtils add get_stack_output function
authorSteven Hardy <shardy@redhat.com>
Tue, 4 Sep 2012 16:08:34 +0000 (17:08 +0100)
committerSteven Hardy <shardy@redhat.com>
Tue, 4 Sep 2012 16:13:15 +0000 (17:13 +0100)
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 <shardy@redhat.com>
heat/tests/functional/util.py

index c8116fcc892176fa4f98ab450b815511a4888aba..0b1d946daa659754d727560d1106b53519599dec 100644 (file)
@@ -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])