Merge "Include file content in scenario tests"
diff --git a/heat_tempest_plugin/common/test.py b/heat_tempest_plugin/common/test.py
index 34ab24e..cbf4abb 100644
--- a/heat_tempest_plugin/common/test.py
+++ b/heat_tempest_plugin/common/test.py
@@ -10,7 +10,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import os
 import random
 import re
 import subprocess
@@ -206,13 +205,6 @@
             LOG.info('Console output for %s', server.id)
             LOG.info(server.get_console_output())
 
-    def _load_template(self, base_file, file_name, sub_dir=None):
-        sub_dir = sub_dir or ''
-        filepath = os.path.join(os.path.dirname(os.path.realpath(base_file)),
-                                sub_dir, file_name)
-        with open(filepath) as f:
-            return f.read()
-
     def create_keypair(self, client=None, name=None):
         if client is None:
             client = self.compute_client
diff --git a/heat_tempest_plugin/tests/scenario/scenario_base.py b/heat_tempest_plugin/tests/scenario/scenario_base.py
index 5cfb5d1..db38c4e 100644
--- a/heat_tempest_plugin/tests/scenario/scenario_base.py
+++ b/heat_tempest_plugin/tests/scenario/scenario_base.py
@@ -10,6 +10,10 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
+import os
+import yaml
+
+from heatclient.common import template_utils
 from oslo_utils import reflection
 
 from heat_tempest_plugin.common import test
@@ -33,9 +37,19 @@
         if not self.conf.minimal_instance_type:
             raise self.skipException("No minimal flavor configured to test")
 
+    def _load_template(self, base_file, file_name, sub_dir=None, files=None):
+        sub_dir = sub_dir or ''
+        filepath = os.path.join(os.path.dirname(os.path.realpath(base_file)),
+                                sub_dir, file_name)
+        _files, template = template_utils.get_template_contents(filepath,
+                                                                files=files)
+        return yaml.safe_dump(template)
+
     def launch_stack(self, template_name, expected_status='CREATE_COMPLETE',
                      parameters=None, **kwargs):
-        template = self._load_template(__file__, template_name, self.sub_dir)
+        files = kwargs.get('files', {})
+        template = self._load_template(__file__, template_name, self.sub_dir,
+                                       files)
 
         parameters = parameters or {}
 
@@ -45,7 +59,7 @@
         stack_id = self.stack_create(
             stack_name=kwargs.get('stack_name'),
             template=template,
-            files=kwargs.get('files'),
+            files=files,
             parameters=parameters,
             environment=kwargs.get('environment'),
             expected_status=expected_status