diff options
Diffstat (limited to 'morphlib/plugins')
-rw-r--r-- | morphlib/plugins/build_plugin.py | 31 | ||||
-rw-r--r-- | morphlib/plugins/distbuild_plugin.py | 42 |
2 files changed, 72 insertions, 1 deletions
diff --git a/morphlib/plugins/build_plugin.py b/morphlib/plugins/build_plugin.py index 12d69545..8da66358 100644 --- a/morphlib/plugins/build_plugin.py +++ b/morphlib/plugins/build_plugin.py @@ -46,10 +46,14 @@ class BuildPlugin(cliapp.Plugin): '[COMPONENT...]') self.app.add_subcommand('distbuild', self.distbuild, arg_synopsis='SYSTEM [COMPONENT...]') + self.app.add_subcommand('distbuild-start', self.distbuild_start, + arg_synopsis='SYSTEM [COMPONENT...]') self.use_distbuild = False + self.allow_detach = False def disable(self): self.use_distbuild = False + self.allow_detach = False def distbuild_morphology(self, args): '''Distbuild a system, outside of a system branch. @@ -97,6 +101,12 @@ class BuildPlugin(cliapp.Plugin): your system, the system artifact will be copied from your trove and cached locally. + Log information can be found in the current working directory, in + directories called build-xx. + + If you do not have a persistent connection to the server on which + the distbuild runs, consider using `morph distbuild-start` instead. + Example: morph distbuild devel-system-x86_64-generic.morph @@ -106,6 +116,25 @@ class BuildPlugin(cliapp.Plugin): self.use_distbuild = True self.build(args) + def distbuild_start(self, args): + '''Distbuild a system image without a lasting client-server connection. + + This command launches a distributed build, and disconnects from the + distbuild cluster once the build starts, leaving the build running + remotely. + + The command will return a build-ID which can be used to cancel the + distbuild via `morph distbuild-cancel`. Builds started in this manner + can be found via `morph distbuild-list-jobs` + + See `morph help distbuild` for more information and example usage. + + ''' + + self.use_distbuild = True + self.allow_detach = True + self.build(args) + def build_morphology(self, args): '''Build a system, outside of a system branch. @@ -211,7 +240,7 @@ class BuildPlugin(cliapp.Plugin): port = self.app.settings['controller-initiator-port'] build_command = morphlib.buildcommand.InitiatorBuildCommand( - self.app, addr, port) + self.app, addr, port, self.allow_detach) else: build_command = morphlib.buildcommand.BuildCommand(self.app) 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 |