Implement repa lock/unlock
authorEd Bartosh <eduard.bartosh@intel.com>
Sun, 1 Feb 2015 19:07:32 +0000 (21:07 +0200)
committerEd Bartosh <eduard.bartosh@intel.com>
Tue, 3 Feb 2015 19:02:09 +0000 (21:02 +0200)
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 <eduard.bartosh@intel.com>
repa.1
repa/lock.py [new file with mode: 0644]
repa/unlock.py [new file with mode: 0644]
setup.py

diff --git a/repa.1 b/repa.1
index bbbe2622ca411dc42ff01fc21857930292aaa0b1..7650a856c5e0754e381d9ded75f51d21545d1d80 100644 (file)
--- 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] <submision>
+
+.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] <submision>
+
+.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 (file)
index 0000000..9edd966
--- /dev/null
@@ -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 <eduard.bartosh@intel.com>
+
+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 (file)
index 0000000..47e0fec
--- /dev/null
@@ -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 <eduard.bartosh@intel.com>
+
+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()))
index b4b012cef979271715ef066038d176fc1873fddb..3078c9dc9f2a8619a87c78452b6f428b1d230cac 100755 (executable)
--- 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']
       })