aboutsummaryrefslogtreecommitdiffstats
path: root/deploy/templater.py
diff options
context:
space:
mode:
authorPeter Barabas <peter.barabas@ericsson.com>2016-08-01 14:41:29 +0200
committerPeter Barabas <peter.barabas@ericsson.com>2016-08-01 14:41:29 +0200
commit8687c10b1a098c9c9f41e68c7f322a5ce6727c40 (patch)
tree9b05e952bbf7e6f48fde9941f12ec3756999921e /deploy/templater.py
parent0c0cc4756e1e95b461da56d538e0dedd1052f0fe (diff)
Make it possible to include files in templates
Change-Id: I45c42ac65cfbe6562f0035df3375a2231148e22e Signed-off-by: Peter Barabas <peter.barabas@ericsson.com>
Diffstat (limited to 'deploy/templater.py')
-rwxr-xr-xdeploy/templater.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/deploy/templater.py b/deploy/templater.py
index 2ad6e05ba..6b41e1f3c 100755
--- a/deploy/templater.py
+++ b/deploy/templater.py
@@ -107,12 +107,28 @@ class Templater(object):
return self.get_interface_from_network(interfaces, args[0])
+ def parse_include_tag(self, tag):
+ # Remove 'include(' prefix and trailing ')'
+ filename = tag[len('include('):].rstrip(')')
+
+ if not filename:
+ err('No argument for include().')
+
+ return filename
+
+ def include_file(self, filename):
+ fragment = self.load_yaml(filename)
+ return yaml.dump(fragment, default_flow_style=False)
+
def parse_tag(self, tag, indent):
fragment = ''
if 'interface(' in tag:
args = self.parse_interface_tag(tag)
fragment = self.lookup_interface(args)
+ elif 'include(' in tag:
+ filename = self.parse_include_tag(tag)
+ fragment = self.include_file(filename)
else:
path = tag.split(DELIMITER)
fragment = self.base