summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-05-19 13:13:27 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-29 11:59:45 +0100
commit1b6a50c6b2857c7c21fe4287966f3babca71a142 (patch)
treeb83d06d7e9e1aeb38cacc85a872c803ccf655147 /bitbake/lib
parent52fe880f9ec46c41d6afdfb275185768c0bb8db9 (diff)
downloadpoky-1b6a50c6b2857c7c21fe4287966f3babca71a142.tar.gz
bitbake: toaster: refactor checksettings command
This patch refactors the checksetting command to prevent early return from the handle function. It also adds a check that marks IN PROGRESS builds at startup time as FAILED. Minor changes to BuildRequest and Build classes ensure useful string representation for the objects. (Bitbake rev: adf67dd79dbf6b585bf8cd54f99c389409b88ecd) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py26
-rw-r--r--bitbake/lib/toaster/bldcontrol/models.py3
-rw-r--r--bitbake/lib/toaster/orm/models.py3
3 files changed, 30 insertions, 2 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
index 1ff5c92833..3c524464fa 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/checksettings.py
@@ -2,7 +2,7 @@ from django.core.management.base import NoArgsCommand, CommandError
2from django.db import transaction 2from django.db import transaction
3from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException 3from bldcontrol.bbcontroller import getBuildEnvironmentController, ShellCmdException
4from bldcontrol.models import BuildRequest, BuildEnvironment, BRError 4from bldcontrol.models import BuildRequest, BuildEnvironment, BRError
5from orm.models import ToasterSetting 5from orm.models import ToasterSetting, Build
6import os 6import os
7 7
8def DN(path): 8def DN(path):
@@ -61,7 +61,7 @@ class Command(NoArgsCommand):
61 return DN(self._find_first_path_for_file(DN(self.guesspath), "bblayers.conf", 4)) 61 return DN(self._find_first_path_for_file(DN(self.guesspath), "bblayers.conf", 4))
62 62
63 63
64 def handle(self, **options): 64 def _verify_artifact_storage_dir(self):
65 # verify that we have a settings for downloading artifacts 65 # verify that we have a settings for downloading artifacts
66 while ToasterSetting.objects.filter(name="ARTIFACTS_STORAGE_DIR").count() == 0: 66 while ToasterSetting.objects.filter(name="ARTIFACTS_STORAGE_DIR").count() == 0:
67 guessedpath = os.getcwd() + "/toaster_build_artifacts/" 67 guessedpath = os.getcwd() + "/toaster_build_artifacts/"
@@ -78,7 +78,10 @@ class Command(NoArgsCommand):
78 else: 78 else:
79 raise ose 79 raise ose
80 ToasterSetting.objects.create(name="ARTIFACTS_STORAGE_DIR", value=artifacts_storage_dir) 80 ToasterSetting.objects.create(name="ARTIFACTS_STORAGE_DIR", value=artifacts_storage_dir)
81 return 0
82
81 83
84 def _verify_build_environment(self):
82 self.guesspath = DN(DN(DN(DN(DN(DN(DN(__file__))))))) 85 self.guesspath = DN(DN(DN(DN(DN(DN(DN(__file__)))))))
83 # refuse to start if we have no build environments 86 # refuse to start if we have no build environments
84 while BuildEnvironment.objects.count() == 0: 87 while BuildEnvironment.objects.count() == 0:
@@ -197,12 +200,16 @@ class Command(NoArgsCommand):
197 200
198 while (_verify_be()): 201 while (_verify_be()):
199 pass 202 pass
203 return 0
200 204
205 def _verify_default_settings(self):
201 # verify that default settings are there 206 # verify that default settings are there
202 if ToasterSetting.objects.filter(name = 'DEFAULT_RELEASE').count() != 1: 207 if ToasterSetting.objects.filter(name = 'DEFAULT_RELEASE').count() != 1:
203 ToasterSetting.objects.filter(name = 'DEFAULT_RELEASE').delete() 208 ToasterSetting.objects.filter(name = 'DEFAULT_RELEASE').delete()
204 ToasterSetting.objects.get_or_create(name = 'DEFAULT_RELEASE', value = '') 209 ToasterSetting.objects.get_or_create(name = 'DEFAULT_RELEASE', value = '')
210 return 0
205 211
212 def _verify_builds_in_progress(self):
206 # we are just starting up. we must not have any builds in progress, or build environments taken 213 # we are just starting up. we must not have any builds in progress, or build environments taken
207 for b in BuildRequest.objects.filter(state = BuildRequest.REQ_INPROGRESS): 214 for b in BuildRequest.objects.filter(state = BuildRequest.REQ_INPROGRESS):
208 BRError.objects.create(req = b, errtype = "toaster", errmsg = "Toaster found this build IN PROGRESS while Toaster started up. This is an inconsistent state, and the build was marked as failed") 215 BRError.objects.create(req = b, errtype = "toaster", errmsg = "Toaster found this build IN PROGRESS while Toaster started up. This is an inconsistent state, and the build was marked as failed")
@@ -211,4 +218,19 @@ class Command(NoArgsCommand):
211 218
212 BuildEnvironment.objects.update(lock = BuildEnvironment.LOCK_FREE) 219 BuildEnvironment.objects.update(lock = BuildEnvironment.LOCK_FREE)
213 220
221 # also mark "In Progress builds as failures"
222 from django.utils import timezone
223 Build.objects.filter(outcome = Build.IN_PROGRESS).update(outcome = Build.FAILED, completed_on = timezone.now())
224
214 return 0 225 return 0
226
227
228
229 def handle(self, **options):
230 retval = 0
231 retval += self._verify_artifact_storage_dir()
232 retval += self._verify_build_environment()
233 retval += self._verify_default_settings()
234 retval += self._verify_builds_in_progress()
235
236 return retval
diff --git a/bitbake/lib/toaster/bldcontrol/models.py b/bitbake/lib/toaster/bldcontrol/models.py
index 02cfaf7086..b789446fa1 100644
--- a/bitbake/lib/toaster/bldcontrol/models.py
+++ b/bitbake/lib/toaster/bldcontrol/models.py
@@ -125,6 +125,9 @@ class BuildRequest(models.Model):
125 def get_machine(self): 125 def get_machine(self):
126 return self.brvariable_set.get(name="MACHINE").value 126 return self.brvariable_set.get(name="MACHINE").value
127 127
128 def __str__(self):
129 return "%s %s" % (self.project, self.get_state_display())
130
128# These tables specify the settings for running an actual build. 131# These tables specify the settings for running an actual build.
129# They MUST be kept in sync with the tables in orm.models.Project* 132# They MUST be kept in sync with the tables in orm.models.Project*
130 133
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index fb62a55d71..8a9a21eeee 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -267,6 +267,9 @@ class Build(models.Model):
267 def toaster_exceptions(self): 267 def toaster_exceptions(self):
268 return self.logmessage_set.filter(level=LogMessage.EXCEPTION) 268 return self.logmessage_set.filter(level=LogMessage.EXCEPTION)
269 269
270 def __str__(self):
271 return "%d %s %s" % (self.id, self.project, ",".join([t.target for t in self.target_set.all()]))
272
270 273
271# an Artifact is anything that results from a Build, and may be of interest to the user, and is not stored elsewhere 274# an Artifact is anything that results from a Build, and may be of interest to the user, and is not stored elsewhere
272class BuildArtifact(models.Model): 275class BuildArtifact(models.Model):