diff options
author | Alexandru DAMIAN <alexandru.damian@intel.com> | 2015-06-02 12:57:03 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-06-26 09:27:31 +0100 |
commit | 0b2e6442a6da8d05649530365601f49d37cb6ab5 (patch) | |
tree | a05a29556ae671ee0dd68b77cc952a2370f1dde9 /bitbake | |
parent | aad93dd3b78781e0a170345a5cf5ad59557e4170 (diff) | |
download | poky-0b2e6442a6da8d05649530365601f49d37cb6ab5.tar.gz |
bitbake: toaster: improve the buildenvironment API
We improve the buildenvironment API by reducing it to a single
command: triggerBuild.
This command is specifically implemented in each BE controller
type, so the runbuilds management command is only concerned
with scheduling the next build, and not with the details
of how a build is actually started.
(Bitbake rev: 7ee0f1da0a8fcac37419ffdddbe35a9268a1ded4)
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
4 files changed, 53 insertions, 23 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/bbcontroller.py b/bitbake/lib/toaster/bldcontrol/bbcontroller.py index 42675d3fc6..9dd01e0deb 100644 --- a/bitbake/lib/toaster/bldcontrol/bbcontroller.py +++ b/bitbake/lib/toaster/bldcontrol/bbcontroller.py | |||
@@ -190,6 +190,9 @@ class BuildEnvironmentController(object): | |||
190 | """ | 190 | """ |
191 | raise Exception("Must override BE release") | 191 | raise Exception("Must override BE release") |
192 | 192 | ||
193 | def triggerBuild(self, bitbake, layers, variables, targets): | ||
194 | raise Exception("Must override BE release") | ||
195 | |||
193 | class ShellCmdException(Exception): | 196 | class ShellCmdException(Exception): |
194 | pass | 197 | pass |
195 | 198 | ||
diff --git a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py index bc3566acee..d0f86325e9 100644 --- a/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/localhostbecontroller.py | |||
@@ -317,3 +317,25 @@ class LocalhostBEController(BuildEnvironmentController): | |||
317 | import shutil | 317 | import shutil |
318 | shutil.rmtree(os.path.join(self.be.sourcedir, "build")) | 318 | shutil.rmtree(os.path.join(self.be.sourcedir, "build")) |
319 | assert not os.path.exists(self.be.builddir) | 319 | assert not os.path.exists(self.be.builddir) |
320 | |||
321 | |||
322 | def triggerBuild(self, bitbake, layers, variables, targets): | ||
323 | # set up the buid environment with the needed layers | ||
324 | self.setLayers(bitbake, layers) | ||
325 | self.writeConfFile("conf/toaster-pre.conf", ) | ||
326 | self.writeConfFile("conf/toaster.conf", raw = "INHERIT+=\"toaster buildhistory\"") | ||
327 | |||
328 | # get the bb server running with the build req id and build env id | ||
329 | bbctrl = self.getBBController() | ||
330 | |||
331 | # trigger the build command | ||
332 | task = reduce(lambda x, y: x if len(y)== 0 else y, map(lambda y: y.task, targets)) | ||
333 | if len(task) == 0: | ||
334 | task = None | ||
335 | |||
336 | bbctrl.build(list(map(lambda x:x.target, targets)), task) | ||
337 | |||
338 | logger.debug("localhostbecontroller: Build launched, exiting. Follow build logs at %s/toaster_ui.log" % self.be.builddir) | ||
339 | |||
340 | # disconnect from the server | ||
341 | bbctrl.disconnect() | ||
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py index 808318f14f..920d9efcd0 100644 --- a/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py +++ b/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py | |||
@@ -50,33 +50,16 @@ class Command(NoArgsCommand): | |||
50 | 50 | ||
51 | # write the build identification variable | 51 | # write the build identification variable |
52 | BRVariable.objects.create(req = br, name="TOASTER_BRBE", value="%d:%d" % (br.pk, bec.be.pk)) | 52 | BRVariable.objects.create(req = br, name="TOASTER_BRBE", value="%d:%d" % (br.pk, bec.be.pk)) |
53 | |||
53 | # let the build request know where it is being executed | 54 | # let the build request know where it is being executed |
54 | br.environment = bec.be | 55 | br.environment = bec.be |
55 | br.save() | 56 | br.save() |
56 | 57 | ||
57 | # set up the buid environment with the needed layers | 58 | # this triggers an async build |
58 | bec.setLayers(br.brbitbake_set.all(), br.brlayer_set.all()) | 59 | bec.triggerBuild(br.brbitbake_set.all(), br.brlayer_set.all(), br.brvariable_set.all(), br.brtarget_set.all()) |
59 | bec.writeConfFile("conf/toaster-pre.conf", br.brvariable_set.all()) | ||
60 | bec.writeConfFile("conf/toaster.conf", raw = "INHERIT+=\"toaster buildhistory\"") | ||
61 | |||
62 | # get the bb server running with the build req id and build env id | ||
63 | bbctrl = bec.getBBController() | ||
64 | |||
65 | # trigger the build command | ||
66 | task = reduce(lambda x, y: x if len(y)== 0 else y, map(lambda y: y.task, br.brtarget_set.all())) | ||
67 | if len(task) == 0: | ||
68 | task = None | ||
69 | bbctrl.build(list(map(lambda x:x.target, br.brtarget_set.all())), task) | ||
70 | |||
71 | logger.debug("runbuilds: Build launched, exiting. Follow build logs at %s/toaster_ui.log" % bec.be.builddir) | ||
72 | # disconnect from the server | ||
73 | bbctrl.disconnect() | ||
74 | |||
75 | # cleanup to be performed by toaster when the deed is done | ||
76 | |||
77 | 60 | ||
78 | except Exception as e: | 61 | except Exception as e: |
79 | logger.error("runbuilds: Error executing shell command %s" % e) | 62 | logger.error("runbuilds: Error launching build %s" % e) |
80 | traceback.print_exc(e) | 63 | traceback.print_exc(e) |
81 | if "[Errno 111] Connection refused" in str(e): | 64 | if "[Errno 111] Connection refused" in str(e): |
82 | # Connection refused, read toaster_server.out | 65 | # Connection refused, read toaster_server.out |
@@ -124,8 +107,9 @@ class Command(NoArgsCommand): | |||
124 | def cleanup(self): | 107 | def cleanup(self): |
125 | from django.utils import timezone | 108 | from django.utils import timezone |
126 | from datetime import timedelta | 109 | from datetime import timedelta |
127 | # environments locked for more than 30 seconds - they should be unlocked | 110 | # DISABLED environments locked for more than 30 seconds - they should be unlocked |
128 | BuildEnvironment.objects.filter(lock=BuildEnvironment.LOCK_LOCK).filter(updated__lt = timezone.now() - timedelta(seconds = 30)).update(lock = BuildEnvironment.LOCK_FREE) | 111 | #BuildEnvironment.objects.filter(lock=BuildEnvironment.LOCK_LOCK).filter(updated__lt = timezone.now() - timedelta(seconds = 30)).update(lock = BuildEnvironment.LOCK_FREE) |
112 | pass | ||
129 | 113 | ||
130 | 114 | ||
131 | def handle_noargs(self, **options): | 115 | def handle_noargs(self, **options): |
diff --git a/bitbake/lib/toaster/bldcontrol/sshbecontroller.py b/bitbake/lib/toaster/bldcontrol/sshbecontroller.py index 29ed0a770f..8ef434baf5 100644 --- a/bitbake/lib/toaster/bldcontrol/sshbecontroller.py +++ b/bitbake/lib/toaster/bldcontrol/sshbecontroller.py | |||
@@ -156,3 +156,24 @@ class SSHBEController(BuildEnvironmentController): | |||
156 | import shutil | 156 | import shutil |
157 | shutil.rmtree(os.path.join(self.be.sourcedir, "build")) | 157 | shutil.rmtree(os.path.join(self.be.sourcedir, "build")) |
158 | assert not self._pathexists(self.be.builddir) | 158 | assert not self._pathexists(self.be.builddir) |
159 | |||
160 | def triggerBuild(self, bitbake, layers, variables, targets): | ||
161 | # set up the buid environment with the needed layers | ||
162 | self.setLayers(bitbake, layers) | ||
163 | self.writeConfFile("conf/toaster-pre.conf", ) | ||
164 | self.writeConfFile("conf/toaster.conf", raw = "INHERIT+=\"toaster buildhistory\"") | ||
165 | |||
166 | # get the bb server running with the build req id and build env id | ||
167 | bbctrl = self.getBBController() | ||
168 | |||
169 | # trigger the build command | ||
170 | task = reduce(lambda x, y: x if len(y)== 0 else y, map(lambda y: y.task, targets)) | ||
171 | if len(task) == 0: | ||
172 | task = None | ||
173 | |||
174 | bbctrl.build(list(map(lambda x:x.target, targets)), task) | ||
175 | |||
176 | logger.debug("localhostbecontroller: Build launched, exiting. Follow build logs at %s/toaster_ui.log" % self.be.builddir) | ||
177 | |||
178 | # disconnect from the server | ||
179 | bbctrl.disconnect() | ||