From 213190ae030e9971225ea3f103b4be0a7f2532d4 Mon Sep 17 00:00:00 2001 From: Marcin Juszkiewicz Date: Wed, 1 Jun 2022 17:16:22 +0200 Subject: Allow to provide own repos.yaml file Several people use Kolla behind firewall/proxy. Internal mirrors are often in use then. We do not provide a way to replace repos.yaml file in an easy way which may lead to complicated solutions or template overrides. This patch adds a way to provide own copy of repos.yaml file. Change-Id: I0b07da22fea27e0ff4e90aaad19e50d84ff9a121 --- kolla/common/config.py | 2 ++ kolla/image/build.py | 2 ++ kolla/template/methods.py | 6 +++++- 3 files changed, 9 insertions(+), 1 deletion(-) (limited to 'kolla') diff --git a/kolla/common/config.py b/kolla/common/config.py index 1cfdebdd3..78c9f2fcd 100755 --- a/kolla/common/config.py +++ b/kolla/common/config.py @@ -251,6 +251,8 @@ _CLI_OPTS = [ help='Show summary at the end of build'), cfg.StrOpt('image-name-prefix', default='', help='Prefix prepended to image names'), + cfg.StrOpt('repos-yaml', default='', + help='Path to alternative repos.yaml file'), ] _BASE_OPTS = [ diff --git a/kolla/image/build.py b/kolla/image/build.py index 0808afc84..f87c43292 100755 --- a/kolla/image/build.py +++ b/kolla/image/build.py @@ -611,6 +611,7 @@ class KollaWorker(object): self.use_dumb_init = conf.use_dumb_init self.base_tag = conf.base_tag self.tag = conf.tag + self.repos_yaml = conf.repos_yaml self.base_arch = conf.base_arch self.debian_arch = self.base_arch if self.base_arch == 'aarch64': @@ -829,6 +830,7 @@ class KollaWorker(object): 'base_image': self.conf.base_image, 'base_distro_tag': self.base_tag, 'base_arch': self.base_arch, + 'repos_yaml': self.repos_yaml, 'use_dumb_init': self.use_dumb_init, 'base_package_type': self.base_package_type, 'debian_arch': self.debian_arch, diff --git a/kolla/template/methods.py b/kolla/template/methods.py index 4426512bb..94d72401b 100644 --- a/kolla/template/methods.py +++ b/kolla/template/methods.py @@ -91,7 +91,11 @@ def handle_repos(context, reponames, mode): if not isinstance(reponames, list): raise TypeError("First argument should be a list of repositories") - repofile = os.path.dirname(os.path.realpath(__file__)) + '/repos.yaml' + if context.get('repos_yaml'): + repofile = context.get('repos_yaml') + else: + repofile = os.path.dirname(os.path.realpath(__file__)) + '/repos.yaml' + with open(repofile, 'r') as repos_file: repo_data = {} for name, params in yaml.safe_load(repos_file).items(): -- cgit v1.2.3