summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastermain/management
diff options
context:
space:
mode:
authorAlexandru DAMIAN <alexandru.damian@intel.com>2015-06-23 10:44:42 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-06-26 09:27:32 +0100
commit8ef5165b5accaffa59a51a2316ed3304680da224 (patch)
treefa244fc802da65c379bfecad8d6f774a8524ed31 /bitbake/lib/toaster/toastermain/management
parent5d0abf197a513f09fa980b9aed1a02822639b7f0 (diff)
downloadpoky-8ef5165b5accaffa59a51a2316ed3304680da224.tar.gz
bitbake: toaster: delete multiple builds
This patch fixes the build deletion on unmigrated databases, and enhances it to delete multiple builds in a single run. [YOCTO #7726] (Bitbake rev: d5468d84c1ef83c780de5974c8e3a11eab762489) Signed-off-by: Alexandru DAMIAN <alexandru.damian@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastermain/management')
-rw-r--r--bitbake/lib/toaster/toastermain/management/commands/builddelete.py56
1 files changed, 36 insertions, 20 deletions
diff --git a/bitbake/lib/toaster/toastermain/management/commands/builddelete.py b/bitbake/lib/toaster/toastermain/management/commands/builddelete.py
index 5cec436714..343d3114c0 100644
--- a/bitbake/lib/toaster/toastermain/management/commands/builddelete.py
+++ b/bitbake/lib/toaster/toastermain/management/commands/builddelete.py
@@ -1,33 +1,49 @@
1from django.core.management.base import BaseCommand, CommandError 1from django.core.management.base import BaseCommand, CommandError
2from orm.models import Build 2from orm.models import Build
3from django.db import OperationalError
3import os 4import os
4 5
5 6
6 7
7class Command(BaseCommand): 8class Command(BaseCommand):
8 args = "buildId" 9 args = "buildId"
9 help = "Deletes selected build" 10 help = "Deletes selected build(s)"
10 11
11 def handle(self, buildId, *args, **options): 12 def handle(self, buildId, *args, **options):
12 b = Build.objects.get(pk = buildId) 13 for bid in buildId.split(","):
13 # theoretically, just b.delete() would suffice 14 b = Build.objects.get(pk = bid)
14 # however SQLite runs into problems when you try to 15 # theoretically, just b.delete() would suffice
15 # delete too many rows at once, so we delete some direct 16 # however SQLite runs into problems when you try to
16 # relationships from Build manually. 17 # delete too many rows at once, so we delete some direct
18 # relationships from Build manually.
19 for t in b.target_set.all():
20 t.delete()
21 for t in b.task_build.all():
22 t.delete()
23 for p in b.package_set.all():
24 p.delete()
25 for lv in b.layer_version_build.all():
26 lv.delete()
27 for v in b.variable_build.all():
28 v.delete()
29 for l in b.logmessage_set.all():
30 l.delete()
17 31
18 for t in b.target_set.all(): 32 # delete the build; some databases might have had problem with migration of the bldcontrol app
19 t.delete() 33 retry_count = 0
20 for t in b.task_build.all(): 34 need_bldcontrol_migration = False
21 t.delete() 35 while True:
22 for p in b.package_set.all(): 36 if retry_count >= 5:
23 p.delete() 37 break
24 for lv in b.layer_version_build.all(): 38 retry_count += 1
25 lv.delete() 39 if need_bldcontrol_migration:
26 for v in b.variable_build.all(): 40 from django.core import management
27 v.delete() 41 management.call_command('migrate', 'bldcontrol', interactive=False)
28 for l in b.logmessage_set.all():
29 l.delete()
30 42
31 # this should take care of the rest 43 try:
32 b.delete() 44 b.delete()
45 break
46 except OperationalError as e:
47 # execute migrations
48 need_bldcontrol_migration = True
33 49