Patchwork [bitbake-devel,9/9] toasterui: fix build - project identification

login
register
mail settings
Submitter Alexandru DAMIAN
Date July 4, 2014, 12:44 p.m.
Message ID <364164bd9d02338fe60694ec128c8737f9b688e3.1404477729.git.alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/75035/
State New
Headers show

Comments

Alexandru DAMIAN - July 4, 2014, 12:44 p.m.
From: Alexandru DAMIAN <alexandru.damian@intel.com>

This patches fixes the build - project identification when
running under managed mode. The build is assigned to the
project from which it was triggered, and to the
build request, as to simplify relationships queries
 in the database.

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 lib/bb/ui/buildinfohelper.py | 17 +++++++++++++++--
 lib/bb/ui/toasterui.py       |  7 +++----
 2 files changed, 18 insertions(+), 6 deletions(-)

Patch

diff --git a/lib/bb/ui/buildinfohelper.py b/lib/bb/ui/buildinfohelper.py
index 77be7c7..29cfc81 100644
--- a/lib/bb/ui/buildinfohelper.py
+++ b/lib/bb/ui/buildinfohelper.py
@@ -46,7 +46,7 @@  class ORMWrapper(object):
         pass
 
 
-    def create_build_object(self, build_info):
+    def create_build_object(self, build_info, brbe):
         assert 'machine' in build_info
         assert 'distro' in build_info
         assert 'distro_version' in build_info
@@ -65,6 +65,13 @@  class ORMWrapper(object):
                                     build_name=build_info['build_name'],
                                     bitbake_version=build_info['bitbake_version'])
 
+        if brbe is not None:
+            from bldcontrol.models import BuildEnvironment, BuildRequest
+            br, be = brbe.split(":")
+            buildrequest = BuildRequest.objects.get(pk = br)
+            build.project = buildrequest.project
+            build.save()
+
         return build
 
     def create_target_objects(self, target_info):
@@ -600,7 +607,10 @@  class BuildInfoHelper(object):
         assert '_pkgs' in vars(event)
         build_information = self._get_build_information()
 
-        build_obj = self.orm_wrapper.create_build_object(build_information)
+        brbe = self.server.runCommand(["getVariable", "TOASTER_BRBE"])[0]
+
+        build_obj = self.orm_wrapper.create_build_object(build_information, brbe)
+
         self.internal_state['build'] = build_obj
 
         # save layer version information for this build
@@ -619,6 +629,9 @@  class BuildInfoHelper(object):
         # Save build configuration
         self.orm_wrapper.save_build_variables(build_obj, self.server.runCommand(["getAllKeysWithFlags", ["doc", "func"]])[0])
 
+        return brbe
+
+
     def update_target_image_file(self, event):
         image_fstypes = self.server.runCommand(["getVariable", "IMAGE_FSTYPES"])[0]
         for t in self.internal_state['targets']:
diff --git a/lib/bb/ui/toasterui.py b/lib/bb/ui/toasterui.py
index 5f87a9d..2f628e9 100644
--- a/lib/bb/ui/toasterui.py
+++ b/lib/bb/ui/toasterui.py
@@ -94,7 +94,7 @@  def main(server, eventHandler, params ):
     first = True
 
     buildinfohelper = BuildInfoHelper(server, build_history_enabled)
-
+    brbe = None
 
     while True:
         try:
@@ -111,7 +111,7 @@  def main(server, eventHandler, params ):
             helper.eventHandler(event)
 
             if isinstance(event, bb.event.BuildStarted):
-                buildinfohelper.store_started_build(event)
+                brbe = buildinfohelper.store_started_build(event)
 
             if isinstance(event, (bb.build.TaskStarted, bb.build.TaskSucceeded, bb.build.TaskFailedSilent)):
                 buildinfohelper.update_and_store_task(event)
@@ -231,10 +231,9 @@  def main(server, eventHandler, params ):
                 buildinfohelper.update_build_information(event, errors, warnings, taskfailures)
 
 
-                brbe = server.runCommand(["getVariable", "TOASTER_BRBE"])[0]
-                br_id, be_id = brbe.split(":")
                 # we start a new build info
                 if brbe is not None:
+                    br_id, be_id = brbe.split(":")
                     buildinfohelper.store_build_done(br_id, be_id)
 
                     print "we are under BuildEnvironment management - after the build, we exit"