From 15e407bdddb1c32f404c0ec955d279056e0c2d77 Mon Sep 17 00:00:00 2001 From: Ed Bartosh Date: Sun, 1 Feb 2015 21:07:32 +0200 Subject: Implement repa lock/unlock repa lock triggers re job on jenkins with action=lock. repa unlock triggers re job on jenkins with action=lock. Fixes: #2321 Change-Id: I9ce75d14056f1044986703454031b4d071cee07c Signed-off-by: Ed Bartosh --- repa.1 | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ repa/lock.py | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ repa/unlock.py | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.py | 4 +++- 4 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 repa/lock.py create mode 100644 repa/unlock.py diff --git a/repa.1 b/repa.1 index bbbe262..7650a85 100644 --- a/repa.1 +++ b/repa.1 @@ -49,6 +49,12 @@ Submission group is a temporary group of submissions, created for testing purpos .RS 2 8. \fBrebuild\fR - rebuild submission .RE +.RS 2 +9. \fBlock\fR - lock submission +.RE +.RS 2 +10. \fBunlock\fR - unlock submission +.RE .\" =========================================================================== .\" Global options @@ -393,6 +399,57 @@ Provide a comment with the explanation of a reason for rebuild. Mandatory option Rebuild only one package. .RE +.\" +.\" The "lock" command description +.\" +.SS \fBlock\fR [options] + +.RS 2 +Lock submission by triggering 're' Jenkins job. 're' job locks submission by disabling build in prerelease OBS project. + +.\" +.\" The "lock" command's options +.\" +.RS 2 +\fBOPTIONS\fR +.RS 2 +.B \-h, \-\-help +.RS 2 +Print short help text about the "lock" command and exit. +.RE + +.PP +.B \-c \-\-comment COMMENT +.RS 2 +Provide a comment with the explanation of a reason for lock. Mandatory option. +.RE + +.\" +.\" The "unlock" command description +.\" +.SS \fBunlock\fR [options] + +.RS 2 +Unlock submission by triggering 're' Jenkins job. 're' job unlocks submission by re-enabling build in prerelease OBS project. + +.\" +.\" The "unlock" command's options +.\" +.RS 2 +\fBOPTIONS\fR +.RS 2 +.B \-h, \-\-help +.RS 2 +Print short help text about the "unlock" command and exit. +.RE + +.PP +.B \-c \-\-comment COMMENT +.RS 2 +Provide a comment with the explanation of a reason for unlock. +.RE + + .SH CONFIGURATION FILE .RS 2 diff --git a/repa/lock.py b/repa/lock.py new file mode 100644 index 0000000..9edd966 --- /dev/null +++ b/repa/lock.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# +# This file is part of REPA: Release Engineering Process Assistant. +# +# Copyright (C) 2015 Intel Corporation +# +# REPA is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. + +""" +REPA: Release Engineering Process Assistant. + +Copyright (C) Intel Corporation 2015 +Licence: GPL version 2 +Author: Ed Bartosh + +Lock module. +Lock submissions. +""" + +import sys + +from collections import namedtuple + +from repa.main import sub_main +from repa.jenkins import trigger_build + +class Lock(object): + """Subcommand: lock submissions.""" + + name = 'lock' + description = 'Lock submission' + help = description + + @staticmethod + def add_arguments(parser, _): + """Adds arguments to the parser. Called from [sub_]main.""" + parser.add_argument('submission', help='submission') + parser.add_argument('-c', '--comment', help='comment', required=True) + + @staticmethod + def run(argv): + """Command line entry point. Called from [sub_]main.""" + job = 're' + cred = namedtuple('cred', ['url', 'username', 'password'])(\ + argv.jenkins_url, argv.jenkins_user, argv.jenkins_passwd) + build, status, out = \ + trigger_build(job, {'action': 'lock', + 'submission': argv.submission, + 'target_project': argv.project, + 'comment': argv.comment}, cred) + print "Jenkins job: %s, build #%s, status: %s" % (job, build, status) + print out + return status == 'SUCCESS' + +if __name__ == '__main__': + sys.exit(sub_main(sys.argv[1:], Lock())) diff --git a/repa/unlock.py b/repa/unlock.py new file mode 100644 index 0000000..47e0fec --- /dev/null +++ b/repa/unlock.py @@ -0,0 +1,68 @@ +#!/usr/bin/env python +# +# This file is part of REPA: Release Engineering Process Assistant. +# +# Copyright (C) 2015 Intel Corporation +# +# REPA is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# version 2 as published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. + +""" +REPA: Release Engineering Process Assistant. + +Copyright (C) Intel Corporation 2015 +Licence: GPL version 2 +Author: Ed Bartosh + +Unlock module. +Unlock submissions. +""" + +import sys + +from collections import namedtuple + +from repa.main import sub_main +from repa.jenkins import trigger_build + +class Unlock(object): + """Subcommand: unlock submissions.""" + + name = 'unlock' + description = 'Unlock submission' + help = description + + @staticmethod + def add_arguments(parser, _): + """Adds arguments to the parser. Called from [sub_]main.""" + parser.add_argument('submission', help='submission') + parser.add_argument('-c', '--comment', help='comment') + + @staticmethod + def run(argv): + """Command line entry point. Called from [sub_]main.""" + job = 're' + cred = namedtuple('cred', ['url', 'username', 'password'])(\ + argv.jenkins_url, argv.jenkins_user, argv.jenkins_passwd) + build, status, out = \ + trigger_build(job, {'action': 'unlock', + 'submission': argv.submission, + 'target_project': argv.project, + 'comment': argv.comment}, cred) + print "Jenkins job: %s, build #%s, status: %s" % (job, build, status) + print out + return status == 'SUCCESS' + +if __name__ == '__main__': + sys.exit(sub_main(sys.argv[1:], Unlock())) diff --git a/setup.py b/setup.py index b4b012c..3078c9d 100755 --- a/setup.py +++ b/setup.py @@ -49,5 +49,7 @@ setup(name="repa", 'rmgroup = repa.rmgroup:RmGroup', 'show = repa.show:Show', 'diff = repa.diff:Diff', - 'rebuild = repa.rebuild:Rebuild'] + 'rebuild = repa.rebuild:Rebuild', + 'lock = repa.lock:Lock', + 'unlock = repa.unlock:Unlock'] }) -- cgit v1.2.3