don't remove prj meta when freezing
- Preserve title and description of the frozen prj (issue 1585) - add a small stagingapi wrapper for makeurl, makes the code easier to read - url = makeurl(self.apiurl, ... + url = self.makeurl(... - don't freeze AGGR (issue 1611)
This commit is contained in:
parent
1d37f18903
commit
1acb0e509b
@ -198,7 +198,8 @@ def do_staging(self, subcmd, opts, *args):
|
|||||||
self._staging_submit_devel(project, opts)
|
self._staging_submit_devel(project, opts)
|
||||||
elif cmd in ['freeze']:
|
elif cmd in ['freeze']:
|
||||||
import osclib.freeze_command
|
import osclib.freeze_command
|
||||||
osclib.freeze_command.FreezeCommand(opts.apiurl).perform(api.prj_from_letter(args[1]))
|
for prj in args[1:]:
|
||||||
|
osclib.freeze_command.FreezeCommand(api).perform(api.prj_from_letter(prj))
|
||||||
elif cmd in ['accept']:
|
elif cmd in ['accept']:
|
||||||
import osclib.accept_command
|
import osclib.accept_command
|
||||||
osclib.accept_command.AcceptCommand(api).perform(api.prj_from_letter(args[1]))
|
osclib.accept_command.AcceptCommand(api).perform(api.prj_from_letter(args[1]))
|
||||||
|
@ -5,11 +5,11 @@ import time
|
|||||||
|
|
||||||
class FreezeCommand:
|
class FreezeCommand:
|
||||||
|
|
||||||
def __init__(self, apiurl):
|
def __init__(self, api):
|
||||||
self.apiurl = apiurl
|
self.api = api
|
||||||
|
|
||||||
def set_links(self):
|
def set_links(self):
|
||||||
url = makeurl(self.apiurl, ['source', self.prj, '_meta'])
|
url = self.api.makeurl(['source', self.prj, '_meta'])
|
||||||
f = http_GET(url)
|
f = http_GET(url)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
sources = dict()
|
sources = dict()
|
||||||
@ -21,16 +21,23 @@ class FreezeCommand:
|
|||||||
self.projectlinks.append(link.get('project'))
|
self.projectlinks.append(link.get('project'))
|
||||||
|
|
||||||
def set_bootstrap_copy(self):
|
def set_bootstrap_copy(self):
|
||||||
url = makeurl(self.apiurl, ['source', self.prj, '_meta'])
|
url = self.api.makeurl(['source', self.prj, '_meta'])
|
||||||
meta = self.prj_meta_for_bootstrap_copy(self.prj)
|
|
||||||
http_PUT(url, data=meta)
|
f = http_GET(url)
|
||||||
|
oldmeta = ET.parse(f).getroot()
|
||||||
|
|
||||||
|
meta = ET.fromstring(self.prj_meta_for_bootstrap_copy(self.prj))
|
||||||
|
meta.find('title').text = oldmeta.find('title').text
|
||||||
|
meta.find('description').text = oldmeta.find('description').text
|
||||||
|
|
||||||
|
http_PUT(url, data=ET.tostring(meta))
|
||||||
|
|
||||||
def create_bootstrap_aggregate(self):
|
def create_bootstrap_aggregate(self):
|
||||||
self.create_bootstrap_aggregate_meta()
|
self.create_bootstrap_aggregate_meta()
|
||||||
self.create_bootstrap_aggregate_file()
|
self.create_bootstrap_aggregate_file()
|
||||||
|
|
||||||
def bootstrap_packages(self):
|
def bootstrap_packages(self):
|
||||||
url = makeurl(self.apiurl, ['source', 'openSUSE:Factory:Rings:0-Bootstrap'])
|
url = self.api.makeurl(['source', 'openSUSE:Factory:Rings:0-Bootstrap'])
|
||||||
f = http_GET(url)
|
f = http_GET(url)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
l = list()
|
l = list()
|
||||||
@ -42,7 +49,7 @@ class FreezeCommand:
|
|||||||
return l
|
return l
|
||||||
|
|
||||||
def create_bootstrap_aggregate_file(self):
|
def create_bootstrap_aggregate_file(self):
|
||||||
url = makeurl(self.apiurl, ['source', self.prj, 'bootstrap-copy', '_aggregate'])
|
url = self.api.makeurl(['source', self.prj, 'bootstrap-copy', '_aggregate'])
|
||||||
|
|
||||||
root = ET.Element('aggregatelist')
|
root = ET.Element('aggregatelist')
|
||||||
a = ET.SubElement(root, 'aggregate', { 'project': "openSUSE:Factory:Rings:0-Bootstrap" } )
|
a = ET.SubElement(root, 'aggregate', { 'project': "openSUSE:Factory:Rings:0-Bootstrap" } )
|
||||||
@ -58,7 +65,7 @@ class FreezeCommand:
|
|||||||
http_PUT(url, data=ET.tostring(root))
|
http_PUT(url, data=ET.tostring(root))
|
||||||
|
|
||||||
def create_bootstrap_aggregate_meta(self):
|
def create_bootstrap_aggregate_meta(self):
|
||||||
url = makeurl(self.apiurl, ['source', self.prj, 'bootstrap-copy', '_meta'])
|
url = self.api.makeurl(['source', self.prj, 'bootstrap-copy', '_meta'])
|
||||||
|
|
||||||
root = ET.Element('package', { 'project': self.prj, 'name': 'bootstrap-copy' })
|
root = ET.Element('package', { 'project': self.prj, 'name': 'bootstrap-copy' })
|
||||||
ET.SubElement(root, 'title')
|
ET.SubElement(root, 'title')
|
||||||
@ -72,7 +79,7 @@ class FreezeCommand:
|
|||||||
http_PUT(url, data=ET.tostring(root))
|
http_PUT(url, data=ET.tostring(root))
|
||||||
|
|
||||||
def build_switch_bootstrap_copy(self, state):
|
def build_switch_bootstrap_copy(self, state):
|
||||||
url = makeurl(self.apiurl, ['source', self.prj, 'bootstrap-copy', '_meta'])
|
url = self.api.makeurl(['source', self.prj, 'bootstrap-copy', '_meta'])
|
||||||
pkgmeta = ET.parse(http_GET(url)).getroot()
|
pkgmeta = ET.parse(http_GET(url)).getroot()
|
||||||
|
|
||||||
for f in pkgmeta.find('build'):
|
for f in pkgmeta.find('build'):
|
||||||
@ -82,17 +89,15 @@ class FreezeCommand:
|
|||||||
http_PUT(url, data=ET.tostring(pkgmeta))
|
http_PUT(url, data=ET.tostring(pkgmeta))
|
||||||
|
|
||||||
def verify_bootstrap_copy_code(self, code):
|
def verify_bootstrap_copy_code(self, code):
|
||||||
url = makeurl(self.apiurl, ['build', self.prj, '_result'], { 'package': 'bootstrap-copy' })
|
url = self.api.makeurl(['build', self.prj, '_result'], { 'package': 'bootstrap-copy' })
|
||||||
|
|
||||||
root = ET.parse(http_GET(url)).getroot()
|
root = ET.parse(http_GET(url)).getroot()
|
||||||
for result in root.findall('result'):
|
for result in root.findall('result'):
|
||||||
if result.get('repository') == 'bootstrap_copy':
|
if result.get('repository') == 'bootstrap_copy':
|
||||||
if not result.get('code') in ['published', 'unpublished']:
|
if not result.get('code') in ['published', 'unpublished']:
|
||||||
print(ET.tostring(result))
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if result.find('status').get('code') != code:
|
if result.find('status').get('code') != code:
|
||||||
print(ET.tostring(result))
|
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@ -159,11 +164,11 @@ class FreezeCommand:
|
|||||||
fl = ET.SubElement(flink, 'frozenlink', { 'project': lprj } )
|
fl = ET.SubElement(flink, 'frozenlink', { 'project': lprj } )
|
||||||
sources = self.receive_sources(lprj, sources, fl)
|
sources = self.receive_sources(lprj, sources, fl)
|
||||||
|
|
||||||
url = makeurl(self.apiurl, ['source', self.prj, '_project', '_frozenlinks'], { 'meta': '1' } )
|
url = self.api.makeurl(['source', self.prj, '_project', '_frozenlinks'], { 'meta': '1' } )
|
||||||
http_PUT(url, data=ET.tostring(flink))
|
http_PUT(url, data=ET.tostring(flink))
|
||||||
|
|
||||||
def receive_sources(self, prj, sources, flink):
|
def receive_sources(self, prj, sources, flink):
|
||||||
url = makeurl(self.apiurl, ['source', prj], { 'view': 'info', 'nofilename': '1' } )
|
url = self.api.makeurl(['source', prj], { 'view': 'info', 'nofilename': '1' } )
|
||||||
f = http_GET(url)
|
f = http_GET(url)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
|
|
||||||
@ -181,12 +186,14 @@ class FreezeCommand:
|
|||||||
for linked in si.findall('linked'):
|
for linked in si.findall('linked'):
|
||||||
if linked.get('project') in self.projectlinks:
|
if linked.get('project') in self.projectlinks:
|
||||||
# take the unexpanded md5 from Factory link
|
# take the unexpanded md5 from Factory link
|
||||||
url = makeurl(self.apiurl, ['source', 'openSUSE:Factory', package], { 'view': 'info', 'nofilename': '1' })
|
url = self.api.makeurl(['source', 'openSUSE:Factory', package], { 'view': 'info', 'nofilename': '1' })
|
||||||
#print(package, linked.get('package'), linked.get('project'))
|
#print(package, linked.get('package'), linked.get('project'))
|
||||||
f = http_GET(url)
|
f = http_GET(url)
|
||||||
proot = ET.parse(f).getroot()
|
proot = ET.parse(f).getroot()
|
||||||
ET.SubElement(flink, 'package', { 'name': package, 'srcmd5': proot.get('lsrcmd5'), 'vrev': si.get('vrev') })
|
ET.SubElement(flink, 'package', { 'name': package, 'srcmd5': proot.get('lsrcmd5'), 'vrev': si.get('vrev') })
|
||||||
return package
|
return package
|
||||||
|
if package in ['rpmlint-mini-AGGR']:
|
||||||
|
return package # we should not freeze aggregates
|
||||||
ET.SubElement(flink, 'package', { 'name': package, 'srcmd5': si.get('srcmd5'), 'vrev': si.get('vrev') })
|
ET.SubElement(flink, 'package', { 'name': package, 'srcmd5': si.get('srcmd5'), 'vrev': si.get('vrev') })
|
||||||
return package
|
return package
|
||||||
|
|
||||||
|
@ -41,6 +41,13 @@ class StagingAPI(object):
|
|||||||
self.ring_packages = self._generate_ring_packages()
|
self.ring_packages = self._generate_ring_packages()
|
||||||
|
|
||||||
|
|
||||||
|
def makeurl(self, l, query=[]):
|
||||||
|
"""
|
||||||
|
Wrapper around osc's makeurl passing our apiurl
|
||||||
|
:return url made for l and query
|
||||||
|
"""
|
||||||
|
return makeurl(self.apiurl, l, query)
|
||||||
|
|
||||||
def _generate_ring_packages(self):
|
def _generate_ring_packages(self):
|
||||||
"""
|
"""
|
||||||
Generate dictionary with names of the rings
|
Generate dictionary with names of the rings
|
||||||
@ -50,7 +57,7 @@ class StagingAPI(object):
|
|||||||
ret = {}
|
ret = {}
|
||||||
|
|
||||||
for prj in self.rings:
|
for prj in self.rings:
|
||||||
url = makeurl(self.apiurl, ['source', prj])
|
url = self.makeurl( ['source', prj])
|
||||||
root = http_GET(url)
|
root = http_GET(url)
|
||||||
for entry in ET.parse(root).getroot().findall('entry'):
|
for entry in ET.parse(root).getroot().findall('entry'):
|
||||||
ret[entry.attrib['name']] = prj
|
ret[entry.attrib['name']] = prj
|
||||||
@ -68,7 +75,7 @@ class StagingAPI(object):
|
|||||||
|
|
||||||
package_info = {}
|
package_info = {}
|
||||||
|
|
||||||
url = makeurl(self.apiurl, ['source', project, pkgname])
|
url = self.makeurl( ['source', project, pkgname])
|
||||||
content = http_GET(url)
|
content = http_GET(url)
|
||||||
root = ET.parse(content).getroot().find('linkinfo')
|
root = ET.parse(content).getroot().find('linkinfo')
|
||||||
package_info['srcmd5'] = root.attrib['srcmd5']
|
package_info['srcmd5'] = root.attrib['srcmd5']
|
||||||
@ -110,7 +117,7 @@ class StagingAPI(object):
|
|||||||
|
|
||||||
projects = []
|
projects = []
|
||||||
|
|
||||||
url = makeurl(self.apiurl, ['search', 'project',
|
url = self.makeurl( ['search', 'project',
|
||||||
'id?match=starts-with(@name,\'openSUSE:Factory:Staging:\')'])
|
'id?match=starts-with(@name,\'openSUSE:Factory:Staging:\')'])
|
||||||
projxml = http_GET(url)
|
projxml = http_GET(url)
|
||||||
root = ET.parse(projxml).getroot()
|
root = ET.parse(projxml).getroot()
|
||||||
@ -139,7 +146,7 @@ class StagingAPI(object):
|
|||||||
if by_user: query['by_user'] = by_user
|
if by_user: query['by_user'] = by_user
|
||||||
if by_project: query['by_project'] = by_project
|
if by_project: query['by_project'] = by_project
|
||||||
|
|
||||||
url = makeurl(self.apiurl, ['request', str(request_id)], query=query)
|
url = self.makeurl( ['request', str(request_id)], query=query)
|
||||||
f = http_POST(url, data=message)
|
f = http_POST(url, data=message)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
return root.attrib.get('code', '500')
|
return root.attrib.get('code', '500')
|
||||||
@ -187,7 +194,7 @@ class StagingAPI(object):
|
|||||||
# xpath query, using the -m, -r, -s options
|
# xpath query, using the -m, -r, -s options
|
||||||
where = "@by_group='factory-staging'+and+@state='new'"
|
where = "@by_group='factory-staging'+and+@state='new'"
|
||||||
|
|
||||||
url = makeurl(self.apiurl, ['search','request'], "match=state/@name='review'+and+review["+where+"]")
|
url = self.makeurl( ['search','request'], "match=state/@name='review'+and+review["+where+"]")
|
||||||
f = http_GET(url)
|
f = http_GET(url)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
|
|
||||||
@ -354,7 +361,7 @@ class StagingAPI(object):
|
|||||||
ET.SubElement(elm, 'disable')
|
ET.SubElement(elm, 'disable')
|
||||||
dst_meta = ET.tostring(root)
|
dst_meta = ET.tostring(root)
|
||||||
|
|
||||||
url = makeurl(self.apiurl, ['source', project, package, '_meta'] )
|
url = self.makeurl( ['source', project, package, '_meta'] )
|
||||||
http_PUT(url, data=dst_meta)
|
http_PUT(url, data=dst_meta)
|
||||||
|
|
||||||
def check_one_request(self, request, project):
|
def check_one_request(self, request, project):
|
||||||
@ -365,7 +372,7 @@ class StagingAPI(object):
|
|||||||
:param request_id: request id to check
|
:param request_id: request id to check
|
||||||
"""
|
"""
|
||||||
|
|
||||||
f = http_GET(makeurl(self.apiurl, ['request', str(request)]))
|
f = http_GET(self.makeurl( ['request', str(request)]))
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
|
|
||||||
# relevant info for printing
|
# relevant info for printing
|
||||||
@ -445,7 +452,7 @@ class StagingAPI(object):
|
|||||||
Checks the openqa state of the project
|
Checks the openqa state of the project
|
||||||
:param project: project to check
|
:param project: project to check
|
||||||
"""
|
"""
|
||||||
u = makeurl(self.apiurl, ['build', project, 'images', 'x86_64', 'Test-DVD-x86_64'])
|
u = self.makeurl( ['build', project, 'images', 'x86_64', 'Test-DVD-x86_64'])
|
||||||
f = http_GET(u)
|
f = http_GET(u)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
|
|
||||||
@ -491,7 +498,7 @@ class StagingAPI(object):
|
|||||||
:param project: project to check
|
:param project: project to check
|
||||||
"""
|
"""
|
||||||
# Get build results
|
# Get build results
|
||||||
u = makeurl(self.apiurl, ['build', project, '_result'])
|
u = self.makeurl( ['build', project, '_result'])
|
||||||
f = http_GET(u)
|
f = http_GET(u)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
|
|
||||||
@ -578,7 +585,7 @@ class StagingAPI(object):
|
|||||||
# create build disabled package
|
# create build disabled package
|
||||||
self.create_package_container(project, tar_pkg, disable_build=True)
|
self.create_package_container(project, tar_pkg, disable_build=True)
|
||||||
# now trigger wipebinaries to emulate a delete
|
# now trigger wipebinaries to emulate a delete
|
||||||
url = makeurl(self.apiurl, ['build', project], { 'cmd': 'wipe', 'package': tar_pkg } )
|
url = self.makeurl( ['build', project], { 'cmd': 'wipe', 'package': tar_pkg } )
|
||||||
http_POST(url)
|
http_POST(url)
|
||||||
|
|
||||||
return tar_pkg
|
return tar_pkg
|
||||||
@ -601,7 +608,7 @@ class StagingAPI(object):
|
|||||||
self.create_package_container(project, tar_pkg, disable_build=disable_build)
|
self.create_package_container(project, tar_pkg, disable_build=disable_build)
|
||||||
|
|
||||||
# expand the revision to a md5
|
# expand the revision to a md5
|
||||||
url = makeurl(self.apiurl, ['source', src_prj, src_pkg], { 'rev': src_rev, 'expand': 1 })
|
url = self.makeurl( ['source', src_prj, src_pkg], { 'rev': src_rev, 'expand': 1 })
|
||||||
f = http_GET(url)
|
f = http_GET(url)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
src_rev = root.attrib['srcmd5']
|
src_rev = root.attrib['srcmd5']
|
||||||
@ -611,7 +618,7 @@ class StagingAPI(object):
|
|||||||
root = ET.Element('link', package=src_pkg, project=src_prj, rev=src_rev)
|
root = ET.Element('link', package=src_pkg, project=src_prj, rev=src_rev)
|
||||||
if src_vrev:
|
if src_vrev:
|
||||||
root.attrib['vrev'] = src_vrev
|
root.attrib['vrev'] = src_vrev
|
||||||
url = makeurl(self.apiurl, ['source', project, tar_pkg, '_link'])
|
url = self.makeurl( ['source', project, tar_pkg, '_link'])
|
||||||
http_PUT(url, data=ET.tostring(root))
|
http_PUT(url, data=ET.tostring(root))
|
||||||
return tar_pkg
|
return tar_pkg
|
||||||
|
|
||||||
@ -623,7 +630,7 @@ class StagingAPI(object):
|
|||||||
def list_requests_in_prj(self, project):
|
def list_requests_in_prj(self, project):
|
||||||
where = "@by_project='%s'+and+@state='new'" % project
|
where = "@by_project='%s'+and+@state='new'" % project
|
||||||
|
|
||||||
url = makeurl(self.apiurl, ['search','request', 'id'], "match=state/@name='review'+and+review["+where+"]")
|
url = self.makeurl( ['search','request', 'id'], "match=state/@name='review'+and+review["+where+"]")
|
||||||
f = http_GET(url)
|
f = http_GET(url)
|
||||||
root = ET.parse(f).getroot()
|
root = ET.parse(f).getroot()
|
||||||
list = []
|
list = []
|
||||||
@ -659,7 +666,7 @@ class StagingAPI(object):
|
|||||||
if len(query) == 0:
|
if len(query) == 0:
|
||||||
raise oscerr.WrongArgs("We need a group or a project")
|
raise oscerr.WrongArgs("We need a group or a project")
|
||||||
query['cmd'] = 'addreview'
|
query['cmd'] = 'addreview'
|
||||||
url = makeurl(self.apiurl, ['request', str(request_id)], query)
|
url = self.makeurl( ['request', str(request_id)], query)
|
||||||
http_POST(url, data=msg)
|
http_POST(url, data=msg)
|
||||||
|
|
||||||
def set_review(self, request_id, project, state='accepted'):
|
def set_review(self, request_id, project, state='accepted'):
|
||||||
@ -679,7 +686,7 @@ class StagingAPI(object):
|
|||||||
change_review_state(self.apiurl, str(request_id), state, by_project=project, message='Reviewed by staging project "{}" with result: "{}"'.format(project, state) )
|
change_review_state(self.apiurl, str(request_id), state, by_project=project, message='Reviewed by staging project "{}" with result: "{}"'.format(project, state) )
|
||||||
|
|
||||||
def build_switch_prj(self, prj, state):
|
def build_switch_prj(self, prj, state):
|
||||||
url = makeurl(self.apiurl, ['source', prj, '_meta'])
|
url = self.makeurl( ['source', prj, '_meta'])
|
||||||
prjmeta = ET.parse(http_GET(url)).getroot()
|
prjmeta = ET.parse(http_GET(url)).getroot()
|
||||||
|
|
||||||
foundone = False
|
foundone = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user