Add helper for parsing RPM_REPOS_YAML to yum config
Change-Id: Ibee5c1d208d825ff7bd77653b2e1f542e3080c09 Closed-Bug: #1604410
This commit is contained in:
parent
92247151dc
commit
e5bab975aa
|
@ -17,6 +17,7 @@ import os
|
|||
from fuelweb_test import logger
|
||||
from fuelweb_test import settings
|
||||
from fuelweb_test.helpers.ssh_manager import SSHManager
|
||||
from fuelweb_test.helpers.utils import generate_yum_repos_config
|
||||
|
||||
from gates_tests.helpers import exceptions
|
||||
|
||||
|
@ -40,6 +41,21 @@ def install_mos_repos():
|
|||
source=settings.FUEL_RELEASE_PATH.rstrip('/'),
|
||||
target=pack_path)
|
||||
|
||||
if settings.RPM_REPOS_YAML:
|
||||
with ssh.open_on_remote(
|
||||
ip=ssh.admin_ip,
|
||||
path='/etc/yum.repos.d/custom.repo',
|
||||
mode="w") as f:
|
||||
f.write(generate_yum_repos_config(settings.RPM_REPOS_YAML))
|
||||
|
||||
if settings.DEB_REPOS_YAML:
|
||||
ssh = SSHManager()
|
||||
pack_path = "/root/default_deb_repos.yaml"
|
||||
ssh.upload_to_remote(
|
||||
ip=ssh.admin_ip,
|
||||
source=settings.DEB_REPOS_YAML,
|
||||
target=pack_path)
|
||||
|
||||
except Exception:
|
||||
logger.exception("Could not upload package")
|
||||
raise
|
||||
|
|
|
@ -1589,3 +1589,24 @@ class YamlEditor(object):
|
|||
if self.content == self.original_content:
|
||||
return
|
||||
self.write_content()
|
||||
|
||||
|
||||
def generate_yum_repos_config(repositories):
|
||||
"""
|
||||
Function will parce yaml file with describing of repos
|
||||
and will create yum config
|
||||
:param repositories: yaml file with repo
|
||||
:return: a dict with options
|
||||
"""
|
||||
repos = YamlEditor(repositories).get_content()
|
||||
logger.debug('custom RPM repos from yaml: {0}'. format(repos))
|
||||
config = ""
|
||||
for repo in repos:
|
||||
config += "[{name}]\n" \
|
||||
"name={name}\n" \
|
||||
"baseurl={uri}\n" \
|
||||
"enabled=1\n" \
|
||||
"gpgcheck=0\n" \
|
||||
"priority={priority}\n" \
|
||||
"skip_if_unavailable=1\n".format(**repo)
|
||||
return config
|
||||
|
|
|
@ -721,3 +721,7 @@ MASTER_NODE_EXTRA_PACKAGES = os.environ.get("MASTER_NODE_EXTRA_PACKAGES", "")
|
|||
CENTOS_MASTER_NODE = os.environ.get("CENTOS_MASTER")
|
||||
|
||||
LOG_SNAPSHOT_TIMEOUT = int(os.environ.get("LOG_SNAPSHOT_TIMEOUT", 10 * 60))
|
||||
|
||||
RPM_REPOS_YAML = os.environ.get("RPM_REPOS_YAML")
|
||||
|
||||
DEB_REPOS_YAML = os.environ.get("DEB_REPOS_YAML")
|
||||
|
|
Loading…
Reference in New Issue