Patchwork [bitbake-devel,1/4] toaster: populate target image file table

login
register
mail settings
Submitter Alexandru DAMIAN
Date March 12, 2014, 6:47 p.m.
Message ID <f1ccf1eb81e7ba89b9e540a19c839a3dfdef234b.1394649860.git.alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/68541/
State New
Headers show

Comments

Alexandru DAMIAN - March 12, 2014, 6:47 p.m.
From: Cristiana Voicu <cristiana.voicu@intel.com>

Using ImageFileSize Metadata event, the image output file and its
size are populated into target_image_file table.

	[YOCTO #5189]
	[YOCTO #5228]

Signed-off-by: Cristiana Voicu <cristiana.voicu@intel.com>
Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 lib/bb/ui/buildinfohelper.py   | 13 +++++++++++++
 lib/bb/ui/toasterui.py         |  2 ++
 lib/toaster/bldviewer/api.py   |  1 +
 lib/toaster/bldviewer/views.py |  3 ++-
 4 files changed, 18 insertions(+), 1 deletion(-)

Patch

diff --git a/lib/bb/ui/buildinfohelper.py b/lib/bb/ui/buildinfohelper.py
index f9b067f..1b17c1f 100644
--- a/lib/bb/ui/buildinfohelper.py
+++ b/lib/bb/ui/buildinfohelper.py
@@ -26,6 +26,7 @@  os.environ.setdefault("DJANGO_SETTINGS_MODULE", "toaster.toastermain.settings")
 
 import toaster.toastermain.settings as toaster_django_settings
 from toaster.orm.models import Build, Task, Recipe, Layer_Version, Layer, Target, LogMessage
+from toaster.orm.models import Target_Image_File
 from toaster.orm.models import Variable, VariableHistory
 from toaster.orm.models import Package, Package_File, Target_Installed_Package, Target_File
 from toaster.orm.models import Task_Dependency, Package_Dependency
@@ -344,6 +345,11 @@  class ORMWrapper(object):
         if (len(errormsg) > 0):
             raise Exception(errormsg)
 
+    def save_target_image_file_information(self, target_obj, file_name, file_size):
+        target_image_file = Target_Image_File.objects.create( target = target_obj,
+                            file_name = file_name,
+                            file_size = file_size)
+        target_image_file.save()
 
     def create_logmessage(self, log_information):
         assert 'build' in log_information
@@ -598,6 +604,13 @@  class BuildInfoHelper(object):
         # Save build configuration
         self.orm_wrapper.save_build_variables(build_obj, self.server.runCommand(["getAllKeysWithFlags", ["doc", "func"]])[0])
 
+    def update_target_image_file(self, event):
+        for t in self.internal_state['targets']:
+            if t.is_image == True:
+                output_files = list(event.data.viewkeys())
+                for output in output_files:
+                    if t.target in output:
+                        self.orm_wrapper.save_target_image_file_information(t, output, event.data[output])
 
     def update_build_information(self, event, errors, warnings, taskfailures):
         if 'build' in self.internal_state:
diff --git a/lib/bb/ui/toasterui.py b/lib/bb/ui/toasterui.py
index e469d93..04e0f99 100644
--- a/lib/bb/ui/toasterui.py
+++ b/lib/bb/ui/toasterui.py
@@ -241,6 +241,8 @@  def main(server, eventHandler, params ):
                     buildinfohelper.store_tasks_stats(event)
                 if event.type == "ImagePkgList":
                     buildinfohelper.store_target_package_data(event)
+                elif event.type == "ImageFileSize":
+                    buildinfohelper.update_target_image_file(event)
                 continue
 
             # ignore
diff --git a/lib/toaster/bldviewer/api.py b/lib/toaster/bldviewer/api.py
index 654864e..76d45c7 100644
--- a/lib/toaster/bldviewer/api.py
+++ b/lib/toaster/bldviewer/api.py
@@ -25,6 +25,7 @@  from django.conf.urls import patterns, include, url
 urlpatterns = patterns('bldviewer.views',
         url(r'^builds$', 'model_explorer',  {'model_name':'build'}, name='builds'),
         url(r'^targets$', 'model_explorer',  {'model_name':'target'}, name='targets'),
+        url(r'^target_image_file$', 'model_explorer',  {'model_name':'target_image_file'}, name='target_image_file'),
         url(r'^tasks$', 'model_explorer', {'model_name':'task'}, name='task'),
         url(r'^task_dependencies$', 'model_explorer',  {'model_name':'task_dependency'}, name='task_dependencies'),
         url(r'^packages$', 'model_explorer',  {'model_name':'package'}, name='package'),
diff --git a/lib/toaster/bldviewer/views.py b/lib/toaster/bldviewer/views.py
index 435bc8e..6f86379 100644
--- a/lib/toaster/bldviewer/views.py
+++ b/lib/toaster/bldviewer/views.py
@@ -25,7 +25,7 @@  from django.db.models import Q
 from django.shortcuts import render
 from orm.models import Build, Target, Task, Layer, Layer_Version, Recipe, LogMessage, Variable, Target_Installed_Package
 from orm.models import Task_Dependency, Recipe_Dependency, Package, Package_File, Package_Dependency
-from orm.models import Target_Installed_Package, VariableHistory
+from orm.models import Target_Installed_Package, VariableHistory, Target_Image_File
 from django.views.decorators.cache import cache_control
 from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
 
@@ -159,6 +159,7 @@  def model_explorer(request, model_name):
     model_mapping = {
         'build': Build,
         'target': Target,
+        'target_image_file': Target_Image_File,
         'task': Task,
         'task_dependency': Task_Dependency,
         'package': Package,