summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/ui
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-05-14 16:44:27 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-29 11:59:44 +0100
commit56c5ff920c93a627f6bd473383ab4bbca912fc41 (patch)
tree7a193c508fe8e74786a0d21c6877aef1fd88bbae /bitbake/lib/bb/ui
parente3e85bdf7100cc5619d7f184dc8d9e2a77a03364 (diff)
downloadpoky-56c5ff920c93a627f6bd473383ab4bbca912fc41.tar.gz
bitbake: toaster logger: assign projects to all builds
Bitbake logger now sets a default project if the TOASTER_BRBE or TOASTER_PROJECT Bitbake variables are not set. This a necessary step in getting all builds under a project, as to unify the MANAGED and interactive modes. Other small fixes are included, related to the size of the fields in the database. (Bitbake rev: 5e0bf388f4e5c1cc493ac8264785e631bad2f672) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui')
-rw-r--r--bitbake/lib/bb/ui/buildinfohelper.py37
1 files changed, 27 insertions, 10 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index 6812a52b7b..3ea842cd4b 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -31,6 +31,9 @@ from toaster.orm.models import Variable, VariableHistory
31from toaster.orm.models import Package, Package_File, Target_Installed_Package, Target_File 31from toaster.orm.models import Package, Package_File, Target_Installed_Package, Target_File
32from toaster.orm.models import Task_Dependency, Package_Dependency 32from toaster.orm.models import Task_Dependency, Package_Dependency
33from toaster.orm.models import Recipe_Dependency 33from toaster.orm.models import Recipe_Dependency
34
35from toaster.orm.models import Project
36
34from bb.msg import BBLogFormatter as format 37from bb.msg import BBLogFormatter as format
35from django.db import models 38from django.db import models
36from pprint import pformat 39from pprint import pformat
@@ -103,7 +106,7 @@ class ORMWrapper(object):
103 106
104 return vars(self)[dictname][key] 107 return vars(self)[dictname][key]
105 108
106 def create_build_object(self, build_info, brbe): 109 def create_build_object(self, build_info, brbe, project_id):
107 assert 'machine' in build_info 110 assert 'machine' in build_info
108 assert 'distro' in build_info 111 assert 'distro' in build_info
109 assert 'distro_version' in build_info 112 assert 'distro_version' in build_info
@@ -112,7 +115,26 @@ class ORMWrapper(object):
112 assert 'build_name' in build_info 115 assert 'build_name' in build_info
113 assert 'bitbake_version' in build_info 116 assert 'bitbake_version' in build_info
114 117
118 prj = None
119 buildrequest = None
120 if brbe is not None: # this build was triggered by a request from a user
121 logger.debug(1, "buildinfohelper: brbe is %s" % brbe)
122 from bldcontrol.models import BuildEnvironment, BuildRequest
123 br, be = brbe.split(":")
124 buildrequest = BuildRequest.objects.get(pk = br)
125 prj = buildrequest.project
126
127 elif project_id is not None: # this build was triggered by an external system for a specific project
128 logger.debug(1, "buildinfohelper: project is %s" % prj)
129 prj = Project.objects.get(pk = project_id)
130
131 else: # this build was triggered by a legacy system, or command line interactive mode
132 prj, created = Project.objects.get_or_create(pk=0, name="Default Project")
133 logger.debug(1, "buildinfohelper: project is not specified, defaulting to %s" % prj)
134
135
115 build = Build.objects.create( 136 build = Build.objects.create(
137 project = prj,
116 machine=build_info['machine'], 138 machine=build_info['machine'],
117 distro=build_info['distro'], 139 distro=build_info['distro'],
118 distro_version=build_info['distro_version'], 140 distro_version=build_info['distro_version'],
@@ -123,17 +145,11 @@ class ORMWrapper(object):
123 bitbake_version=build_info['bitbake_version']) 145 bitbake_version=build_info['bitbake_version'])
124 146
125 logger.debug(1, "buildinfohelper: build is created %s" % build) 147 logger.debug(1, "buildinfohelper: build is created %s" % build)
126 if brbe is not None:
127 logger.debug(1, "buildinfohelper: brbe is %s" % brbe)
128 from bldcontrol.models import BuildEnvironment, BuildRequest
129 br, be = brbe.split(":")
130 148
131 buildrequest = BuildRequest.objects.get(pk = br) 149 if buildrequest is not None:
132 buildrequest.build = build 150 buildrequest.build = build
133 buildrequest.save() 151 buildrequest.save()
134 152
135 build.project_id = buildrequest.project_id
136 build.save()
137 return build 153 return build
138 154
139 def create_target_objects(self, target_info): 155 def create_target_objects(self, target_info):
@@ -638,6 +654,7 @@ class BuildInfoHelper(object):
638 self.has_build_history = has_build_history 654 self.has_build_history = has_build_history
639 self.tmp_dir = self.server.runCommand(["getVariable", "TMPDIR"])[0] 655 self.tmp_dir = self.server.runCommand(["getVariable", "TMPDIR"])[0]
640 self.brbe = self.server.runCommand(["getVariable", "TOASTER_BRBE"])[0] 656 self.brbe = self.server.runCommand(["getVariable", "TOASTER_BRBE"])[0]
657 self.project = self.server.runCommand(["getVariable", "TOASTER_PROJECT"])[0]
641 logger.debug(1, "buildinfohelper: Build info helper inited %s" % vars(self)) 658 logger.debug(1, "buildinfohelper: Build info helper inited %s" % vars(self))
642 659
643 660
@@ -804,7 +821,7 @@ class BuildInfoHelper(object):
804 assert '_pkgs' in vars(event) 821 assert '_pkgs' in vars(event)
805 build_information = self._get_build_information() 822 build_information = self._get_build_information()
806 823
807 build_obj = self.orm_wrapper.create_build_object(build_information, self.brbe) 824 build_obj = self.orm_wrapper.create_build_object(build_information, self.brbe, self.project)
808 825
809 self.internal_state['build'] = build_obj 826 self.internal_state['build'] = build_obj
810 827
@@ -1233,7 +1250,7 @@ class BuildInfoHelper(object):
1233 logger.debug(1, "buildinfohelper: Saving stored event %s " % tempevent) 1250 logger.debug(1, "buildinfohelper: Saving stored event %s " % tempevent)
1234 self.store_log_event(tempevent) 1251 self.store_log_event(tempevent)
1235 else: 1252 else:
1236 logger.error("buildinfohelper: Events not saved: %s" % self.internal_state['backlog']) 1253 logger.info("buildinfohelper: All events saved")
1237 del self.internal_state['backlog'] 1254 del self.internal_state['backlog']
1238 1255
1239 log_information = {} 1256 log_information = {}