1
0
mirror of https://github.com/openSUSE/osc.git synced 2025-09-07 05:38:43 +02:00

added commands for constraints/worker checking

This commit is contained in:
Marco Strigl
2016-12-29 12:46:07 +01:00
parent 9fffefb2d2
commit 4893049312
3 changed files with 116 additions and 5 deletions

32
dist/osc.complete vendored
View File

@@ -59,7 +59,7 @@ oscopts=(--version --help --debugger --post-mortem --traceback --http-full-debug
--debug --apiurl -A --config -c --no-keyring --no-gnome-keyring --verbose --quiet)
osccmds=(abortbuild add addremove aggregatepac api ar bco bl blt branch branchco
bsdevelproject bse bugowner build buildconfig buildhist buildhistory buildinfo
buildlog buildlogtail cat changedevelreq changedevelrequest checkin checkout
buildlog buildlogtail cat changedevelreq changedevelrequest checkconstraints checkin checkout
chroot ci co commit config copypac cr createincident createrequest creq del
delete deletereq deleterequest dependson detachbranch develproject di diff
distributions dists dr dropreq droprequest getbinaries getpac help importsrcpkg
@@ -73,7 +73,7 @@ osccmds=(abortbuild add addremove aggregatepac api ar bco bl blt branch branchco
resolved results revert review rm rq rremove se search service setlinkrev
signkey sm sr st status submitpac submitreq submitrequest tr triggerreason
undelete unlock up update updatepacmetafromspec user vc whatdependson who whois
wipebinaries)
wipebinaries workerinfo)
oscreq=(list log show accept decline revoke reopen setincident supersede approvenew
checkout clone)
oscrev=(show list add accept decline reopen supersede)
@@ -1396,7 +1396,7 @@ maintainer)
opts=(--help --role --delete --set-bugowner-request --set-bugowner --all --add
--devel-project --verbose --nodevelproject --email --bugowner --bugowner-only)
if ((count == 1)) ; then
builtin compgen -W "${osccmds[*]}" -- "${cmdline[count]}"
builtin compgen -W "${osccmds[*]}" -- "${cmdline[count]}"
elif ((count >= 2)) ; then
for ((off=2; off<=count; off++)) ; do
while test "${cmdline[off+remove]::1}" = "-" ; do
@@ -1812,6 +1812,30 @@ diff|linkdiff)
builtin compgen -W "${opts[*]}" -- "${cmdline[count]}"
fi
;;
workerinfo)
opts=(--help)
if ((count == 1)) ; then
builtin compgen -W "${osccmds[*]} ${oscopts[*]}" -- "${cmdline[count]}"
elif ((count >= 2)) ; then
if test "${cmdline[count]::1}" = "-" ; then
builtin compgen -W "${opts[*]}" -- "${cmdline[count]}"
else
targets ${opts[*]} -- "${cmdline[count]}"
fi
fi
;;
checkconstraints)
opts=(--help --ignore-file)
if ((count == 1)) ; then
builtin compgen -W "${osccmds[*]} ${oscopts[*]}" -- "${cmdline[count]}"
elif ((count >= 2)) ; then
if test "${cmdline[count]::1}" = "-" ; then
builtin compgen -W "${opts[*]}" -- "${cmdline[count]}"
else
targets ${opts[*]} -- "${cmdline[count]}"
fi
fi
;;
*)
opts=(--help)
if ((count == 1)) ; then
@@ -1822,5 +1846,5 @@ diff|linkdiff)
else
targets ${opts[*]} -- "${cmdline[count]}"
fi
fi
fi
esac

View File

@@ -5617,6 +5617,74 @@ Please submit there instead, or use --nodevelproject to force direct submission.
print(''.join(get_buildconfig(apiurl, project, repository)))
def do_workerinfo(self, subcmd, opts, worker):
"""${cmd_name}: gets the information to a worker from the server
Examples:
osc workerinfo <workername>
${cmd_usage}
${cmd_option_list}
"""
apiurl = self.get_api_url()
print(''.join(get_worker_info(apiurl, worker)))
@cmdln.option('', '--ignore-file', action='store_true',
help='ignore _constraints file and only check project constraints')
def do_checkconstraints(self, subcmd, opts, *args):
"""${cmd_name}: check the constraints and view compliant workers
Checks the constraints for compliant workers.
usage:
in a package working copy:
osc checkconstraints [OPTS] REPOSITORY ARCH CONSTRAINTSFILE
osc checkconstraints [OPTS] CONSTRAINTSFILE
osc checkconstraints [OPTS]
${cmd_option_list}
"""
repository = arch = constraintsfile = None
project = store_read_project('.')
package = store_read_package('.')
if len(args) == 1:
constraintsfile = args[0]
elif len(args) == 2 or len(args) == 3:
repository = args[0]
arch = args[1]
if len(args) == 3:
constraintsfile = args[2]
constraintsfile_data = None
if constraintsfile is not None:
constraintsfile_data = open(constraintsfile, 'r').read()
elif not opts.ignore_file:
if os.path.isfile("_constraints"):
constraintsfile_data = open("_constraints", 'r').read()
else:
print("No local _constraints file. Using just the project constraints")
apiurl = self.get_api_url()
r = []
if not arch and not repository:
result_line_templ = '%(name)-25s %(arch)-25s %(comp_workers)s'
for repo in get_repos_of_project(apiurl, project):
rmap = {}
rmap['name'] = repo.name
rmap['arch'] = repo.arch
workers = check_constraints(apiurl, project, repo.name, repo.arch, package, constraintsfile_data)
rmap['comp_workers'] = len(workers)
r.append(result_line_templ % rmap)
r.insert(0, 'Repository Arch Worker')
r.insert(1, '---------- ---- ------')
else:
r = check_constraints(apiurl, project, repository, arch, package, constraintsfile_data)
r.insert(0, 'Worker')
r.insert(1, '------')
print('\n'.join(r))
@cmdln.alias('repos')
@cmdln.alias('platforms')
def do_repositories(self, subcmd, opts, *args):

View File

@@ -5894,7 +5894,26 @@ def get_buildconfig(apiurl, prj, repository):
f = http_GET(u)
return f.read()
def get_worker_info(apiurl, worker):
u = makeurl(apiurl, ['worker', worker])
f = http_GET(u)
return f.read()
def check_constraints(apiurl, prj, repository, arch, package, constraintsfile=None):
query = {'cmd': 'checkconstraints'}
query['project'] = prj
query['package'] = package
query['repository'] = repository
query['arch'] = arch
u = makeurl(apiurl, ['worker'], query)
f = http_POST(u, data=constraintsfile)
root = ET.fromstring(''.join(f))
return [node.get('name') for node in root.findall('entry')]
def get_source_rev(apiurl, project, package, revision=None):
# API supports ?deleted=1&meta=1&rev=4
# but not rev=current,rev=latest,rev=top, or anything like this.