Hello,
I am using koji version 1.16.2 for centos 7 and I'm having issues getting the following code to succeed:
################################################
import sys import logging
import koji from koji.plugin import callback
koji_hub_path = '/usr/share/koji-hub' sys.path.insert(0, koji_hub_path) import kojihub
logger = logging.getLogger('koji.plugins')
@callback('postTag') def mycallback(cbtype, *args, **kwargs): # Get the tag name from the buildroot map opts = {} taskOpts = {} tag = kwargs['tag']['name'] keys = None repo_id = 3 taskOpts['priority'] = koji.PRIO_DEFAULT taskOpts['channel'] = 'createrepo' taskOpts['owner'] = 3 #This is the kojiadmin account taskOpts['arch'] = 'x86_64' opts['tag'] = tag opts['keys'] = keys opts['allow_missing_signatures'] = True opts['skip_missing_signatures'] = True opts['latest'] = True
if tag == 'local7': logging.getLogger('koji.plugin.mycallback').error('Executing mycallback.') print 'Variable dump: ', args print 'Expected tag is local7. mytag is: ', tag print 'Starting dist repo generator for %s...' % tag
return kojihub.make_task('distRepo', [tag, keys], **taskOpts)
The above code always fails with the following exception:
koji.hub: Cannot parse parameters: ['local7', None] of distRepo task
Is make_task the correct function to call in this instance? What should the arguments passed to make_task look like?
Regards,
Robby
Hmm, if you're calling it from inside hub, you need to replicate what distRepo API call [1] does. Your code is failing, because you don't send all required parameters make_task('distRepo', [tag, repo_id, keys, opts], **taskOpts).
Second option - safer, would be to use API directly (if you don't care about task owner rewrite, or arch pinning (taskOpts)). so api = kojihub.RootExports() api.distRepo(tag, keys, **opts)
[1] https://pagure.io/koji/blob/master/f/hub/kojihub.py#10580
čt 25. 4. 2019 v 0:36 odesílatel Robert Callicotte rcallicotte@gmail.com napsal:
Hello,
I am using koji version 1.16.2 for centos 7 and I'm having issues getting the following code to succeed:
################################################
import sys import logging
import koji from koji.plugin import callback
koji_hub_path = '/usr/share/koji-hub' sys.path.insert(0, koji_hub_path) import kojihub
logger = logging.getLogger('koji.plugins')
@callback('postTag') def mycallback(cbtype, *args, **kwargs): # Get the tag name from the buildroot map opts = {} taskOpts = {} tag = kwargs['tag']['name'] keys = None repo_id = 3 taskOpts['priority'] = koji.PRIO_DEFAULT taskOpts['channel'] = 'createrepo' taskOpts['owner'] = 3 #This is the kojiadmin account taskOpts['arch'] = 'x86_64' opts['tag'] = tag opts['keys'] = keys opts['allow_missing_signatures'] = True opts['skip_missing_signatures'] = True opts['latest'] = True
if tag == 'local7': logging.getLogger('koji.plugin.mycallback').error('Executing
mycallback.') print 'Variable dump: ', args print 'Expected tag is local7. mytag is: ', tag print 'Starting dist repo generator for %s...' % tag
return kojihub.make_task('distRepo', [tag, keys], **taskOpts)
The above code always fails with the following exception:
koji.hub: Cannot parse parameters: ['local7', None] of distRepo task
Is make_task the correct function to call in this instance? What should the arguments passed to make_task look like?
Regards,
Robby _______________________________________________ buildsys mailing list -- buildsys@lists.fedoraproject.org To unsubscribe send an email to buildsys-leave@lists.fedoraproject.org Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/buildsys@lists.fedoraproject.o...
Thank you for your reply.
I feel like I am very close to getting this to work using the make_task option. The only two things that I don't fully understand are how to programatically pull the event (option in distRepo) and the repo_id. How would I pull the event id (I'm assuming it is the task return id from my initial tag-build call)? Since I already know the tag name how would I find the corresponding repo_id?
I appreciate your help thus far.
-Robby
Just call dist_repo_init - it returns exactly these two values. For details look at [1]
[1] https://pagure.io/koji/blob/master/f/hub/kojihub.py#_10583
čt 25. 4. 2019 v 15:57 odesílatel Robert Callicotte rcallicotte@gmail.com napsal:
Thank you for your reply.
I feel like I am very close to getting this to work using the make_task option. The only two things that I don't fully understand are how to programatically pull the event (option in distRepo) and the repo_id. How would I pull the event id (I'm assuming it is the task return id from my initial tag-build call)? Since I already know the tag name how would I find the corresponding repo_id?
I appreciate your help thus far.
-Robby _______________________________________________ buildsys mailing list -- buildsys@lists.fedoraproject.org To unsubscribe send an email to buildsys-leave@lists.fedoraproject.org Fedora Code of Conduct: https://getfedora.org/code-of-conduct.html List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedoraproject.org/archives/list/buildsys@lists.fedoraproject.o...
Thanks for you help that did the trick! Here is the working code snippet:
if tag == 'local7-testing': logging.getLogger('koji.plugin.mycallback').error('Executing mycallback.') print 'Expected tag is local7-testing. mytag is: ', tag print 'Starting dist repo generator for %s...' % tag repo_id, event_id = kojihub.dist_repo_init(tag, keys, taskOpts) opts['event'] = event_id
return kojihub.make_task('distRepo', [tag, repo_id, keys, opts], **taskOpts)
buildsys@lists.fedoraproject.org