summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-06-02 12:57:03 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-26 09:27:31 +0100
commit0b2e6442a6da8d05649530365601f49d37cb6ab5 (patch)
treea05a29556ae671ee0dd68b77cc952a2370f1dde9 /bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py
parentaad93dd3b78781e0a170345a5cf5ad59557e4170 (diff)
downloadpoky-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/lib/toaster/bldcontrol/management/commands/runbuilds.py')
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/runbuilds.py30
1 files changed, 7 insertions, 23 deletions
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):