summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm
diff options
context:
space:
mode:
authorDavid Reyna <David.Reyna@windriver.com>2017-06-27 13:44:30 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-06-28 16:02:15 +0100
commit4f2baebf362d71351db044c0646f9bc6e8a39c49 (patch)
treebcbb07afbe24816f35d0c9d616ac5ea1fcca7f17 /bitbake/lib/toaster/orm
parent43aaa802c35ecc9d972f3b9adcd060033de1d9de (diff)
downloadpoky-4f2baebf362d71351db044c0646f9bc6e8a39c49.tar.gz
bitbake: toaster: Add distro selection support
Add the ability to select a distro in the project page, based on values from the Layer Index. Add a distro selection page with the add layer feature, based on the add machine page. [YOCTO #10632] (Bitbake rev: a156a4eff67cdc3943494f5be72b96e3db656250) Signed-off-by: David Reyna <David.Reyna@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm')
-rw-r--r--bitbake/lib/toaster/orm/management/commands/lsupdates.py19
-rw-r--r--bitbake/lib/toaster/orm/migrations/0017_distro_clone.py25
-rw-r--r--bitbake/lib/toaster/orm/models.py31
3 files changed, 75 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/orm/management/commands/lsupdates.py b/bitbake/lib/toaster/orm/management/commands/lsupdates.py
index 90f07c9dc5..0b0d4ff8f9 100644
--- a/bitbake/lib/toaster/orm/management/commands/lsupdates.py
+++ b/bitbake/lib/toaster/orm/management/commands/lsupdates.py
@@ -23,6 +23,7 @@ from django.core.management.base import BaseCommand
23 23
24from orm.models import LayerSource, Layer, Release, Layer_Version 24from orm.models import LayerSource, Layer, Release, Layer_Version
25from orm.models import LayerVersionDependency, Machine, Recipe 25from orm.models import LayerVersionDependency, Machine, Recipe
26from orm.models import Distro
26 27
27import os 28import os
28import sys 29import sys
@@ -249,6 +250,24 @@ class Command(BaseCommand):
249 depends_on=lvd) 250 depends_on=lvd)
250 self.mini_progress("Layer version dependencies", i, total) 251 self.mini_progress("Layer version dependencies", i, total)
251 252
253 # update Distros
254 logger.info("Fetching distro information")
255 distros_info = _get_json_response(
256 apilinks['distros'] + "?filter=layerbranch__branch__name:%s" %
257 "OR".join(whitelist_branch_names))
258
259 total = len(distros_info)
260 for i, di in enumerate(distros_info):
261 distro, created = Distro.objects.get_or_create(
262 name=di['name'],
263 layer_version=Layer_Version.objects.get(
264 pk=li_layer_branch_id_to_toaster_lv_id[di['layerbranch']]))
265 distro.up_date = di['updated']
266 distro.name = di['name']
267 distro.description = di['description']
268 distro.save()
269 self.mini_progress("distros", i, total)
270
252 # update machines 271 # update machines
253 logger.info("Fetching machine information") 272 logger.info("Fetching machine information")
254 machines_info = _get_json_response( 273 machines_info = _get_json_response(
diff --git a/bitbake/lib/toaster/orm/migrations/0017_distro_clone.py b/bitbake/lib/toaster/orm/migrations/0017_distro_clone.py
new file mode 100644
index 0000000000..d3c5901275
--- /dev/null
+++ b/bitbake/lib/toaster/orm/migrations/0017_distro_clone.py
@@ -0,0 +1,25 @@
1# -*- coding: utf-8 -*-
2from __future__ import unicode_literals
3
4from django.db import migrations, models
5
6class Migration(migrations.Migration):
7
8 dependencies = [
9 ('orm', '0016_clone_progress'),
10 ]
11
12 operations = [
13 migrations.CreateModel(
14 name='Distro',
15 fields=[
16 ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
17 ('up_id', models.IntegerField(default=None, null=True)),
18 ('up_date', models.DateTimeField(default=None, null=True)),
19 ('name', models.CharField(max_length=255)),
20 ('description', models.CharField(max_length=255)),
21 ('layer_version', models.ForeignKey(to='orm.Layer_Version')),
22 ],
23 ),
24 ]
25
diff --git a/bitbake/lib/toaster/orm/models.py b/bitbake/lib/toaster/orm/models.py
index 13bd11704a..5c14727a70 100644
--- a/bitbake/lib/toaster/orm/models.py
+++ b/bitbake/lib/toaster/orm/models.py
@@ -321,6 +321,22 @@ class Project(models.Model):
321 321
322 return queryset 322 return queryset
323 323
324 def get_available_distros(self):
325 """ Returns QuerySet of all Distros which are provided by the
326 Layers currently added to the Project """
327 queryset = Distro.objects.filter(
328 layer_version__in=self.get_project_layer_versions())
329
330 return queryset
331
332 def get_all_compatible_distros(self):
333 """ Returns QuerySet of all the compatible Wind River distros available to the
334 project including ones from Layers not currently added """
335 queryset = Distro.objects.filter(
336 layer_version__in=self.get_all_compatible_layer_versions())
337
338 return queryset
339
324 def get_available_recipes(self): 340 def get_available_recipes(self):
325 """ Returns QuerySet of all the recipes that are provided by layers 341 """ Returns QuerySet of all the recipes that are provided by layers
326 added to this project """ 342 added to this project """
@@ -1795,6 +1811,21 @@ def signal_runbuilds():
1795 except FileNotFoundError: 1811 except FileNotFoundError:
1796 logger.info("Stopping existing runbuilds: no current process found") 1812 logger.info("Stopping existing runbuilds: no current process found")
1797 1813
1814class Distro(models.Model):
1815 search_allowed_fields = ["name", "description", "layer_version__layer__name"]
1816 up_date = models.DateTimeField(null = True, default = None)
1817
1818 layer_version = models.ForeignKey('Layer_Version')
1819 name = models.CharField(max_length=255)
1820 description = models.CharField(max_length=255)
1821
1822 def get_vcs_distro_file_link_url(self):
1823 path = self.name+'.conf'
1824 return self.layer_version.get_vcs_file_link_url(path)
1825
1826 def __unicode__(self):
1827 return "Distro " + self.name + "(" + self.description + ")"
1828
1798django.db.models.signals.post_save.connect(invalidate_cache) 1829django.db.models.signals.post_save.connect(invalidate_cache)
1799django.db.models.signals.post_delete.connect(invalidate_cache) 1830django.db.models.signals.post_delete.connect(invalidate_cache)
1800django.db.models.signals.m2m_changed.connect(invalidate_cache) 1831django.db.models.signals.m2m_changed.connect(invalidate_cache)