summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py')
-rw-r--r--bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py b/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py
index c9af487d9d..6e1f97a9f9 100644
--- a/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py
+++ b/bitbake/lib/toaster/bldcontrol/management/commands/loadconf.py
@@ -1,6 +1,6 @@
1from django.core.management.base import BaseCommand, CommandError 1from django.core.management.base import BaseCommand, CommandError
2from orm.models import LayerSource, ToasterSetting, Branch, Layer, Layer_Version 2from orm.models import LayerSource, ToasterSetting, Branch, Layer, Layer_Version
3from orm.models import BitbakeVersion, Release, ReleaseDefaultLayer 3from orm.models import BitbakeVersion, Release, ReleaseDefaultLayer, ReleaseLayerSourcePriority
4import os 4import os
5 5
6from checksettings import DN 6from checksettings import DN
@@ -71,17 +71,23 @@ class Command(BaseCommand):
71 assert 'name' in lsi 71 assert 'name' in lsi
72 assert 'branches' in lsi 72 assert 'branches' in lsi
73 73
74 if lsi['sourcetype'] == LayerSource.TYPE_LAYERINDEX or lsi['apiurl'].startswith("/"): 74 def _get_id_for_sourcetype(s):
75 for i in LayerSource.SOURCE_TYPE:
76 if s == i[1]:
77 return i[0]
78 raise Exception("Could not find definition for sourcetype " + s)
79
80 if _get_id_for_sourcetype(lsi['sourcetype']) == LayerSource.TYPE_LAYERINDEX or lsi['apiurl'].startswith("/"):
75 apiurl = lsi['apiurl'] 81 apiurl = lsi['apiurl']
76 else: 82 else:
77 apiurl = self._reduce_canon_path(os.path.join(DN(filepath), lsi['apiurl'])) 83 apiurl = self._reduce_canon_path(os.path.join(DN(filepath), lsi['apiurl']))
78 84
79 try: 85 try:
80 ls = LayerSource.objects.get(sourcetype = lsi['sourcetype'], apiurl = apiurl) 86 ls = LayerSource.objects.get(sourcetype = _get_id_for_sourcetype(lsi['sourcetype']), apiurl = apiurl)
81 except LayerSource.DoesNotExist: 87 except LayerSource.DoesNotExist:
82 ls = LayerSource.objects.create( 88 ls = LayerSource.objects.create(
83 name = lsi['name'], 89 name = lsi['name'],
84 sourcetype = lsi['sourcetype'], 90 sourcetype = _get_id_for_sourcetype(lsi['sourcetype']),
85 apiurl = apiurl 91 apiurl = apiurl
86 ) 92 )
87 93
@@ -121,17 +127,20 @@ class Command(BaseCommand):
121 bvo = BitbakeVersion.objects.get(name = ri['bitbake']) 127 bvo = BitbakeVersion.objects.get(name = ri['bitbake'])
122 assert bvo is not None 128 assert bvo is not None
123 129
124 ro, created = Release.objects.get_or_create(name = ri['name'], bitbake_version = bvo, branch = Branch.objects.get( layer_source__name = ri['layersource'], name=ri['branch'])) 130 ro, created = Release.objects.get_or_create(name = ri['name'], bitbake_version = bvo, branch_name = ri['branch'])
125 ro.description = ri['description'] 131 ro.description = ri['description']
126 ro.helptext = ri['helptext'] 132 ro.helptext = ri['helptext']
127 ro.save() 133 ro.save()
128 134
135 # save layer source priority for release
136 for ls_name in ri['layersourcepriority'].keys():
137 rlspo, created = ReleaseLayerSourcePriority.objects.get_or_create(release = ro, layer_source = LayerSource.objects.get(name=ls_name))
138 rlspo.priority = ri['layersourcepriority'][ls_name]
139 rlspo.save()
140
129 for dli in ri['defaultlayers']: 141 for dli in ri['defaultlayers']:
130 layer, created = Layer.objects.get_or_create( 142 # find layers with the same name
131 layer_source = LayerSource.objects.get(name = ri['layersource']), 143 ReleaseDefaultLayer.objects.get_or_create( release = ro, layer_name = dli)
132 name = dli
133 )
134 ReleaseDefaultLayer.objects.get_or_create( release = ro, layer = layer)
135 144
136 # set default release 145 # set default release
137 if ToasterSetting.objects.filter(name = "DEFAULT_RELEASE").count() > 0: 146 if ToasterSetting.objects.filter(name = "DEFAULT_RELEASE").count() > 0: