summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Wood <michael.g.wood@intel.com>2016-02-10 11:51:44 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-10 13:33:40 +0000
commite0eb2ea48864b7b91a89d1b60c4fff6dddbe15e6 (patch)
tree3d603053e98ae678bdb8babec4d64ea1389170fa
parent48622e1d6b9a04a301961b995ae26eb3ad9f72e7 (diff)
downloadpoky-e0eb2ea48864b7b91a89d1b60c4fff6dddbe15e6.tar.gz
bitbake: toaster: models Remove manual transaction control from lsupdates
Revert "toaster: models.py do not use transactions". This reverts commit e248a503ba84658dea086e65e9cde8b845b9c0ed (Bitbake rev: 48d0d510816346073f135bb86fb7904fdb50bb27) Manually managing the database transactions caused more problems than it temporarily solved so we return control back to Django's orm. [YOCTO #8796] (Bitbake rev: 25c531915b6f8f79a0822996ceb97f90483e359f) Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Elliot Smith <elliot.smith@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/toaster/orm/models.py23
1 files changed, 1 insertions, 22 deletions
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 183cc3218c..ab6940feaf 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -1097,8 +1097,7 @@ class LayerIndexLayerSource(LayerSource):
1097 1097
1098 # update layers 1098 # update layers
1099 layers_info = _get_json_response(apilinks['layerItems']) 1099 layers_info = _get_json_response(apilinks['layerItems'])
1100 if not connection.features.autocommits_when_autocommit_is_off: 1100
1101 transaction.set_autocommit(False)
1102 for li in layers_info: 1101 for li in layers_info:
1103 # Special case for the openembedded-core layer 1102 # Special case for the openembedded-core layer
1104 if li['name'] == oe_core_layer: 1103 if li['name'] == oe_core_layer:
@@ -1130,17 +1129,12 @@ class LayerIndexLayerSource(LayerSource):
1130 l.description = li['description'] 1129 l.description = li['description']
1131 l.save() 1130 l.save()
1132 1131
1133 if not connection.features.autocommits_when_autocommit_is_off:
1134 transaction.set_autocommit(True)
1135
1136 # update layerbranches/layer_versions 1132 # update layerbranches/layer_versions
1137 logger.debug("Fetching layer information") 1133 logger.debug("Fetching layer information")
1138 layerbranches_info = _get_json_response(apilinks['layerBranches'] 1134 layerbranches_info = _get_json_response(apilinks['layerBranches']
1139 + "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), [i for i in Branch.objects.filter(layer_source = self) if i.up_id is not None] )) 1135 + "?filter=branch:%s" % "OR".join(map(lambda x: str(x.up_id), [i for i in Branch.objects.filter(layer_source = self) if i.up_id is not None] ))
1140 ) 1136 )
1141 1137
1142 if not connection.features.autocommits_when_autocommit_is_off:
1143 transaction.set_autocommit(False)
1144 for lbi in layerbranches_info: 1138 for lbi in layerbranches_info:
1145 lv, created = Layer_Version.objects.get_or_create(layer_source = self, 1139 lv, created = Layer_Version.objects.get_or_create(layer_source = self,
1146 up_id = lbi['id'], 1140 up_id = lbi['id'],
@@ -1153,14 +1147,10 @@ class LayerIndexLayerSource(LayerSource):
1153 lv.commit = lbi['actual_branch'] 1147 lv.commit = lbi['actual_branch']
1154 lv.dirpath = lbi['vcs_subdir'] 1148 lv.dirpath = lbi['vcs_subdir']
1155 lv.save() 1149 lv.save()
1156 if not connection.features.autocommits_when_autocommit_is_off:
1157 transaction.set_autocommit(True)
1158 1150
1159 # update layer dependencies 1151 # update layer dependencies
1160 layerdependencies_info = _get_json_response(apilinks['layerDependencies']) 1152 layerdependencies_info = _get_json_response(apilinks['layerDependencies'])
1161 dependlist = {} 1153 dependlist = {}
1162 if not connection.features.autocommits_when_autocommit_is_off:
1163 transaction.set_autocommit(False)
1164 for ldi in layerdependencies_info: 1154 for ldi in layerdependencies_info:
1165 try: 1155 try:
1166 lv = Layer_Version.objects.get(layer_source = self, up_id = ldi['layerbranch']) 1156 lv = Layer_Version.objects.get(layer_source = self, up_id = ldi['layerbranch'])
@@ -1178,8 +1168,6 @@ class LayerIndexLayerSource(LayerSource):
1178 LayerVersionDependency.objects.filter(layer_version = lv).delete() 1168 LayerVersionDependency.objects.filter(layer_version = lv).delete()
1179 for lvd in dependlist[lv]: 1169 for lvd in dependlist[lv]:
1180 LayerVersionDependency.objects.get_or_create(layer_version = lv, depends_on = lvd) 1170 LayerVersionDependency.objects.get_or_create(layer_version = lv, depends_on = lvd)
1181 if not connection.features.autocommits_when_autocommit_is_off:
1182 transaction.set_autocommit(True)
1183 1171
1184 1172
1185 # update machines 1173 # update machines
@@ -1188,8 +1176,6 @@ class LayerIndexLayerSource(LayerSource):
1188 + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) 1176 + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self)))
1189 ) 1177 )
1190 1178
1191 if not connection.features.autocommits_when_autocommit_is_off:
1192 transaction.set_autocommit(False)
1193 for mi in machines_info: 1179 for mi in machines_info:
1194 mo, created = Machine.objects.get_or_create(layer_source = self, up_id = mi['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch'])) 1180 mo, created = Machine.objects.get_or_create(layer_source = self, up_id = mi['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = mi['layerbranch']))
1195 mo.up_date = mi['updated'] 1181 mo.up_date = mi['updated']
@@ -1197,16 +1183,11 @@ class LayerIndexLayerSource(LayerSource):
1197 mo.description = mi['description'] 1183 mo.description = mi['description']
1198 mo.save() 1184 mo.save()
1199 1185
1200 if not connection.features.autocommits_when_autocommit_is_off:
1201 transaction.set_autocommit(True)
1202
1203 # update recipes; paginate by layer version / layer branch 1186 # update recipes; paginate by layer version / layer branch
1204 logger.debug("Fetching target information") 1187 logger.debug("Fetching target information")
1205 recipes_info = _get_json_response(apilinks['recipes'] 1188 recipes_info = _get_json_response(apilinks['recipes']
1206 + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self))) 1189 + "?filter=layerbranch:%s" % "OR".join(map(lambda x: str(x.up_id), Layer_Version.objects.filter(layer_source = self)))
1207 ) 1190 )
1208 if not connection.features.autocommits_when_autocommit_is_off:
1209 transaction.set_autocommit(False)
1210 for ri in recipes_info: 1191 for ri in recipes_info:
1211 try: 1192 try:
1212 ro, created = Recipe.objects.get_or_create(layer_source = self, up_id = ri['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = ri['layerbranch'])) 1193 ro, created = Recipe.objects.get_or_create(layer_source = self, up_id = ri['id'], layer_version = Layer_Version.objects.get(layer_source = self, up_id = ri['layerbranch']))
@@ -1228,8 +1209,6 @@ class LayerIndexLayerSource(LayerSource):
1228 except IntegrityError as e: 1209 except IntegrityError as e:
1229 logger.debug("Failed saving recipe, ignoring: %s (%s:%s)" % (e, ro.layer_version, ri['filepath']+"/"+ri['filename'])) 1210 logger.debug("Failed saving recipe, ignoring: %s (%s:%s)" % (e, ro.layer_version, ri['filepath']+"/"+ri['filename']))
1230 ro.delete() 1211 ro.delete()
1231 if not connection.features.autocommits_when_autocommit_is_off:
1232 transaction.set_autocommit(True)
1233 1212
1234class BitbakeVersion(models.Model): 1213class BitbakeVersion(models.Model):
1235 1214