summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2015-09-28 21:45:27 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-29 14:11:38 +0100
commit922503f4c1d664edc5d3c0f66f262b3b4c3e5c56 (patch)
treeaf791653d208cc5674dd75b4ca3ca93896f42b6a
parent0bc0a44affe689422fb8d05b19e06338f6901629 (diff)
downloadpoky-922503f4c1d664edc5d3c0f66f262b3b4c3e5c56.tar.gz
bitbake: toaster: Create a relationship between build information and toaster layers
Previously this layer relationship was done by trying to match path information that came back to the buildinfohelper with trying to query for data in toaster's layers table. This rarely matched due to the lose coupling. (Bitbake rev: 838e77c7c3c4006abd1327343a004590ab652de9) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: brian avery <avery.brian@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/ui/buildinfohelper.py30
-rw-r--r--bitbake/lib/toaster/bldcontrol/migrations/0009_auto__add_field_brlayer_layer_version.py180
-rw-r--r--bitbake/lib/toaster/bldcontrol/models.py3
-rw-r--r--bitbake/lib/toaster/orm/models.py2
4 files changed, 211 insertions, 4 deletions
diff --git a/bitbake/lib/bb/ui/buildinfohelper.py b/bitbake/lib/bb/ui/buildinfohelper.py
index 5098448c97..d0efaa9778 100644
--- a/bitbake/lib/bb/ui/buildinfohelper.py
+++ b/bitbake/lib/bb/ui/buildinfohelper.py
@@ -94,8 +94,8 @@ class ORMWrapper(object):
94 94
95 created = False 95 created = False
96 if not key in vars(self)[dictname].keys(): 96 if not key in vars(self)[dictname].keys():
97 vars(self)[dictname][key] = clazz.objects.create(**kwargs) 97 vars(self)[dictname][key], created = \
98 created = True 98 clazz.objects.get_or_create(**kwargs)
99 99
100 return (vars(self)[dictname][key], created) 100 return (vars(self)[dictname][key], created)
101 101
@@ -271,6 +271,17 @@ class ORMWrapper(object):
271 return recipe_object 271 return recipe_object
272 272
273 def get_update_layer_version_object(self, build_obj, layer_obj, layer_version_information): 273 def get_update_layer_version_object(self, build_obj, layer_obj, layer_version_information):
274 if isinstance(layer_obj, Layer_Version):
275 # We already found our layer version for this build so just
276 # update it with the new build information
277 logger.debug("We found our layer from toaster")
278 layer_obj.build = build_obj
279 layer_obj.local_path = layer_version_information['local_path']
280 layer_obj.commit = layer_version_information['commit']
281 layer_obj.save()
282 self.layer_version_objects.append(layer_obj)
283 return layer_obj
284
274 assert isinstance(build_obj, Build) 285 assert isinstance(build_obj, Build)
275 assert isinstance(layer_obj, Layer) 286 assert isinstance(layer_obj, Layer)
276 assert 'branch' in layer_version_information 287 assert 'branch' in layer_version_information
@@ -320,8 +331,15 @@ class ORMWrapper(object):
320 localdirname = os.path.join(bc.be.sourcedir, localdirname) 331 localdirname = os.path.join(bc.be.sourcedir, localdirname)
321 #logger.debug(1, "Localdirname %s lcal_path %s" % (localdirname, layer_information['local_path'])) 332 #logger.debug(1, "Localdirname %s lcal_path %s" % (localdirname, layer_information['local_path']))
322 if localdirname.startswith(layer_information['local_path']): 333 if localdirname.startswith(layer_information['local_path']):
334 # If the build request came from toaster this field
335 # should contain the information from the layer_version
336 # That created this build request.
337 if brl.layer_version:
338 return brl.layer_version
339
323 # we matched the BRLayer, but we need the layer_version that generated this BR; reverse of the Project.schedule_build() 340 # we matched the BRLayer, but we need the layer_version that generated this BR; reverse of the Project.schedule_build()
324 #logger.debug(1, "Matched %s to BRlayer %s" % (pformat(layer_information["local_path"]), localdirname)) 341 #logger.debug(1, "Matched %s to BRlayer %s" % (pformat(layer_information["local_path"]), localdirname))
342
325 for pl in buildrequest.project.projectlayer_set.filter(layercommit__layer__name = brl.name): 343 for pl in buildrequest.project.projectlayer_set.filter(layercommit__layer__name = brl.name):
326 if pl.layercommit.layer.vcs_url == brl.giturl : 344 if pl.layercommit.layer.vcs_url == brl.giturl :
327 layer = pl.layercommit.layer 345 layer = pl.layercommit.layer
@@ -674,6 +692,7 @@ class BuildInfoHelper(object):
674 def __init__(self, server, has_build_history = False): 692 def __init__(self, server, has_build_history = False):
675 self.internal_state = {} 693 self.internal_state = {}
676 self.internal_state['taskdata'] = {} 694 self.internal_state['taskdata'] = {}
695 self.internal_state['targets'] = []
677 self.task_order = 0 696 self.task_order = 0
678 self.autocommit_step = 1 697 self.autocommit_step = 1
679 self.server = server 698 self.server = server
@@ -752,8 +771,15 @@ class BuildInfoHelper(object):
752 if not localdirname.startswith("/"): 771 if not localdirname.startswith("/"):
753 localdirname = os.path.join(bc.be.sourcedir, localdirname) 772 localdirname = os.path.join(bc.be.sourcedir, localdirname)
754 if path.startswith(localdirname): 773 if path.startswith(localdirname):
774 # If the build request came from toaster this field
775 # should contain the information from the layer_version
776 # That created this build request.
777 if brl.layer_version:
778 return brl.layer_version
779
755 #logger.warn("-- managed: matched path %s with layer %s " % (path, localdirname)) 780 #logger.warn("-- managed: matched path %s with layer %s " % (path, localdirname))
756 # we matched the BRLayer, but we need the layer_version that generated this br 781 # we matched the BRLayer, but we need the layer_version that generated this br
782
757 for lvo in self.orm_wrapper.layer_version_objects: 783 for lvo in self.orm_wrapper.layer_version_objects:
758 if brl.name == lvo.layer.name: 784 if brl.name == lvo.layer.name:
759 return lvo 785 return lvo
diff --git a/bitbake/lib/toaster/bldcontrol/migrations/0009_auto__add_field_brlayer_layer_version.py b/bitbake/lib/toaster/bldcontrol/migrations/0009_auto__add_field_brlayer_layer_version.py
new file mode 100644
index 0000000000..9b50bc1c03
--- /dev/null
+++ b/bitbake/lib/toaster/bldcontrol/migrations/0009_auto__add_field_brlayer_layer_version.py
@@ -0,0 +1,180 @@
1# -*- coding: utf-8 -*-
2from south.utils import datetime_utils as datetime
3from south.db import db
4from south.v2 import SchemaMigration
5from django.db import models
6
7
8class Migration(SchemaMigration):
9
10 def forwards(self, orm):
11 # Adding field 'BRLayer.layer_version'
12 db.add_column(u'bldcontrol_brlayer', 'layer_version',
13 self.gf('django.db.models.fields.related.ForeignKey')(to=orm['orm.Layer_Version'], null=True),
14 keep_default=False)
15
16
17 def backwards(self, orm):
18 # Deleting field 'BRLayer.layer_version'
19 db.delete_column(u'bldcontrol_brlayer', 'layer_version_id')
20
21
22 models = {
23 u'bldcontrol.brbitbake': {
24 'Meta': {'object_name': 'BRBitbake'},
25 'commit': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
26 'dirpath': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
27 'giturl': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
28 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
29 'req': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['bldcontrol.BuildRequest']", 'unique': 'True'})
30 },
31 u'bldcontrol.brerror': {
32 'Meta': {'object_name': 'BRError'},
33 'errmsg': ('django.db.models.fields.TextField', [], {}),
34 'errtype': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
35 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
36 'req': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['bldcontrol.BuildRequest']"}),
37 'traceback': ('django.db.models.fields.TextField', [], {})
38 },
39 u'bldcontrol.brlayer': {
40 'Meta': {'object_name': 'BRLayer'},
41 'commit': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
42 'dirpath': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
43 'giturl': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
44 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
45 'layer_version': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Layer_Version']", 'null': 'True'}),
46 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
47 'req': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['bldcontrol.BuildRequest']"})
48 },
49 u'bldcontrol.brtarget': {
50 'Meta': {'object_name': 'BRTarget'},
51 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
52 'req': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['bldcontrol.BuildRequest']"}),
53 'target': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
54 'task': ('django.db.models.fields.CharField', [], {'max_length': '100', 'null': 'True'})
55 },
56 u'bldcontrol.brvariable': {
57 'Meta': {'object_name': 'BRVariable'},
58 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
59 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
60 'req': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['bldcontrol.BuildRequest']"}),
61 'value': ('django.db.models.fields.TextField', [], {'blank': 'True'})
62 },
63 u'bldcontrol.buildenvironment': {
64 'Meta': {'object_name': 'BuildEnvironment'},
65 'address': ('django.db.models.fields.CharField', [], {'max_length': '254'}),
66 'bbaddress': ('django.db.models.fields.CharField', [], {'max_length': '254', 'blank': 'True'}),
67 'bbport': ('django.db.models.fields.IntegerField', [], {'default': '-1'}),
68 'bbstate': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
69 'bbtoken': ('django.db.models.fields.CharField', [], {'max_length': '126', 'blank': 'True'}),
70 'betype': ('django.db.models.fields.IntegerField', [], {}),
71 'builddir': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
72 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
73 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
74 'lock': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
75 'sourcedir': ('django.db.models.fields.CharField', [], {'max_length': '512', 'blank': 'True'}),
76 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
77 },
78 u'bldcontrol.buildrequest': {
79 'Meta': {'object_name': 'BuildRequest'},
80 'build': ('django.db.models.fields.related.OneToOneField', [], {'to': u"orm['orm.Build']", 'unique': 'True', 'null': 'True'}),
81 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
82 'environment': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['bldcontrol.BuildEnvironment']", 'null': 'True'}),
83 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
84 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Project']"}),
85 'state': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
86 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'})
87 },
88 u'orm.bitbakeversion': {
89 'Meta': {'object_name': 'BitbakeVersion'},
90 'branch': ('django.db.models.fields.CharField', [], {'max_length': '32'}),
91 'dirpath': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
92 'giturl': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
93 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
94 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'})
95 },
96 u'orm.branch': {
97 'Meta': {'unique_together': "(('layer_source', 'name'), ('layer_source', 'up_id'))", 'object_name': 'Branch'},
98 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
99 'layer_source': ('django.db.models.fields.related.ForeignKey', [], {'default': 'True', 'to': u"orm['orm.LayerSource']", 'null': 'True'}),
100 'name': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
101 'short_description': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
102 'up_date': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),
103 'up_id': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True'})
104 },
105 u'orm.build': {
106 'Meta': {'object_name': 'Build'},
107 'bitbake_version': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
108 'build_name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
109 'completed_on': ('django.db.models.fields.DateTimeField', [], {}),
110 'cooker_log_path': ('django.db.models.fields.CharField', [], {'max_length': '500'}),
111 'distro': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
112 'distro_version': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
113 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
114 'machine': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
115 'outcome': ('django.db.models.fields.IntegerField', [], {'default': '2'}),
116 'project': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Project']"}),
117 'started_on': ('django.db.models.fields.DateTimeField', [], {})
118 },
119 u'orm.layer': {
120 'Meta': {'unique_together': "(('layer_source', 'up_id'), ('layer_source', 'name'))", 'object_name': 'Layer'},
121 'description': ('django.db.models.fields.TextField', [], {'default': 'None', 'null': 'True'}),
122 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
123 'layer_index_url': ('django.db.models.fields.URLField', [], {'max_length': '200'}),
124 'layer_source': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['orm.LayerSource']", 'null': 'True'}),
125 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
126 'summary': ('django.db.models.fields.TextField', [], {'default': 'None', 'null': 'True'}),
127 'up_date': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),
128 'up_id': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True'}),
129 'vcs_url': ('django.db.models.fields.URLField', [], {'default': 'None', 'max_length': '200', 'null': 'True'}),
130 'vcs_web_file_base_url': ('django.db.models.fields.URLField', [], {'default': 'None', 'max_length': '200', 'null': 'True'}),
131 'vcs_web_tree_base_url': ('django.db.models.fields.URLField', [], {'default': 'None', 'max_length': '200', 'null': 'True'}),
132 'vcs_web_url': ('django.db.models.fields.URLField', [], {'default': 'None', 'max_length': '200', 'null': 'True'})
133 },
134 u'orm.layer_version': {
135 'Meta': {'unique_together': "(('layer_source', 'up_id'),)", 'object_name': 'Layer_Version'},
136 'branch': ('django.db.models.fields.CharField', [], {'max_length': '80'}),
137 'build': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'related_name': "'layer_version_build'", 'null': 'True', 'to': u"orm['orm.Build']"}),
138 'commit': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
139 'dirpath': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True'}),
140 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
141 'layer': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'layer_version_layer'", 'to': u"orm['orm.Layer']"}),
142 'layer_source': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['orm.LayerSource']", 'null': 'True'}),
143 'local_path': ('django.db.models.fields.FilePathField', [], {'default': "'/'", 'max_length': '1024'}),
144 'priority': ('django.db.models.fields.IntegerField', [], {'default': '0'}),
145 'project': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['orm.Project']", 'null': 'True'}),
146 'up_branch': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': u"orm['orm.Branch']", 'null': 'True'}),
147 'up_date': ('django.db.models.fields.DateTimeField', [], {'default': 'None', 'null': 'True'}),
148 'up_id': ('django.db.models.fields.IntegerField', [], {'default': 'None', 'null': 'True'})
149 },
150 u'orm.layersource': {
151 'Meta': {'unique_together': "(('sourcetype', 'apiurl'),)", 'object_name': 'LayerSource'},
152 'apiurl': ('django.db.models.fields.CharField', [], {'default': 'None', 'max_length': '255', 'null': 'True'}),
153 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
154 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '63'}),
155 'sourcetype': ('django.db.models.fields.IntegerField', [], {})
156 },
157 u'orm.project': {
158 'Meta': {'object_name': 'Project'},
159 'bitbake_version': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.BitbakeVersion']", 'null': 'True'}),
160 'created': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
161 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
162 'is_default': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
163 'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
164 'release': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.Release']", 'null': 'True'}),
165 'short_description': ('django.db.models.fields.CharField', [], {'max_length': '50', 'blank': 'True'}),
166 'updated': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
167 'user_id': ('django.db.models.fields.IntegerField', [], {'null': 'True'})
168 },
169 u'orm.release': {
170 'Meta': {'object_name': 'Release'},
171 'bitbake_version': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['orm.BitbakeVersion']"}),
172 'branch_name': ('django.db.models.fields.CharField', [], {'default': "''", 'max_length': '50'}),
173 'description': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
174 'helptext': ('django.db.models.fields.TextField', [], {'null': 'True'}),
175 u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
176 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '32'})
177 }
178 }
179
180 complete_apps = ['bldcontrol'] \ No newline at end of file
diff --git a/bitbake/lib/toaster/bldcontrol/models.py b/bitbake/lib/toaster/bldcontrol/models.py
index b61de58a3e..f2493a8426 100644
--- a/bitbake/lib/toaster/bldcontrol/models.py
+++ b/bitbake/lib/toaster/bldcontrol/models.py
@@ -1,6 +1,6 @@
1from django.db import models 1from django.db import models
2from django.core.validators import MaxValueValidator, MinValueValidator 2from django.core.validators import MaxValueValidator, MinValueValidator
3from orm.models import Project, ProjectLayer, ProjectVariable, ProjectTarget, Build 3from orm.models import Project, ProjectLayer, ProjectVariable, ProjectTarget, Build, Layer_Version
4 4
5# a BuildEnvironment is the equivalent of the "build/" directory on the localhost 5# a BuildEnvironment is the equivalent of the "build/" directory on the localhost
6class BuildEnvironment(models.Model): 6class BuildEnvironment(models.Model):
@@ -137,6 +137,7 @@ class BRLayer(models.Model):
137 giturl = models.CharField(max_length = 254) 137 giturl = models.CharField(max_length = 254)
138 commit = models.CharField(max_length = 254) 138 commit = models.CharField(max_length = 254)
139 dirpath = models.CharField(max_length = 254) 139 dirpath = models.CharField(max_length = 254)
140 layer_version = models.ForeignKey(Layer_Version, null=True)
140 141
141class BRBitbake(models.Model): 142class BRBitbake(models.Model):
142 req = models.ForeignKey(BuildRequest, unique = True) # only one bitbake for a request 143 req = models.ForeignKey(BuildRequest, unique = True) # only one bitbake for a request
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 4025702fbc..8d7388e2e6 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -260,7 +260,7 @@ class Project(models.Model):
260 for l in self.projectlayer_set.all().order_by("pk"): 260 for l in self.projectlayer_set.all().order_by("pk"):
261 commit = l.layercommit.get_vcs_reference() 261 commit = l.layercommit.get_vcs_reference()
262 print("ii Building layer ", l.layercommit.layer.name, " at vcs point ", commit) 262 print("ii Building layer ", l.layercommit.layer.name, " at vcs point ", commit)
263 BRLayer.objects.create(req = br, name = l.layercommit.layer.name, giturl = l.layercommit.layer.vcs_url, commit = commit, dirpath = l.layercommit.dirpath) 263 BRLayer.objects.create(req = br, name = l.layercommit.layer.name, giturl = l.layercommit.layer.vcs_url, commit = commit, dirpath = l.layercommit.dirpath, layer_version=l.layercommit)
264 264
265 br.state = BuildRequest.REQ_QUEUED 265 br.state = BuildRequest.REQ_QUEUED
266 now = timezone.now() 266 now = timezone.now()