Skip to content

Instantly share code, notes, and snippets.

@hguemar
Created April 11, 2016 08:54
Show Gist options
  • Save hguemar/5f1341cd34b4d2462d20ce53bd52b9e6 to your computer and use it in GitHub Desktop.
Save hguemar/5f1341cd34b4d2462d20ce53bd52b9e6 to your computer and use it in GitHub Desktop.
#! /usr/bin/python
import koji
from operator import itemgetter
import os.path
import sys
KOJI_URL='http://cbs.centos.org/kojihub'
FROMTAG='cloud7-openstack-mitaka-testing'
TOTAG='cloud7-openstack-mitaka-release'
CLIENT_CERT = os.path.expanduser('~/.centos.cert')
CLIENTCA_CERT = os.path.expanduser('~/.centos-server-ca.cert')
SERVERCA_CERT = os.path.expanduser('/etc/ssl/certs/ca-bundle.crt')
USER = 'hguemar'
kojiclient = koji.ClientSession(KOJI_URL)
kojiclient.ssl_login(CLIENT_CERT, CLIENTCA_CERT, SERVERCA_CERT)
def get_tag_id(tagName):
tags = [x['id'] for x in kojiclient.listTags() if x['name'] == tagName]
return tags[0] if len(tags) else None
def retrieve_packages(tagName):
tagID = get_tag_id(tagName)
packages = kojiclient.listPackages(tagID=tagID)
return packages
def tag_build(buildID, tagID, fromtag=None):
kojiclient.tagBuild(tagID, buildID, fromtag=fromtag)
def tag_packages(packages):
fromtag = get_tag_id(FROMTAG)
for package in packages:
name = package['package_name']
tagID = get_tag_id(TOTAG)
builds = kojiclient.listTagged(tag=FROMTAG, package=name, latest=True)
for build in builds:
buildID = build['build_id']
print "Tagging {}: {}".format(name, build)
tag_build(buildID, tagID)
packages = retrieve_packages(FROMTAG)
tag_packages(packages)
@apevec
Copy link

apevec commented Apr 11, 2016

tagID = get_tag_id(TOTAG) could be outside the loop

@apevec
Copy link

apevec commented Apr 11, 2016

Script assumes all packages are already added to TOTAG, how do we ensure, is there add-to-RDO.sh script?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment