#!/usr/bin/python import koji import optparse # cli/koji -c ~/.koji/config-mead call --python makeTask '"vmExec"' '["Win2k8-x86-vstudio-devel", ["wget -q -O /tmp/test-build.sh http://download.lab.bos.redhat.com/devel/mikeb/mead/debug/test-build.sh && chmod 755 /tmp/test-build.sh && /tmp/test-build.sh &> /tmp/output/build.log && echo build successful"], {"cpus": 2, "mem": 2048}]' --kwargs '{"channel": "vm"}' parser = optparse.OptionParser('%prog VM-NAME SCM-URL TARGET') parser.add_option('--server', help='Koji hub') parser.add_option('--cert', help='Client certificate') parser.add_option('--ca', help='Client CA') parser.add_option('--server-ca', help='Server CA') parser.add_option('--cpus', help='Number of virtual CPUs to allocate to the VM (optional)', type='int') parser.add_option('--mem', help='Amount of memory (in megabytes) to allocate to the VM (optional)', type='int') parser.add_option('--channel', help='Channel to create the task in', default='vm') parser.add_option('--specfile', help='Alternate SCM URL of the specfile') parser.add_option('--patches', help='SCM URL of patches to apply before build') parser.add_option('--scratch', help='Run a scratch build', action='store_true') opts, args = parser.parse_args() if len(args) < 3: parser.error('You must specify a VM name, a SCM URL, and a build target') vm_name = args[0] scm_url = args[1] target = args[2] session = koji.ClientSession(opts.server) session.ssl_login(opts.cert, opts.ca, opts.server_ca) task_opts = {} if opts.cpus: task_opts['cpus'] = opts.cpus if opts.mem: task_opts['mem'] = opts.mem if opts.specfile: task_opts['specfile'] = opts.specfile if opts.patches: task_opts['patches'] = opts.patches if opts.scratch: task_opts['scratch'] = True params = [vm_name, scm_url, target, task_opts] task_id = session.makeTask('winbuild', params, channel=opts.channel) print 'Created task %s' % task_id