summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richard.ipsum@codethink.co.uk>2014-03-26 16:40:31 +0000
committerRichard Ipsum <richard.ipsum@codethink.co.uk>2014-03-26 22:10:01 +0000
commita589866b356453474bb845bd78e8b38c77ee1059 (patch)
tree590a3b765c1e482abf9a160b88b66f13f1eaabfb
parent19004f89ec34503d937897dac44e84be9ea6c47b (diff)
downloadmorph-a589866b356453474bb845bd78e8b38c77ee1059.tar.gz
Bring InitiatorBuildCommand into buildcommand
-rw-r--r--morphlib/buildcommand.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/morphlib/buildcommand.py b/morphlib/buildcommand.py
index 137c63b4..3c190275 100644
--- a/morphlib/buildcommand.py
+++ b/morphlib/buildcommand.py
@@ -20,6 +20,7 @@ import logging
import tempfile
import morphlib
+import distbuild
class MultipleRootArtifactsError(morphlib.Error):
@@ -474,3 +475,32 @@ class BuildCommand(object):
self.app, staging_area, self.lac, self.rac, self.lrc,
self.app.settings['max-jobs'], setup_mounts)
return builder.build_and_cache(artifact)
+
+class InitiatorBuildCommand(BuildCommand):
+
+ def __init__(self, app, addr, port):
+ self.app = app
+ self.addr = addr
+ self.port = port
+ self.app.settings['push-build-branches'] = True
+ super(InitiatorBuildCommand, self).__init__(app)
+
+ def build(self, args):
+ '''Initiate a distributed build on a controller'''
+
+ distbuild.add_crash_conditions(self.app.settings['crash-condition'])
+
+ if len(args) != 3:
+ raise morphlib.Error(
+ 'Need repo, ref, morphology triplet to build')
+
+ if self.addr == '':
+ raise morphlib.Error(
+ 'Need address of controller to run a distbuild')
+
+ self.app.status(msg='Starting distributed build')
+ loop = distbuild.MainLoop()
+ cm = distbuild.ConnectionMachine(
+ self.addr, self.port, distbuild.Initiator, [self.app] + args)
+ loop.add_state_machine(cm)
+ loop.run()