summaryrefslogtreecommitdiff
path: root/morphlib/plugins/distbuild_plugin.py
diff options
context:
space:
mode:
authorLauren Perry <lauren.perry@codethink.co.uk>2015-04-02 17:23:07 +0100
committerRichard Ipsum <richardipsum@fastmail.co.uk>2015-04-29 16:10:58 +0000
commit84096556ea54d4af236f1fe5f7ccf61c1343016f (patch)
tree76b5aa72bf9c691fd8e154feade051c2ceba16ac /morphlib/plugins/distbuild_plugin.py
parent4a1c2d118511da067fcadf2253fdc2a49d04e4fa (diff)
downloadmorph-84096556ea54d4af236f1fe5f7ccf61c1343016f.tar.gz
distbuild: Add distbuild start and cancel functionality
Add command for distbuild-start to build_plugin in morphlib, and create a boolean parameter to inform the initiator whether to disconnect the controller and leave the build running remotely. Add distbuild-cancel command to parse currently-running distbuild build-request IDs and cancel the one matching the given argument Change-Id: I458a5767bb768ceb2b4d8876adf1c86075d452bd
Diffstat (limited to 'morphlib/plugins/distbuild_plugin.py')
-rw-r--r--morphlib/plugins/distbuild_plugin.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/morphlib/plugins/distbuild_plugin.py b/morphlib/plugins/distbuild_plugin.py
index 09669988..68a80784 100644
--- a/morphlib/plugins/distbuild_plugin.py
+++ b/morphlib/plugins/distbuild_plugin.py
@@ -40,6 +40,48 @@ class DistbuildOptionsPlugin(cliapp.Plugin):
pass
+class DistbuildCancel(cliapp.Plugin):
+
+ RECONNECT_INTERVAL = 30 # seconds
+ MAX_RETRIES = 1
+
+ def enable(self):
+ self.app.add_subcommand('distbuild-cancel', self.distbuild_cancel,
+ arg_synopsis='ID')
+
+ def disable(self):
+ pass
+
+ def distbuild_cancel(self, args):
+ '''Cancels a currently-running distbuild
+
+ Command line arguments:
+
+ `ID` of the running process that you wish to cancel
+ (this can be found via distbuild-list-jobs)
+
+ Example:
+
+ * morph distbuild-cancel InitiatorConnection-1
+
+ '''
+
+ if len(args) != 1:
+ raise cliapp.AppException(
+ 'usage: morph distbuild-cancel <build-request id>')
+
+ addr = self.app.settings['controller-initiator-address']
+ port = self.app.settings['controller-initiator-port']
+ icm = distbuild.InitiatorConnectionMachine(self.app, addr, port,
+ distbuild.InitiatorCancel,
+ [self.app] + args,
+ self.RECONNECT_INTERVAL,
+ self.MAX_RETRIES)
+ loop = distbuild.MainLoop()
+ loop.add_state_machine(icm)
+ loop.run()
+
+
class DistbuildListJobsPlugin(cliapp.Plugin):
RECONNECT_INTERVAL = 30 # seconds