aboutsummaryrefslogtreecommitdiff
path: root/kolla/template/methods.py
diff options
context:
space:
mode:
authorMarcin Juszkiewicz <marcin.juszkiewicz@linaro.org>2019-12-04 20:44:15 +0100
committerMarcin Juszkiewicz <marcin.juszkiewicz@linaro.org>2019-12-17 19:11:42 +0000
commit540b0cf6d7da4f7a85c54af847d4f519471d6e27 (patch)
treed033d86b8a20634ef1974e0f1feedc49550e40de /kolla/template/methods.py
parent308e85aa413da84ed107b27fa09a3f0e0a64392f (diff)
downloadkolla-540b0cf6d7da4f7a85c54af847d4f519471d6e27.tar.gz
kolla-540b0cf6d7da4f7a85c54af847d4f519471d6e27.zip
add more tests for enable_repos template method
- CentOS single, multiple and one with missing repo - Debian single, multiple and one with missing repo - TripleO Change-Id: Ide4868d031bd84b1a6935aada7d0e7627f11bf37
Diffstat (limited to 'kolla/template/methods.py')
-rw-r--r--kolla/template/methods.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/kolla/template/methods.py b/kolla/template/methods.py
index 1217547bf..c4c34125d 100644
--- a/kolla/template/methods.py
+++ b/kolla/template/methods.py
@@ -16,7 +16,6 @@ import os
import yaml
from jinja2 import contextfunction
-from jinja2.runtime import Undefined
def debian_package_install(packages, clean_package_cache=True):
@@ -79,6 +78,7 @@ def enable_repos(context, reponames):
Repo names have to be simple names mapped to proper ones. So 'ceph' ==
'centos-ceph-nautilus' for CentOS, UCA for Ubuntu (enabled by default) and
something else for Debian.
+ Distro/arch are not required to have all entries - we ignore missing ones.
"""
repofile = os.path.dirname(os.path.realpath(__file__)) + '/repos.yaml'
with open(repofile, 'r') as repos_file:
@@ -86,24 +86,13 @@ def enable_repos(context, reponames):
for name, params in yaml.safe_load(repos_file).items():
repo_data[name] = params
- # TODO(hrw): add checks for isinstance() and raise proper exception
base_package_type = context.get('base_package_type')
- if isinstance(base_package_type, Undefined):
- raise
-
base_distro = context.get('base_distro')
base_arch = context.get('base_arch')
distro_package_manager = context.get('distro_package_manager')
commands = ''
- if base_package_type == 'rpm':
- # NOTE(hrw): we enable all repos with one call
- if distro_package_manager == 'yum':
- commands = 'yum-config-manager '
- elif distro_package_manager == 'dnf':
- commands = 'dnf config-manager '
-
try:
repo_list = repo_data['%s-%s' % (base_distro, base_arch)]
except KeyError:
@@ -116,12 +105,23 @@ def enable_repos(context, reponames):
commands += ' --enable %s' % repo_list[repo]
elif base_package_type == 'deb':
commands += 'echo "%s" ' % repo_list[repo]
- commands += '>/etc/apt/sources.list.d/%s.list; ' % repo
+ commands += '>/etc/apt/sources.list.d/%s.list && ' % repo
except KeyError:
+ # NOTE(hrw): we ignore missing repositories for a given
+ # distro/arch
pass
- # NOTE(hrw): tripleo builds have empty repolist
- except TypeError:
- pass
+
+ if base_package_type == 'rpm' and commands:
+ # NOTE(hrw): if commands is empty then no repos are enabled
+ # otherwise we need to add command to handle repositories
+ if distro_package_manager == 'yum':
+ commands = 'yum-config-manager %s' % commands
+ elif distro_package_manager == 'dnf':
+ # NOTE(hrw) dnf errors out if we enable unknown repo
+ commands = 'dnf config-manager %s || true' % commands
+ elif base_package_type == 'deb':
+ # NOTE(hrw): Debian commands end with '&&'
+ commands = commands[0:-4]
if commands:
commands = "RUN %s" % commands