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
(cherry picked from commit 213190ae03)
This commit is contained in:
Marcin Juszkiewicz 2022-06-01 17:16:22 +02:00 committed by Maksim Malchuk
parent b0517b3562
commit 47fdc545ad
4 changed files with 16 additions and 2 deletions

View File

@ -247,7 +247,9 @@ _CLI_OPTS = [
cfg.BoolOpt('summary', default=True,
help='Show summary at the end of build'),
cfg.BoolOpt('infra-rename', default=False,
help='Rename infrastructure images to infra')
help='Rename infrastructure images to infra'),
cfg.StrOpt('repos-yaml', default='',
help='Path to alternative repos.yaml file'),
]
_BASE_OPTS = [

View File

@ -676,6 +676,7 @@ class KollaWorker(object):
self.base_tag = conf.base_tag
self.install_type = conf.install_type
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':
@ -934,6 +935,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,

View File

@ -95,7 +95,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():

View File

@ -0,0 +1,6 @@
---
features:
- |
Added an `--repos-yaml` argument to allow user to provide own file with
definitions of external package repositories. Useful for those building
in offline environments with set of internal mirrors.