#6691 Updating scripts to use koji profiles
Merged 7 years ago by ausil. Opened 7 years ago by mohanboddu.
mohanboddu/releng koji-profiles  into  master

file modified
+10 -2
@@ -27,6 +27,8 @@ 

  STAGING_KOJI = "https://koji.stg.fedoraproject.org/kojihub"

  

  

+ 

+ 
ausil commented 7 years ago

why the extra lines?

  class ReleaseMapper(object):

      BRANCHNAME = 0

      KOJI_TAG = 1
@@ -78,8 +80,9 @@ 

      """

      Get a list of all blocked and unblocked packages in a branch.

      """

-     url = PRODUCTION_KOJI if not staging else STAGING_KOJI

-     kojisession = koji.ClientSession(url, {'krb_rdns': False})

+     profile = PRODUCTION_KOJI_PROFILE if not staging else STAGING_KOJI_PROFILE

+     koji_module = koji.get_profile_module(profile)

+     kojisession = koji_module.ClientSession(koji_module.config.server)

      kojisession.krb_login()

      pkglist = kojisession.listPackages(tagID=tag, inherited=True)

      blocked = []
@@ -324,10 +327,15 @@ 

      parser.add_argument(

          "--staging", default=False, action="store_true",

          help="Talk to staging services (pkgdb), instead of production")

+     parser.add_argument(

+         "-p", "--profile", default="compose_koji",

+         help="Koji profile to use, default: %(default)s")

      args = parser.parse_args()

  

      setup_logging(args.debug)

  

+     PRODUCTION_KOJI_PROFILE = args.profile

+     STAGING_KOJI_PROFILE = "stg"

      if not args.packages:

          block_all_retired(staging=args.staging)

      else:

file modified
+4 -4
@@ -15,8 +15,6 @@ 

  import rpm

  import operator

  

- LOCALKOJIHUB = 'http://arm.koji.fedoraproject.org/kojihub'

- REMOTEKOJIHUB = 'http://koji.fedoraproject.org/kojihub'

  PACKAGEURL = 'http://kojipkgs.fedoraproject.org/'

  

  workpath = '/tmp/build-recent'
@@ -134,8 +132,10 @@ 

  

  # setup the koji session

  logging.info('Setting up koji session')

- localkojisession = koji.ClientSession(LOCALKOJIHUB, {'krb_rdns': False})

- remotekojisession = koji.ClientSession(REMOTEKOJIHUB)

+ local_koji_module = koji.get_profile_module("arm")

+ localkojisession = local_koji_module.ClientSession(local_koji_module.config.server)

+ remote_koji_module = koji.get_profile_module("koji")

+ remotekojisession = remote_koji_module.ClientSession(remote_koji_module.config.server)

  localkojisession.krb_login()

  

  tag = 'f18-rebuild'

file modified
+4 -4
@@ -16,8 +16,6 @@ 

  import rpm 

  import shutil

  

- LOCALKOJIHUB = 'http://sparc.koji.fedoraproject.org/kojihub'

- REMOTEKOJIHUB = 'http://koji.fedoraproject.org/kojihub'

  PACKAGEURL = 'http://kojipkgs.fedoraproject.org/'

  

  workpath = '/tmp/build-recent'
@@ -125,8 +123,10 @@ 

  

  # setup the koji session

  logging.info('Setting up koji session')

- localkojisession = koji.ClientSession(LOCALKOJIHUB, {'krb_rdns': False})

- remotekojisession = koji.ClientSession(REMOTEKOJIHUB)

+ local_koji_module = koji.get_profile_module("arm")

+ remote_koji_module = koji.get_profile_module("fedora")

+ localkojisession = local_koji_module.ClientSession(local_koji_module.config.server)

+ remotekojisession = remote_koji_module.ClientSession(remote_koji_module.config.server)

  localkojisession.krb_login()

  

  tag = 'dist-f16'

@@ -35,9 +35,9 @@ 

  log.debug("tag=%s arch=%s pkgs=%s", args.tag, args.arch, args.package)

  

  if args.arch is None:

-     KOJIHUB = 'http://koji.fedoraproject.org/kojihub'

+     KOJIHUB = 'fedora'

  else:

-     KOJIHUB = 'http://%s.koji.fedoraproject.org/kojihub' % (args.arch)

+     KOJIHUB = args.arch

  

  

  def _rpmvercmp((e1, v1, r1), (e2, v2, r2)):
@@ -57,8 +57,8 @@ 

          # second evr wins

          return -1

  

- 

- kojisession = koji.ClientSession(KOJIHUB, {'krb_rdns': False})

+ koji_module = koji.get_profile_module(KOJIHUB)

+ kojisession = koji_module.ClientSession(koji_module.config.server)

  kojisession.krb_login()

  

  if args.package == []:

file modified
+8 -1
@@ -12,11 +12,18 @@ 

  

  import koji

  import os

+ import argparse

  

  tag = 'f25'

  oldtag = 'f24'

  # Create a koji session

- kojisession = koji.ClientSession('http://ppc.koji.fedoraproject.org/kojihub', {'krb_rdns': False})

+ parser = argparse.ArgumentParser()

+ parser.add_argument('-p','--koji-profile', help='Select a koji profile to use',required=True)

+ args = parser.parse_args()

+ koji_profile = args.koji_profile

+ 

+ koji_module = koji.get_profile_module(koji_profile)

+ kojisession = koji_module.ClientSession(koji_module.config.server)

  

  # Log into koji

  kojisession.krb_login()

file modified
+6 -4
@@ -31,8 +31,8 @@ 

  parser.add_argument('build', nargs='+', help='NVR')

  args = parser.parse_args()

  

- LOCALKOJIHUB = 'https://%s.koji.fedoraproject.org/kojihub' % (args.arch)

- REMOTEKOJIHUB = 'https://koji.fedoraproject.org/kojihub'

+ LOCALKOJIHUB = args.arch

+ REMOTEKOJIHUB = 'fedora'

  PACKAGEURL = 'http://kojipkgs.fedoraproject.org/'

  

  # Should probably set these from a koji config file
@@ -69,8 +69,10 @@ 

  

  # setup the koji session

  logging.info('Setting up koji session')

- localkojisession = koji.ClientSession(LOCALKOJIHUB, session_opts)

- remotekojisession = koji.ClientSession(REMOTEKOJIHUB)

+ local_koji_module = koji.get_profile_module(LOCALKOJIHUB)

+ remote_koji_module = koji.get_profile_module(REMOTEKOJIHUB)

+ localkojisession = local_koji_module.ClientSession(local_koji_module.config.server, session_opts)

+ remotekojisession = remote_koji_module.ClientSession(remote_koji_module.config.server)

  if os.path.isfile(CLIENTCERT):

      localkojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA)

  else:

file modified
+6 -4
@@ -29,8 +29,8 @@ 

  parser.add_argument("build", nargs="*", help="build to import")

  args = parser.parse_args()

  

- LOCALKOJIHUB = 'https://%s.koji.fedoraproject.org/kojihub' % (args.arch)

- REMOTEKOJIHUB = 'https://koji.fedoraproject.org/kojihub'

+ LOCALKOJIHUB = args.arch

+ REMOTEKOJIHUB = 'fedora'

  PACKAGEURL = 'http://kojipkgs.fedoraproject.org/'

  

  # Should probably set these from a koji config file
@@ -148,8 +148,10 @@ 

  

  # setup the koji session

  logging.info('Setting up koji session')

- localkojisession = koji.ClientSession(LOCALKOJIHUB, session_opts)

- remotekojisession = koji.ClientSession(REMOTEKOJIHUB)

+ local_koji_module = koji.get_profile_module(LOCALKOJIHUB)

+ remote_koji_module = koji.get_profile_module(REMOTEKOJIHUB)

+ localkojisession = local_koji_module.ClientSession(local_koji_module.config.server, session_opts)

+ remotekojisession = remote_koji_module.ClientSession(remote_koji_module.config.server)

  if os.path.isfile(CLIENTCERT):

      localkojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA)

  else:

file modified
+12 -6
@@ -15,6 +15,7 @@ 

  import koji

  import tempfile

  import shutil

+ import argparse

  

  # fill these in: 

  # pkgs to re-import: 
@@ -22,11 +23,16 @@ 

  # tag to tag them with: 

  tag = ''

  

- # setup koji sessions: 

- primarykoji = 'https://koji.fedoraproject.org/kojihub'

- secondarykoji = 'https://ppc.koji.fedoraproject.org/kojihub' 

- primary = koji.ClientSession(primarykoji)

- secondary = koji.ClientSession(secondarykoji, {'krb_rdns': False})

+ # setup koji sessions:

+ parser = argparse.ArgumentParser()

+ parser.add_argument('-p','--koji-profile', help='Koji profile for alternate arches',required=True)

+ args = parser.parse_args()

+ sec_profile = args.koji_profile

+ 

+ primarykoji = koji.get_profile_module("fedora")

+ secondarykoji = koji.get_profile_module(sec_profile)

+ primary = primarykoji.ClientSession(primarykoji.config.server)

+ secondary = secondarykoji.ClientSession(secondarykoji.config.server)

  secondary.krb_login()

  

  # do the thing: 
@@ -46,7 +52,7 @@ 

      subprocess.call(['koji', 'download-build', pkg], cwd=tempdir) 

      # verify RPMs are good, if so, import them:

      subprocess.check_call(['rpm -K *.rpm'], cwd=tempdir, shell=True)

-     subprocess.call(['ppc-koji import *.rpm'], cwd=tempdir, shell=True)

+     subprocess.call(['%s import *.rpm'%(sec_profile)], cwd=tempdir, shell=True)

      # Tag: 

      secondary.tagBuild(tag, pkg) 

      # Remove the temp dir

file modified
+2 -1
@@ -26,7 +26,8 @@ 

  tasks = {} # dict of new build task info

  

  # Create a koji session

- kojisession = koji.ClientSession('https://koji.fedoraproject.org/kojihub', {'krb_rdns': False})

+ koji_module = koji.get_profile_module("fedora")

+ kojisession = koji_module.ClientSession(koji_module.config.server)

  

  # Log into koji

  kojisession.krb_login()

file modified
+17 -16
@@ -11,7 +11,7 @@ 

  # This program requires koji installed, as well as configured.

  

  import os

- import optparse

+ import argparse

  import sys

  import koji

  import logging
@@ -20,25 +20,25 @@ 

  builds = {}

  untag = []

  loglevel = ''

- KOJIHUB = 'https://koji.fedoraproject.org/kojihub'

  # Setup a dict of our key names as sigul knows them to the actual key ID

  # that koji would use.  We should get this from sigul somehow.

  

- # Define our usage

- usage = 'usage: %prog [options] tag'

  # Create a parser to parse our arguments

- parser = optparse.OptionParser(usage=usage)

- parser.add_option('-v', '--verbose', action='count', default=0,

+ parser = argparse.ArgumentParser(usage = '%(prog)s [options] tag')

+ parser.add_argument('-v', '--verbose', action='count', default=0,

                    help='Be verbose, specify twice for debug')

- parser.add_option('-n', '--dry-run', action='store_true', default=False,

+ parser.add_argument('-n', '--dry-run', action='store_true', default=False,

                    help='Perform a dry run without untagging')

+ parser.add_argument('-p', '--koji-profile', default="fedora",

+                   help='Select a koji profile to use')

  

+ KOJIHUB = args.koji_profile

  # Get our options and arguments

- (opts, args) = parser.parse_args()

+ args, extras =  parser.parse_known_args()

  

- if opts.verbose <= 0:   

+ if args.verbose <= 0:

      loglevel = logging.WARNING

- elif opts.verbose == 1:

+ elif args.verbose == 1:

      loglevel = logging.INFO 

  else: # options.verbose >= 2

      loglevel = logging.DEBUG
@@ -48,15 +48,16 @@ 

                      level=loglevel)

  

  # Check to see if we got any arguments

- if not args:

+ if not extras:

      parser.print_help()

      sys.exit(1)

  

- tag = args[0]

+ tag = extras[0]

  

  # setup the koji session

  logging.info('Setting up koji session')

- kojisession = koji.ClientSession(KOJIHUB, {'krb_rdns': False})

+ koji_module = koji.get_profile_module(KOJIHUB)

+ kojisession = koji_module.ClientSession(koji_module.config.server)

  if not kojisession.krb_login():

      logging.error('Unable to log into koji')

      sys.exit(1)
@@ -81,14 +82,14 @@ 

  

  # Now untag all the builds

  logging.info('Untagging %s builds' % len(untag))

- if not opts.dry_run:

+ if not args.dry_run:

      kojisession.multicall = True

  for build in untag:

-     if not opts.dry_run:

+     if not args.dry_run:

          kojisession.untagBuildBypass(tag, build, force=True)

      logging.debug('Untagging %s' % build)

  

- if not opts.dry_run:

+ if not args.dry_run:

      results = kojisession.multiCall()

  

      for build, result in zip(untag, results):

file modified
+3 -2
@@ -312,14 +312,15 @@ 

          self.options.debug_xmlrpc = False

          self.options.password = None

          self.options.user = None

-         self.options.kojihub = 'http://koji.fedoraproject.org/kojihub'

+         self.options.kojihub = 'koji'

          self.options.regex = False

          self.options.ignore = []

          self.options.krb_rdns = False

  

      def create_koji_session(self):

          # used options: debug, debug_xmlrpc, user, password

-         self.koji_session = koji.ClientSession(self.options.kojihub, self.options.__dict__)

+         self.koji_module = koji.get_profile_module(self.kojihub)

+         self.koji_session = self.koji_module.ClientSession(self.koji_module.config.server, self.options.__dict__)

  

      def close_koji_session(self):

          self.koji_session.logout()

@@ -106,12 +106,11 @@ 

  class KojiHelper(object):

      def __init__(self, arch=None):

          if arch:

-             self.kojihub = \

-                 'https://{arch}.koji.fedoraproject.org/kojihub'.format(

-                     arch=arch)

+             self.kojihub = arch

          else:

-             self.kojihub = 'https://koji.fedoraproject.org/kojihub'

-         self.kojisession = koji.ClientSession(self.kojihub, {'krb_rdns': False})

+             self.kojihub = "koji"

+         self.koji_module = koji.get_profile_module(self.kojihub) 

+         self.kojisession = self.koji_module.ClientSession(self.koji_module.config.server)

          self.kojisession.krb_login()

  

      def listTagged(self, tag, inherit=False):

@@ -21,7 +21,8 @@ 

  

  arches = ['arm', 'ppc', 's390']

  

- kojisession = koji.ClientSession('https://koji.fedoraproject.org/kojihub')

+ koji_module = koji.get_profile_module("fedora")

+ kojisession = koji_module.ClientSession(koji_module.config.server)

  

  def getBlocked(kojisession, tag):

      blocked = [] # holding for blocked pkgs
@@ -46,7 +47,8 @@ 

  for arch in arches:

      print "== Working on Arch: %s" % arch

      # Create a koji session

-     seckojisession = koji.ClientSession('https://%s.koji.fedoraproject.org/kojihub' % arch , {'krb_rdns': False})

+     sec_koji_module = koji.get_profile_module(args.arch)

+     seckojisession = sec_koji_module.ClientSession(sec_koji_module.config.server)

      seckojisession.krb_login()

  

      for tag in tags:

@@ -64,8 +64,10 @@ 

  

  print "=== Working on arch: %s ====" % args.arch

  # Create a koji session

- kojisession = koji.ClientSession('https://koji.fedoraproject.org/kojihub')

- seckojisession = koji.ClientSession('https://%s.koji.fedoraproject.org/kojihub' % args.arch, session_opts)

+ koji_module = koji.get_profile_module("fedora")

+ kojisession = koji_module.ClientSession(koji_module.config.server)

+ sec_koji_module = koji.get_profile_module(args.arch)

+ seckojisession = sec_koji_module.ClientSession(sec_koji_module.config.server, session_opts)

  if os.path.isfile(CLIENTCERT):

      seckojisession.ssl_login(CLIENTCERT, CLIENTCA, SERVERCA)

  else:

KOJIHUB = '%s-koji' % (args.arch)

probably should use the fedora profile here

lets make the koji profile to use be a command line option

we should make the secondarykoji instance be a command like flag

use the fedora profile

default to fedora but make a command line flag

self.kojihub = '%s-koji' % (args.arch)

rebased

7 years ago

the secondary arch koji profiles are just teh arch not arch-koji

rebased

7 years ago

rebased

7 years ago

rebased

7 years ago

This is primarily run as part of the compose process. and the fedora profile does not have the releng keytab available. there is a compose_koji profile in use on the compose boxes, however a way to run it locally would be good

rebased

7 years ago

Pull-Request has been merged by ausil

7 years ago