From 29fcb04cf38de41276b2b23e69e86d898efe5afb Mon Sep 17 00:00:00 2001 From: Abe Music Date: Thu, 28 Jul 2016 16:31:16 -0500 Subject: enhancements to install_packages macro - Adds debian_package_install method to the jinja environment that will return the necessary set of commands needed to install packages via apt-get and/or URLs to .deb packages - Updates install_packages macro to make use of the method above Change-Id: Ie9318a7def54b5034ba91375fd8fd3b589d18349 Partially-implements: blueprint third-party-plugin-support --- kolla/image/build.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'kolla/image') diff --git a/kolla/image/build.py b/kolla/image/build.py index 090b28f4b..20d26e01b 100644 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -51,6 +51,7 @@ if PROJECT_ROOT not in sys.path: from kolla.common import config as common_config from kolla.common import task from kolla.template import filters as jinja_filters +from kolla.template import methods as jinja_methods from kolla import version @@ -625,6 +626,17 @@ class KollaWorker(object): } return filters + def _get_methods(self): + """Mapping of available Jinja methods + + return a dictionary that maps available function names and their + corresponding python methods to make them available in jinja templates + """ + + return { + 'debian_package_install': jinja_methods.debian_package_install, + } + def create_dockerfiles(self): kolla_version = version.version_info.cached_version_string() supported_distro_release = common_config.DISTRO_RELEASE.get( @@ -648,6 +660,7 @@ class KollaWorker(object): env = jinja2.Environment( # nosec: not used to render HTML loader=jinja2.FileSystemLoader(self.working_dir)) env.filters.update(self._get_filters()) + env.globals.update(self._get_methods()) tpl_path = os.path.join( os.path.relpath(path, self.working_dir), template_name) -- cgit v1.2.3