Patchwork [bitbake-devel,68/94] bitbake: dsi: use get vars command to store configuration

login
register
mail settings
Submitter Alexandru DAMIAN
Date Sept. 24, 2013, 4:52 p.m.
Message ID <c592a5c9efa95210f483162cf7adc02ab0d86b89.1380041477.git.alexandru.damian@intel.com>
Download mbox | patch
Permalink /patch/58865/
State New
Headers show

Comments

Alexandru DAMIAN - Sept. 24, 2013, 4:52 p.m.
From: Alexandru DAMIAN <alexandru.damian@intel.com>

Patch to store variable configuration for a build using
the getAllKeysWithFlags command. Only variables that are
not functions are saved.

Minor fixes to the Variable model as to match data we receive.

Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com>
---
 bitbake/lib/bb/ui/buildinfohelper.py | 15 +++++++++++++--
 bitbake/lib/webhob/orm/models.py     |  6 +++---
 2 files changed, 16 insertions(+), 5 deletions(-)

Patch

diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index 6f4789c..89d5f15 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -9,7 +9,7 @@  os.environ.setdefault("DJANGO_SETTINGS_MODULE", "webhob.whbmain.settings")
 
 import webhob.whbmain.settings as whb_django_settings
 from webhob.orm.models import Machine, Build, Task, Recipe, Layer_Version, Layer, Package, LogMessage
-from webhob.orm.models import Task_Dependency, Package_Dependency
+from webhob.orm.models import Task_Dependency, Package_Dependency, Variable
 from bb.msg import BBLogFormatter as format
 
 class ORMWrapper(object):
@@ -146,6 +146,15 @@  class ORMWrapper(object):
 
         return log_object.save()
 
+    def save_build_variables(self, build_obj, vardump):
+        for k in vardump:
+            if not bool(vardump[k]['func']):
+                Variable.objects.create( build = build_obj,
+                    variable_name = k,
+                    variable_value = vardump[k]['v'],
+                    description = vardump[k]['doc'])
+
+
 class BuildInfoHelper(object):
     """ This class gathers the build information from the server and sends it
         towards the ORM wrapper for storing in the database
@@ -363,13 +372,15 @@  class BuildInfoHelper(object):
         build_obj = self.orm_wrapper.create_build_object(build_information)
         self.internal_state['build'] = build_obj
         self.internal_state['target'] = build_information['target']
+        # Load layer information for the build
         self.internal_state['layer_versions'] = []
         for layer_object in self.internal_state['layers']:
             layer_version_information = self._get_layer_version_information(layer_object)
             self.internal_state['layer_versions'].append(self.orm_wrapper.get_layer_version_object(layer_version_information))
 
         del self.internal_state['layers']
-
+        # Save build configuration
+        self.orm_wrapper.save_build_variables(build_obj, self.server.runCommand(["getAllKeysWithFlags", ["doc", "func"]])[0])
 
 
     def update_build_information(self, event, errors, warnings, taskfailures):
diff --git a/bitbake/lib/webhob/orm/models.py b/bitbake/lib/webhob/orm/models.py
index f51f53d..1d67e40 100644
--- a/bitbake/lib/webhob/orm/models.py
+++ b/bitbake/lib/webhob/orm/models.py
@@ -161,11 +161,11 @@  class Layer_Version(models.Model):
 class Variable(models.Model):
     build = models.ForeignKey(Build, related_name='variable_build')
     variable_name = models.CharField(max_length=100)
-    variable_value = models.TextField()
+    variable_value = models.TextField(null=True)
     file = models.FilePathField(max_length=255)
-    changed = models.BooleanField()
+    changed = models.BooleanField(default=False)
     human_readable_name = models.CharField(max_length=200)
-    description = models.TextField()
+    description = models.TextField(null=True)
 
 
 class Machine(models.Model):