[bitbake-devel] [PATCH 02/23] toaster: improve the buildenvironment API
Alex DAMIAN
alexandru.damian at intel.com
Thu Jun 25 10:33:39 UTC 2015
From: Alexandru DAMIAN <alexandru.damian at intel.com>
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.
Signed-off-by: Alexandru DAMIAN <alexandru.damian at intel.com>
---
lib/toaster/bldcontrol/bbcontroller.py | 3 +++
lib/toaster/bldcontrol/localhostbecontroller.py | 22 ++++++++++++++++
.../bldcontrol/management/commands/runbuilds.py | 30 +++++-----------------
lib/toaster/bldcontrol/sshbecontroller.py | 21 +++++++++++++++
4 files changed, 53 insertions(+), 23 deletions(-)
diff --git a/lib/toaster/bldcontrol/bbcontroller.py b/lib/toaster/bldcontrol/bbcontroller.py
index 42675d3..9dd01e0 100644
--- a/lib/toaster/bldcontrol/bbcontroller.py
+++ b/lib/toaster/bldcontrol/bbcontroller.py
@@ -190,6 +190,9 @@ class BuildEnvironmentController(object):
"""
raise Exception("Must override BE release")
+ def triggerBuild(self, bitbake, layers, variables, targets):
+ raise Exception("Must override BE release")
+
class ShellCmdException(Exception):
pass
diff --git a/lib/toaster/bldcontrol/localhostbecontroller.py b/lib/toaster/bldcontrol/localhostbecontroller.py
index bc3566a..d0f8632 100644
--- a/lib/toaster/bldcontrol/localhostbecontroller.py
+++ b/lib/toaster/bldcontrol/localhostbecontroller.py
@@ -317,3 +317,25 @@ class LocalhostBEController(BuildEnvironmentController):
import shutil
shutil.rmtree(os.path.join(self.be.sourcedir, "build"))
assert not os.path.exists(self.be.builddir)
+
+
+ def triggerBuild(self, bitbake, layers, variables, targets):
+ # set up the buid environment with the needed layers
+ self.setLayers(bitbake, layers)
+ self.writeConfFile("conf/toaster-pre.conf", )
+ self.writeConfFile("conf/toaster.conf", raw = "INHERIT+=\"toaster buildhistory\"")
+
+ # get the bb server running with the build req id and build env id
+ bbctrl = self.getBBController()
+
+ # trigger the build command
+ task = reduce(lambda x, y: x if len(y)== 0 else y, map(lambda y: y.task, targets))
+ if len(task) == 0:
+ task = None
+
+ bbctrl.build(list(map(lambda x:x.target, targets)), task)
+
+ logger.debug("localhostbecontroller: Build launched, exiting. Follow build logs at %s/toaster_ui.log" % self.be.builddir)
+
+ # disconnect from the server
+ bbctrl.disconnect()
diff --git a/lib/toaster/bldcontrol/management/commands/runbuilds.py b/lib/toaster/bldcontrol/management/commands/runbuilds.py
index 808318f..920d9ef 100644
--- a/lib/toaster/bldcontrol/management/commands/runbuilds.py
+++ b/lib/toaster/bldcontrol/management/commands/runbuilds.py
@@ -50,33 +50,16 @@ class Command(NoArgsCommand):
# write the build identification variable
BRVariable.objects.create(req = br, name="TOASTER_BRBE", value="%d:%d" % (br.pk, bec.be.pk))
+
# let the build request know where it is being executed
br.environment = bec.be
br.save()
- # set up the buid environment with the needed layers
- bec.setLayers(br.brbitbake_set.all(), br.brlayer_set.all())
- bec.writeConfFile("conf/toaster-pre.conf", br.brvariable_set.all())
- bec.writeConfFile("conf/toaster.conf", raw = "INHERIT+=\"toaster buildhistory\"")
-
- # get the bb server running with the build req id and build env id
- bbctrl = bec.getBBController()
-
- # trigger the build command
- task = reduce(lambda x, y: x if len(y)== 0 else y, map(lambda y: y.task, br.brtarget_set.all()))
- if len(task) == 0:
- task = None
- bbctrl.build(list(map(lambda x:x.target, br.brtarget_set.all())), task)
-
- logger.debug("runbuilds: Build launched, exiting. Follow build logs at %s/toaster_ui.log" % bec.be.builddir)
- # disconnect from the server
- bbctrl.disconnect()
-
- # cleanup to be performed by toaster when the deed is done
-
+ # this triggers an async build
+ bec.triggerBuild(br.brbitbake_set.all(), br.brlayer_set.all(), br.brvariable_set.all(), br.brtarget_set.all())
except Exception as e:
- logger.error("runbuilds: Error executing shell command %s" % e)
+ logger.error("runbuilds: Error launching build %s" % e)
traceback.print_exc(e)
if "[Errno 111] Connection refused" in str(e):
# Connection refused, read toaster_server.out
@@ -124,8 +107,9 @@ class Command(NoArgsCommand):
def cleanup(self):
from django.utils import timezone
from datetime import timedelta
- # environments locked for more than 30 seconds - they should be unlocked
- BuildEnvironment.objects.filter(lock=BuildEnvironment.LOCK_LOCK).filter(updated__lt = timezone.now() - timedelta(seconds = 30)).update(lock = BuildEnvironment.LOCK_FREE)
+ # DISABLED environments locked for more than 30 seconds - they should be unlocked
+ #BuildEnvironment.objects.filter(lock=BuildEnvironment.LOCK_LOCK).filter(updated__lt = timezone.now() - timedelta(seconds = 30)).update(lock = BuildEnvironment.LOCK_FREE)
+ pass
def handle_noargs(self, **options):
diff --git a/lib/toaster/bldcontrol/sshbecontroller.py b/lib/toaster/bldcontrol/sshbecontroller.py
index 29ed0a7..8ef434b 100644
--- a/lib/toaster/bldcontrol/sshbecontroller.py
+++ b/lib/toaster/bldcontrol/sshbecontroller.py
@@ -156,3 +156,24 @@ class SSHBEController(BuildEnvironmentController):
import shutil
shutil.rmtree(os.path.join(self.be.sourcedir, "build"))
assert not self._pathexists(self.be.builddir)
+
+ def triggerBuild(self, bitbake, layers, variables, targets):
+ # set up the buid environment with the needed layers
+ self.setLayers(bitbake, layers)
+ self.writeConfFile("conf/toaster-pre.conf", )
+ self.writeConfFile("conf/toaster.conf", raw = "INHERIT+=\"toaster buildhistory\"")
+
+ # get the bb server running with the build req id and build env id
+ bbctrl = self.getBBController()
+
+ # trigger the build command
+ task = reduce(lambda x, y: x if len(y)== 0 else y, map(lambda y: y.task, targets))
+ if len(task) == 0:
+ task = None
+
+ bbctrl.build(list(map(lambda x:x.target, targets)), task)
+
+ logger.debug("localhostbecontroller: Build launched, exiting. Follow build logs at %s/toaster_ui.log" % self.be.builddir)
+
+ # disconnect from the server
+ bbctrl.disconnect()
--
1.9.1
More information about the bitbake-devel
mailing list