{'internal.git_ignore_ssl': None},
{'internal.setup_cdn_repo': None},
{'internal.setup_base_repo': None},
- {'internal.setup_additional_repo': None}
+ {'internal.setup_additional_repo': None},
+ {'internal.setup_container_registry': None}
])
# Install latest kernel task for redhat downstream runs
if config.get('redhat').get('install_latest_rh_kernel', False):
from teuthology.job_status import get_status, set_status
from teuthology.orchestra import cluster, remote, run
# the below import with noqa is to workaround run.py which does not support multilevel submodule import
-from teuthology.task.internal.redhat import setup_cdn_repo, setup_base_repo, setup_additional_repo, setup_stage_cdn # noqa
+from teuthology.task.internal.redhat import (setup_cdn_repo, setup_base_repo, # noqa
+ setup_additional_repo, # noqa
+ setup_stage_cdn, setup_container_registry) # noqa
log = logging.getLogger(__name__)
set_cdn_repo(ctx, config)
yield
+@contextlib.contextmanager
+def setup_container_registry(ctx, config):
+ """
+ setup container registry if setup_container_registry in config
+
+ redhat:
+ setup_container_registry: <registry.io> # registry-name
+ """
+ if ctx.config.get('redhat').get('setup_container_registry', None):
+ registry = ctx.config['redhat']['setup_container_registry']
+
+ # fetch credentials from teuth_config
+ creds = teuthconfig.get('registries', dict()).get(registry)
+ if not creds:
+ raise ConfigError("Registry not found....")
+
+ # container-tool login
+ for remote in ctx.cluster.remotes.keys():
+ container_tool = "podman"
+ if remote.os.version.startswith('7'):
+ container_tool = "docker"
+
+ remote.run(args=[
+ 'sudo', container_tool,
+ 'login', registry,
+ '--username', creds['username'],
+ '--password', creds['password'],
+ ]
+ )
+ yield
@contextlib.contextmanager
def setup_additional_repo(ctx, config):