summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Bartosh <eduard.bartosh@intel.com>2014-05-09 22:16:37 +0300
committerEd Bartosh <eduard.bartosh@intel.com>2014-05-18 14:01:17 +0300
commit53852242b91bed291d90878579447798eb29b8d2 (patch)
tree22dfd80cbb36e2bca2aefc48ae767565cb0123d9
parent37ae4d1b58addc66d1cd446ecd08b729b286a56b (diff)
downloadrepa-53852242b91bed291d90878579447798eb29b8d2.tar.gz
repa-53852242b91bed291d90878579447798eb29b8d2.tar.bz2
repa-53852242b91bed291d90878579447798eb29b8d2.zip
Create one SR for all packages in submission
Currently repa creates one SR per package. This change implements creation of one SR per multiple packages by using new schema of POST /request API https://api.opensuse.org/apidocs/request.rng Note, that osc API doesn't support this schema, so it can't be used. Fixes: #1386 Change-Id: Iae5cb55b0b5f489b9596c5a79e0845ec18a2ba51 Signed-off-by: Ed Bartosh <eduard.bartosh@intel.com>
-rw-r--r--repa/common.py38
-rw-r--r--repa/obs.py31
2 files changed, 29 insertions, 40 deletions
diff --git a/repa/common.py b/repa/common.py
index 79d6ed7..51128e2 100644
--- a/repa/common.py
+++ b/repa/common.py
@@ -93,31 +93,19 @@ def accept_or_reject(obs, submission, state, target, comment=''):
meta['git_tag'],
commit)
- for pkg in obs.get_source_packages(project):
- # Create SR
- try:
- reqid = obs.create_sr(project, pkg, str(meta['obs_target_prj']),
- message=str(message))
- except RepaException:
- if state == 'declined':
- # Broken sources. Try to avoid queryng source by
- # providing revision 1. It always exists and it doesn't
- # matter which revision to reject.
- reqid = obs.create_sr(project, pkg,
- str(meta['obs_target_prj']),
- message=str(message), revision=1)
- else:
- raise
-
- print 'package %s: created SR %s' % (pkg, reqid)
-
- # and immediately set its state
- message = "SR %s is set to %s" % (reqid, state)
- if comment:
- message += comment
- obs.set_sr_state(reqid, state=state,
- message=str(message), force=True)
- print 'set SR state to', state
+ # Create SR
+ reqid = obs.create_sr(project, obs.get_source_packages(project),
+ str(meta['obs_target_prj']), message=message)
+
+ print 'created SR %s' % reqid
+
+ # and immediately set its state
+ message = "SR %s is set to %s" % (reqid, state)
+ if comment:
+ message += comment
+ obs.set_sr_state(reqid, state=state,
+ message=str(message), force=True)
+ print 'set SR state to', state
# delete submit group
if submission.startswith('submitgroup'):
diff --git a/repa/obs.py b/repa/obs.py
index 6227734..be052e7 100644
--- a/repa/obs.py
+++ b/repa/obs.py
@@ -35,6 +35,7 @@ should be contributed to oscapi.
import sys
import re
+import cgi
from base64 import b64encode
from xml.etree import cElementTree as ET
@@ -159,22 +160,22 @@ class OBS(OSC):
sys.stdout = saved
- def create_sr(self, src_project, package, dst_project,
- message='', revision=None):
+ def create_sr(self, src_project, packages, tgt_project, message=''):
"""Create submit request for the project."""
- rev = revision
- if not rev:
- url = core.makeurl(self.apiurl, ['source', src_project, package],
- query="expand=1")
- try:
- answer = self.core_http(core.http_GET, url)
- except OSCError, err:
- raise RepaException("cat't query source %s from "
- "project %s: %s" % (package, src_project, err))
- rev = ET.parse(answer).getroot().get('rev')
- return core.create_submit_request(self.apiurl, src_project, package,
- dst_project, package, message=message,
- orev=rev)
+
+ content = '<request><description>%s</description>' % \
+ cgi.escape(str(message))
+ for package in packages:
+ content += '<action type="submit">'
+ content += '<source project="%s" package="%s"/>' % \
+ (src_project, package)
+ content += '<target project="%s" package="%s" />' % \
+ (tgt_project, package)
+ content += '</action>'
+ content += '</request>\n'
+ url = core.makeurl(self.apiurl, ['request'], query='cmd=create')
+ reply = self.core_http(core.http_POST, url, data=content)
+ return ET.parse(reply).getroot().get('id')
def set_sr_state(self, reqid, state, message='', force=False):
"""Set SR state."""