diff --git a/kojihub/kojihub.py b/kojihub/kojihub.py index 2581ea6e..509a4b83 100644 --- a/kojihub/kojihub.py +++ b/kojihub/kojihub.py @@ -605,7 +605,8 @@ def make_task(method, arglist, **opts): parent: the id of the parent task (creates a subtask) label: (subtasks only) the label of the subtask owner: the user_id that should own the task - channel: the channel to place the task in + channel: requested channel override + default_channel: default channel arch: the arch for the task priority: the priority of the task assign: a host_id to assign the task to @@ -672,9 +673,10 @@ def make_task(method, arglist, **opts): ruleset = context.policy.get('channel') result = ruleset.apply(policy_data) + default_channel = opts.get('default_channel', 'default') if result is None: - logger.warning('Channel policy returned no result, using default') - opts['channel_id'] = get_channel_id('default', strict=True) + logger.debug('Channel policy returned no result, using default') + opts['channel_id'] = get_channel_id(default_channel, strict=True) else: try: parts = result.split() @@ -696,6 +698,9 @@ def make_task(method, arglist, **opts): ruleset.last_rule()) raise koji.GenericError("invalid channel policy") opts['channel_id'] = req_channel_id + elif parts[0] == "default": + # note this is different from "use default" if default_channel is passed + opts['channel_id'] = get_channel_id(default_channel, strict=True) else: logger.error("Invalid result from channel policy: %s", ruleset.last_rule()) raise koji.GenericError("invalid channel policy") @@ -10904,7 +10909,7 @@ class RootExports(object): return make_task('chainbuild', [srcs, target, opts], **taskOpts) - def mavenBuild(self, url, target, opts=None, priority=None, channel='maven'): + def mavenBuild(self, url, target, opts=None, priority=None, channel=None): """Create a Maven build task url: The url to checkout the source from. May be a CVS, SVN, or GIT repository. @@ -10912,7 +10917,7 @@ class RootExports(object): priority: the amount to increase (or decrease) the task priority, relative to the default priority; higher values mean lower priority; only admins have the right to specify a negative priority here - channel: the channel to allocate the task to (defaults to the "maven" channel) + channel: override the channel to allocate the task to Returns the task ID """ @@ -10922,7 +10927,7 @@ class RootExports(object): convert_value(url, cast=str, check_only=True) if not opts: opts = {} - taskOpts = {} + taskOpts = {'default_channel': 'maven'} if priority: if priority < 0: if not context.session.hasPerm('admin'): @@ -10933,7 +10938,7 @@ class RootExports(object): return make_task('maven', [url, target, opts], **taskOpts) - def wrapperRPM(self, build, url, target, priority=None, channel='maven', opts=None): + def wrapperRPM(self, build, url, target, priority=None, channel=None, opts=None): """Create a top-level wrapperRPM task build: The build to generate wrapper rpms for. Must be in the COMPLETE state and have no @@ -10945,7 +10950,7 @@ class RootExports(object): priority: the amount to increase (or decrease) the task priority, relative to the default priority; higher values mean lower priority; only admins have the right to specify a negative priority here - channel: the channel to allocate the task to (defaults to the "maven" channel) + channel: override the channel to allocate the task to returns the task ID """ @@ -10968,18 +10973,19 @@ class RootExports(object): logger.warning('The wrapperRPM call ignores repo_id options') del opts['repo_id'] - taskOpts = {} + taskOpts = {'default_channel': 'maven'} if priority: if priority < 0: if not context.session.hasPerm('admin'): raise koji.ActionNotAllowed('only admins may create high-priority tasks') taskOpts['priority'] = koji.PRIO_DEFAULT + priority - convert_value(channel, cast=str, check_only=True) - taskOpts['channel'] = channel + if channel is not None: + convert_value(channel, cast=str, check_only=True) + taskOpts['channel'] = channel return make_task('wrapperRPM', [url, build_target, build, None, opts], **taskOpts) - def chainMaven(self, builds, target, opts=None, priority=None, channel='maven'): + def chainMaven(self, builds, target, opts=None, priority=None, channel=None): """Create a Maven chain-build task builds: a list of maps defining the parameters for the sequence of builds @@ -10987,7 +10993,7 @@ class RootExports(object): priority: the amount to increase (or decrease) the task priority, relative to the default priority; higher values mean lower priority; only admins have the right to specify a negative priority here - channel: the channel to allocate the task to (defaults to the "maven" channel) + channel: override the channel to allocate the task to Returns the task ID """ @@ -10995,7 +11001,7 @@ class RootExports(object): if not context.opts.get('EnableMaven'): raise koji.GenericError("Maven support not enabled") convert_value(builds, cast=dict, check_only=True) - taskOpts = {} + taskOpts = {'default_channel': 'maven'} if priority: if priority < 0: if not context.session.hasPerm('admin'): @@ -11006,7 +11012,7 @@ class RootExports(object): return make_task('chainmaven', [builds, target, opts], **taskOpts) - def winBuild(self, vm, url, target, opts=None, priority=None, channel='vm'): + def winBuild(self, vm, url, target, opts=None, priority=None, channel=None): """ Create a Windows build task @@ -11017,7 +11023,7 @@ class RootExports(object): priority: the amount to increase (or decrease) the task priority, relative to the default priority; higher values mean lower priority; only admins have the right to specify a negative priority here - channel: the channel to allocate the task to (defaults to the "vm" channel) + channel: override the channel to allocate the task to Returns the task ID """ @@ -11032,7 +11038,7 @@ class RootExports(object): assert_policy('vm', policy_data) if not opts: opts = {} - taskOpts = {} + taskOpts = {'default_channel': 'vm'} if priority: if priority < 0: if not context.session.hasPerm('admin'): @@ -11057,7 +11063,7 @@ class RootExports(object): context.session.assertPerm(img_type) - taskOpts = {'channel': img_type} + taskOpts = {'default_channel': img_type} if img_type == 'livemedia': taskOpts['arch'] = 'noarch' else: @@ -11079,7 +11085,7 @@ class RootExports(object): Create an image using two other images and an indirection template """ context.session.assertPerm('image') - taskOpts = {'channel': 'image'} + taskOpts = {'default_channel': 'image'} if priority: if priority < 0: if not context.session.hasPerm('admin'): @@ -11104,7 +11110,7 @@ class RootExports(object): for i in [name, inst_tree, version]: convert_value(i, cast=str, check_only=True) context.session.assertPerm('image') - taskOpts = {'channel': 'image'} + taskOpts = {'default_channel': 'image'} if priority: if priority < 0: if not context.session.hasPerm('admin'): @@ -13742,7 +13748,7 @@ class RootExports(object): logger.debug("Cancelling distRepo task %d" % task_id) Task(task_id).cancel(recurse=True) return make_task('distRepo', [tag, repo_id, keys, task_opts], - priority=15, channel='createrepo') + priority=15, default_channel='createrepo') def newRepo(self, tag, event=None, src=False, debuginfo=False, separate_src=False): """Create a newRepo task. returns task id""" @@ -13770,7 +13776,7 @@ class RootExports(object): if debuginfo: opts['debuginfo'] = True args = koji.encode_args(tag, **opts) - return make_task('newRepo', args, priority=15, channel='createrepo') + return make_task('newRepo', args, priority=15, default_channel='createrepo') def repoExpire(self, repo_id): """mark repo expired""" diff --git a/kojihub/kojixmlrpc.py b/kojihub/kojixmlrpc.py index e0dd0777..785fa364 100644 --- a/kojihub/kojixmlrpc.py +++ b/kojihub/kojixmlrpc.py @@ -630,7 +630,7 @@ _default_policies = { 'channel': ''' has req_channel :: req is_child_task :: parent - all :: use default + all :: default ''', 'vm': ''' has_perm admin win-admin :: allow