From 87b060e9a3273a24af0f1f8a37a3b2948bb32449 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Schr=C3=B6ter?= Date: Mon, 7 Mar 2011 11:46:51 +0100 Subject: [PATCH] - add "maintenancerequests" command to request a maintenance incident from maintenance team --- NEWS | 3 ++- osc/commandline.py | 64 ++++++++++++++++++++++++++++++++++++++++++++++ osc/core.py | 24 +++++++++++++++++ 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 3b751839..e337a978 100644 --- a/NEWS +++ b/NEWS @@ -14,7 +14,7 @@ (For example for doing a version update without creating a _service file: osc service lr update_source) - protect rebuild and abortbuild commands with required "--all" option to mass failures by accident (similar to wipebinaries) # -# Features which requires OBS 2.2 +# Features which requires OBS 2.3 # - "my requests" is doing faster and complete server side lookup now if available - "review" command has been extended to handle reviews by project or by package maintainers @@ -22,6 +22,7 @@ - support project wide source services - support for armv7hl architecuture. used to denote armv7 + hardfloat binaries - add force option to accept requests in review state. + - add "maintenancerequests" command to request a maintenance incident from maintenance team 0.130 - new "revert" command to restore the original working copy file (without diff --git a/osc/commandline.py b/osc/commandline.py index 149f4679..3746c56c 100644 --- a/osc/commandline.py +++ b/osc/commandline.py @@ -2330,6 +2330,70 @@ Please submit there instead, or use --nodevelproject to force direct submission. print r + @cmdln.option('-a', '--attribute', metavar='ATTRIBUTE', + help='Use this attribute to find default maintenance project (default is OBS:Maintenance)') + @cmdln.option('-m', '--message', metavar='TEXT', + help='specify message TEXT') + def do_maintenancerequest(self, subcmd, opts, *args): + """${cmd_name}: Create a request for starting a maintenance incident. + + [See http://doc.opensuse.org/products/draft/OBS/obs-reference-guide/cha.obs.maintenance_setup.html + for information on this topic.] + + This command is asking the maintence team to start a maintence incident based on a + created maintenance update. Please see the "mbranch" command on how to create such a project and + the "patchinfo" command how add the required maintenance update informations. + + usage: + osc maintenancerequest [ SOURCEPROJECT [ TARGETPROJECT ] ] + ${cmd_option_list} + """ + + args = slash_split(args) + apiurl = self.get_api_url() + attribute = "OBS:Maintenance" # default attribute as defined in api code. + if opts.attribute: + attribute = opts.attribute + + source_project = target_project = None + + if len(args) > 2: + raise oscerr.WrongArgs('Too many arguments.') + + if len(args) == 0: + if is_project_dir(os.getcwd()): + apiurl = self.get_api_url() + source_project = args[0] + if len(args) >= 2: + target_project = args[1] + else: + sys.exit('osc maintenancerequest needs a source project specified either via command line or as current directory\n') + + if len(args) > 0: + source_project = args[0] + + if len(args) > 1: + target_project = args[1] + else: + query = { "match": "attribute/@name='" + attribute + "'" } + u = makeurl(apiurl, ['search', 'project_id'], query) + f = http_GET(u) + root = ET.parse(f).getroot() + project = root.find("project") + target_project = project.get("name") + print target_project + if not target_project: + sys.exit('Unable to find defined OBS:Maintenance project on server.\n') + + if not opts.message: + opts.message = edit_message() + + result = create_maintenance_request(apiurl, source_project, target_project, opts.message) + if not result: + sys.exit("maintenance request creation failed") + print result + + @cmdln.option('-c', '--checkout', action='store_true', help='Checkout branched package afterwards ' \ '(\'osc bco\' is a shorthand for this option)' ) diff --git a/osc/core.py b/osc/core.py index 6397444d..5cc6fc8e 100644 --- a/osc/core.py +++ b/osc/core.py @@ -3468,6 +3468,30 @@ def clone_request(apiurl, reqid, msg=None): raise oscerr.APIError('invalid data from clone request:\n%s\n' % ET.tostring(root)) return project +# create a maintenance incident per request +def create_maintenance_request(apiurl, src_project, dst_project, message="" ): + import cgi + + xml = """\ + + + + + + + %s + +""" % (src_project, + dst_project, + cgi.escape(unicode(message, "utf8"))) + + u = makeurl(apiurl, ['request'], query='cmd=create') + f = http_POST(u, data=xml) + + root = ET.parse(f).getroot() + return root.get('id') + + # This creates an old style submit request for server api 1.0 def create_submit_request(apiurl, src_project, src_package,