Created
July 23, 2018 10:33
-
-
Save hguemar/9e692d80e740cc7f5e683d6a05372a78 to your computer and use it in GitHub Desktop.
Register RDO packages in CBS tags
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python3 | |
import koji | |
import os | |
import rdoinfo | |
import six | |
import sys | |
def get_build_tags(info, release): | |
release_info = None | |
for rls in info['releases']: | |
if rls['name'] == release: | |
release_info = rls | |
break | |
if not release_info: | |
print("There's no release {} in rdoinfo".format(release)) | |
sys.exit(1) | |
tags = release_info['repos'][0]['buildsys-tags'] | |
# FIXME(hguemar): cleanup required at this moment | |
# release tag is not yet in rdoinfo | |
tags.remove('cloud7-openstack-{}-el7-build'.format('rocky')) | |
tags.append('cloud7-openstack-{}-release'.format('rocky')) | |
return tags | |
def extract_packages_from_release(info, release): | |
releases = info['releases'] | |
rls_names = [rls['name'] for rls in releases] | |
testing_tag = "cloud7-openstack-{}-testing".format(release) | |
if release not in rls_names: | |
print("There's no release {} in rdoinfo".format(release)) | |
sys.exit(1) | |
pkgs = [] | |
for pkg in info['packages']: | |
if release in pkg['tags']: | |
pkgs.append(pkg['name']) | |
for pkg in info['packages']: | |
if 'buildsys-tags' in pkg: | |
if testing_tag in pkg['buildsys-tags']: | |
pkgs.append(pkg['name']) | |
pkgs = sorted(pkgs) | |
return pkgs | |
def register_packages(tags, pkgs): | |
opts = koji.read_config('cbs') | |
for key, value in six.iteritems(opts): | |
opts[key] = os.path.expanduser(value) if isinstance(value, str) \ | |
else value | |
session = koji.ClientSession(opts['server'], opts=opts) | |
session.ssl_login(opts['cert'], None, opts['serverca']) | |
session.multicall = True | |
for tag in tags: | |
for pkg in pkgs: | |
session.packageListAdd(tag, pkg, owner='hguemar') | |
session.multiCall(strict=True) | |
if __name__ == '__main__': | |
info = rdoinfo.parse_info_file('rdo.yml', include_fns=['deps.yml']) | |
pkgs = extract_packages_from_release(info, 'rocky') | |
tags = get_build_tags(info, 'rocky') | |
register_packages(tags, pkgs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment