toaster update database models patchset
cover toaster update database models patchset
From: Alexandru DAMIAN <[email protected]>
This patchset adds changes to the database that allow compatibility with the layerindex application. The functionality include:
* update layer information from the layer index application
* loading poky configuration file
* updates to UI to allow use of the new data
The information contained in this model suffices for displaying data in the designed 1.7 version.
Can you please review and pull at your convenience ?
Cheers,
Alex
The following changes since commit 5d858e23de8b15badc3ab7f56ad5160a76a89de1:
bitbake.conf: Drop unused MKTEMP* variables (2014-08-24 10:09:53 +0100)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib adamian/20140827-submission-bb
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=adamian/20140827-submission-bb
Alexandru DAMIAN (11):
toasterui: refactor log saving and save out-of-build errors
toaster: fix application discovery in settings.py
toaster: update orm models for layerindex compatibility
toaster: enable admin interface on select models
toaster: create project section navigation structure
toaster: add all layers page
toaster: update checksettings command for auto-detection
toaster: update the bldcontrol to the new orm models
toatergui: update pages to match project models
buildinfohelper: BuildRequest project file update soft linked
toaster: create Build methods for calculating progress and ETA
bin/toaster | 9 +- lib/bb/ui/buildinfohelper.py | 81 ++- lib/bb/ui/toasterui.py | 10 +- lib/toaster/bldcontrol/admin.py | 8 + lib/toaster/bldcontrol/bbcontroller.py | 35 +- .../management/commands/checksettings.py | 190 +++++- .../bldcontrol/management/commands/runbuilds.py | 2 +- .../migrations/0006_auto__add_brbitbake.py | 128 ++++ lib/toaster/bldcontrol/models.py | 5 + lib/toaster/orm/admin.py | 17 + lib/toaster/orm/management/__init__.py | 0 lib/toaster/orm/management/commands/__init__.py | 0 lib/toaster/orm/management/commands/lsupdates.py | 12 + ...erversiondependency__add_unique_layerversion.py | 710 +++++++++++++++++++++ lib/toaster/orm/models.py | 395 ++++++++++-- lib/toaster/orm/tests.py | 33 + lib/toaster/toastergui/templates/layers.html | 173 +++++ lib/toaster/toastergui/templates/newproject.html | 5 +- lib/toaster/toastergui/templates/project.html | 51 +- lib/toaster/toastergui/urls.py | 11 +- lib/toaster/toastergui/views.py | 138 +++- lib/toaster/toastermain/settings.py | 16 +- lib/toaster/toastermain/urls.py | 18 +- 23 files changed, 1891 insertions(+), 156 deletions(-) create mode 100644 lib/toaster/bldcontrol/admin.py create mode 100644 lib/toaster/bldcontrol/migrations/0006_auto__add_brbitbake.py create mode 100644 lib/toaster/orm/admin.py create mode 100644 lib/toaster/orm/management/__init__.py create mode 100644 lib/toaster/orm/management/commands/__init__.py create mode 100644 lib/toaster/orm/management/commands/lsupdates.py create mode 100644 lib/toaster/orm/migrations/0013_auto__add_release__add_layerversiondependency__add_unique_layerversion.py create mode 100644 lib/toaster/orm/tests.py create mode 100755 lib/toaster/toastergui/templates/layers.html
Signature · 1 line
1.9.1
PATCH 1/11 toasterui: refactor log saving and save out-of-build errors
From: Alexandru DAMIAN <[email protected]>
We refactor log saving to go through only one code path.
All logs that happened outside the build (i.e. before build starting) now will be logged to either toaster_ui.log if the build command ran in interactive mode, or to the build request errors if the command ran in managed mode.
This enables proper display of error logs in project page.
--- lib/bb/ui/buildinfohelper.py | 79 ++++++++++++++++++++++++++------------------ lib/bb/ui/toasterui.py | 10 +++--- 2 files changed, 51 insertions(+), 38 deletions(-)
lib/bb/ui/buildinfohelper.py +47 -32
@@ -480,6 +480,8 @@ class ORMWrapper(object): line_number = vh['line'], operation = vh['op']) +class MockEvent: pass # sometimes we mock an event, declare it here + class BuildInfoHelper(object): """ This class gathers the build information from the server and sends it towards the ORM wrapper for storing in the database
@@ -487,6 +489,7 @@ class BuildInfoHelper(object): Keeps in memory all data that needs matching before writing it to the database """ + def __init__(self, server, has_build_history = False): self._configure_django() self.internal_state = {}
@@ -496,6 +499,8 @@ class BuildInfoHelper(object): self.orm_wrapper = ORMWrapper() self.has_build_history = has_build_history self.tmp_dir = self.server.runCommand(["getVariable", "TMPDIR"])[0] + self.brbe = self.server.runCommand(["getVariable", "TOASTER_BRBE"])[0] + def _configure_django(self): # Add toaster to sys path for importing modules
@@ -607,9 +612,7 @@ class BuildInfoHelper(object): assert '_pkgs' in vars(event) build_information = self._get_build_information() - brbe = self.server.runCommand(["getVariable", "TOASTER_BRBE"])[0] - - build_obj = self.orm_wrapper.create_build_object(build_information, brbe) + build_obj = self.orm_wrapper.create_build_object(build_information, self.brbe) self.internal_state['build'] = build_obj
@@ -629,7 +632,8 @@ class BuildInfoHelper(object): # Save build configuration self.orm_wrapper.save_build_variables(build_obj, self.server.runCommand(["getAllKeysWithFlags", ["doc", "func"]])[0]) - return brbe + return self.brbe + def update_target_image_file(self, event):
@@ -773,7 +777,6 @@ class BuildInfoHelper(object): identifier = fn + taskname + "_setscene" recipe_information = self._get_recipe_information_from_taskfile(fn) recipe = self.orm_wrapper.get_update_recipe_object(recipe_information) - class MockEvent: pass mevent = MockEvent() mevent.taskname = taskname mevent.taskhash = taskhash
@@ -792,7 +795,6 @@ class BuildInfoHelper(object): identifier = fn + taskname + "_setscene" recipe_information = self._get_recipe_information_from_taskfile(fn) recipe = self.orm_wrapper.get_update_recipe_object(recipe_information) - class MockEvent: pass mevent = MockEvent() mevent.taskname = taskname mevent.taskhash = taskhash
@@ -929,7 +931,8 @@ class BuildInfoHelper(object): self.internal_state['recipes'], ) - def store_build_done(self, br_id, be_id): + def _store_build_done(self): + br_id, be_id = self.brbe.split(":") from bldcontrol.models import BuildEnvironment, BuildRequest be = BuildEnvironment.objects.get(pk = be_id) be.lock = BuildEnvironment.LOCK_LOCK
@@ -939,49 +942,61 @@ class BuildInfoHelper(object): br.build = self.internal_state['build'] br.save() - def _store_log_information(self, level, text): - log_information = {} - log_information['build'] = self.internal_state['build'] - log_information['level'] = level - log_information['message'] = text - self.orm_wrapper.create_logmessage(log_information) - - def store_log_info(self, text): - self._store_log_information(LogMessage.INFO, text) - - def store_log_warn(self, text): - self._store_log_information(LogMessage.WARNING, text) def store_log_error(self, text): - self._store_log_information(LogMessage.ERROR, text) + mockevent = MockEvent() + mockevent.levelno = format.ERROR + mockevent.msg = text + self.store_log_event(mockevent) def store_log_event(self, event): + if event.levelno < format.WARNING: + return + + if 'args' in vars(event): + event.msg = event.msg % event.args + + if not 'build' in self.internal_state: + if self.brbe is None: + if not 'backlog' in self.internal_state: + self.internal_state['backlog'] = [] + self.internal_state['backlog'].append(event) + else: # we're under Toaster control, post the errors to the build request + from bldcontrol.models import BuildRequest, BRError + br, be = brbe.split(":") + buildrequest = BuildRequest.objects.get(pk = br) + brerror = BRError.objects.create(req = buildrequest, errtype="build", errmsg = event.msg) + + return + if 'build' in self.internal_state and 'backlog' in self.internal_state: if len(self.internal_state['backlog']): tempevent = self.internal_state['backlog'].pop() - print "Saving stored event ", tempevent + print " Saving stored event ", tempevent self.store_log_event(tempevent) else: del self.internal_state['backlog'] - if event.levelno < format.WARNING: - return - - if not 'build' in self.internal_state: - print "Save event for later" - if not 'backlog' in self.internal_state: - self.internal_state['backlog'] = [] - self.internal_state['backlog'].append(event) - - return log_information = {} log_information['build'] = self.internal_state['build'] if event.levelno >= format.ERROR: - log_information['level'] = LogMessage.ERROR + log_information['level'] = event.levelno elif event.levelno == format.WARNING: log_information['level'] = LogMessage.WARNING + elif event.levelno == format.INFO: + log_information['level'] = LogMessage.INFO + else: + log_information['level'] = event.levelno + log_information['message'] = event.msg log_information['pathname'] = event.pathname log_information['lineno'] = event.lineno self.orm_wrapper.create_logmessage(log_information) + def close(self): + if self.brbe is not None: + buildinfohelper._store_build_done() + + if 'backlog' in self.internal_state: + for event in self.internal_state['backlog']: + print "NOTE: Unsaved log: ", event.msg
lib/bb/ui/toasterui.py +4 -6
@@ -94,7 +94,6 @@ def main(server, eventHandler, params ): first = True buildinfohelper = BuildInfoHelper(server, build_history_enabled) - brbe = None while True: try:
@@ -111,7 +110,7 @@ def main(server, eventHandler, params ): helper.eventHandler(event) if isinstance(event, bb.event.BuildStarted): - brbe = buildinfohelper.store_started_build(event) + buildinfohelper.store_started_build(event) if isinstance(event, (bb.build.TaskStarted, bb.build.TaskSucceeded, bb.build.TaskFailedSilent)): buildinfohelper.update_and_store_task(event)
@@ -222,19 +221,18 @@ def main(server, eventHandler, params ): bb.command.CommandExit)): if (isinstance(event, bb.command.CommandFailed)): event.levelno = format.ERROR - event.msg = event.error + event.msg = "Command Failed " + event.error event.pathname = "" event.lineno = 0 buildinfohelper.store_log_event(event) errors += 1 buildinfohelper.update_build_information(event, errors, warnings, taskfailures) + buildinfohelper.close() # we start a new build info - if brbe is not None: - br_id, be_id = brbe.split(":") - buildinfohelper.store_build_done(br_id, be_id) + if buildinfohelper.brbe is not None: print "we are under BuildEnvironment management - after the build, we exit" server.terminateServer()
Signature · 1 line
1.9.1
PATCH 2/11 toaster: fix application discovery in settings.py
From: Alexandru DAMIAN <[email protected]>
We fix application discovery, tuples don't have .append().
Other minor fixes.
--- lib/toaster/toastermain/settings.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
lib/toaster/toastermain/settings.py +1 -3
@@ -241,8 +241,6 @@ INSTALLED_APPS = ( 'django.contrib.humanize', 'orm', 'toastermain', - 'toastergui', - 'bldviewer', 'south', 'bldcontrol', )
@@ -261,7 +259,7 @@ currentdir = os.path.dirname(__file__) for t in os.walk(os.path.dirname(currentdir)): modulename = os.path.basename(t[0]) if ("views.py" in t[2] or "models.py" in t[2]) and not modulename in INSTALLED_APPS: - INSTALLED_APPS.append(modulename) + INSTALLED_APPS = INSTALLED_APPS + (modulename,) # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to
Signature · 1 line
1.9.1
PATCH 3/11 toaster: update orm models for layerindex compatibility
In reply to Alex DAMIANFrom: Alexandru DAMIAN <[email protected]>
We add a ToasterSettings table that will keep
installation-wide settings.
We update the models for the layer-related data storage to make them compatible with the layerindex application API.
We add a LayerSource class that can update local data from a LayerIndex-like compatible API.
Adding a command line option to perform information update from all upstream layer sources.
Fair warning - there is no backward migration from 0013.
--- lib/toaster/orm/management/__init__.py | 0 lib/toaster/orm/management/commands/__init__.py | 0 lib/toaster/orm/management/commands/lsupdates.py | 12 + ...erversiondependency__add_unique_layerversion.py | 710 +++++++++++++++++++++ lib/toaster/orm/models.py | 377 +++++++++-- lib/toaster/orm/tests.py | 33 + lib/toaster/toastermain/settings.py | 2 + 7 files changed, 1096 insertions(+), 38 deletions(-) create mode 100644 lib/toaster/orm/management/__init__.py create mode 100644 lib/toaster/orm/management/commands/__init__.py create mode 100644 lib/toaster/orm/management/commands/lsupdates.py create mode 100644 lib/toaster/orm/migrations/0013_auto__add_release__add_layerversiondependency__add_unique_layerversion.py create mode 100644 lib/toaster/orm/tests.py
lib/toaster/orm/management/__init__.py new file +0 -0
lib/toaster/orm/management/commands/__init__.py new file +0 -0
lib/toaster/orm/management/commands/lsupdates.py new file +12 -0
@@ -0,0 +1,12 @@ +from django.core.management.base import NoArgsCommand, CommandError +from orm.models import LayerSource +import os + +class Command(NoArgsCommand): + args = "" + help = "Updates locally cached information from all LayerSources" + + + def handle_noargs(self, **options): + for ls in LayerSource.objects.all(): + ls.update()
lib/toaster/orm/migrations/0013_auto__add_release__add_layerversiondependency__add_unique_layerversion.py new file +710 -0
711 lines not on this page · raw message
lib/toaster/orm/models.py +339 -38
435 lines not on this page · raw message
lib/toaster/orm/tests.py new file +33 -0
@@ -0,0 +1,33 @@ +from django.test import TestCase +from orm.models import LocalLayerSource, LayerIndexLayerSource, LayerSource +from orm.models import Branch + +class LayerSourceVerifyInheritanceSaveLoad(TestCase): + def test_object_creation(self): + lls = LayerSource.objects.create(name = "a1", sourcetype = LayerSource.TYPE_LOCAL, apiurl = "") + lils = LayerSource.objects.create(name = "a1", sourcetype = LayerSource.TYPE_LAYERINDEX, apiurl = "") + + print LayerSource.objects.all() + + self.assertTrue(True in map(lambda x: isinstance(x, LocalLayerSource), LayerSource.objects.all())) + self.assertTrue(True in map(lambda x: isinstance(x, LayerIndexLayerSource), LayerSource.objects.all())) + + def test_duplicate_error(self): + def duplicate(): + LayerSource.objects.create(name = "a1", sourcetype = LayerSource.TYPE_LOCAL, apiurl = "") + LayerSource.objects.create(name = "a1", sourcetype = LayerSource.TYPE_LOCAL, apiurl = "") + + self.assertRaises(Exception, duplicate) + + + +class LILSUpdateTestCase(TestCase): + def test_update(self): + lils = LayerSource.objects.create(name = "b1", sourcetype = LayerSource.TYPE_LAYERINDEX, apiurl = "http://adamian-desk.local:8080/layerindex/api/") + lils.update() + + # run second update + # lils.update() + + # print vars(lils) + #print map(lambda x: vars(x), Branch.objects.all())
lib/toaster/toastermain/settings.py +2 -0
@@ -245,6 +245,8 @@ INSTALLED_APPS = ( 'bldcontrol', ) +SOUTH_TESTS_MIGRATE = False + # if we run in managed mode, we need user support if MANAGED: INSTALLED_APPS = ('django.contrib.auth',
Signature · 1 line
1.9.1
PATCH 4/11 toaster: enable admin interface on select models
In reply to Alex DAMIANFrom: Alexandru DAMIAN <[email protected]>
We enable the admin interface in Toaster.
We add admin models for Build Environments (where the sysadmin can configure where the builds take place) and for Layer Sources (marking the upstream provider for layer information).
The admin interface and associated data are enabled only for the MANAGED version.
--- lib/toaster/bldcontrol/admin.py | 8 ++++++++ lib/toaster/orm/admin.py | 17 +++++++++++++++++ lib/toaster/toastermain/settings.py | 10 +++++----- lib/toaster/toastermain/urls.py | 18 +++++++++++++----- 4 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 lib/toaster/bldcontrol/admin.py create mode 100644 lib/toaster/orm/admin.py
lib/toaster/bldcontrol/admin.py new file +8 -0
@@ -0,0 +1,8 @@ +from django.contrib import admin +from django.contrib.admin.filters import RelatedFieldListFilter +from .models import BuildEnvironment + +class BuildEnvironmentAdmin(admin.ModelAdmin): + pass + +admin.site.register(BuildEnvironment, BuildEnvironmentAdmin)
lib/toaster/orm/admin.py new file +17 -0
@@ -0,0 +1,17 @@ +from django.contrib import admin +from django.contrib.admin.filters import RelatedFieldListFilter +from .models import Branch, LayerSource, ToasterSetting + +class LayerSourceAdmin(admin.ModelAdmin): + pass + +class BranchAdmin(admin.ModelAdmin): + pass + +class ToasterSettingAdmin(admin.ModelAdmin): + pass + +admin.site.register(LayerSource, LayerSourceAdmin) +admin.site.register(Branch, BranchAdmin) +admin.site.register(ToasterSetting, ToasterSettingAdmin) +
lib/toaster/toastermain/settings.py +5 -5
@@ -232,17 +232,13 @@ TEMPLATE_CONTEXT_PROCESSORS = ('django.contrib.auth.context_processors.auth', INSTALLED_APPS = ( #'django.contrib.sites', - #'django.contrib.messages', 'django.contrib.staticfiles', - # Uncomment the next line to enable the admin: - # 'django.contrib.admin', # Uncomment the next line to enable admin documentation: # 'django.contrib.admindocs', 'django.contrib.humanize', 'orm', 'toastermain', 'south', - 'bldcontrol', ) SOUTH_TESTS_MIGRATE = False
@@ -251,7 +247,11 @@ SOUTH_TESTS_MIGRATE = False if MANAGED: INSTALLED_APPS = ('django.contrib.auth', 'django.contrib.contenttypes', - 'django.contrib.sessions',) + INSTALLED_APPS + 'django.contrib.messages', + 'django.contrib.sessions', + # Uncomment the next line to enable the admin: + 'django.contrib.admin', + ) + INSTALLED_APPS # We automatically detect and install applications here if
lib/toaster/toastermain/urls.py +13 -5
@@ -25,11 +25,12 @@ from django.views.decorators.cache import never_cache # Uncomment the next two lines to enable the admin: -# from django.contrib import admin -# admin.autodiscover() +from django.contrib import admin +admin.autodiscover() + urlpatterns = patterns('', + # the api-s are not auto-discoverable url(r'^api/1.0/', include('bldviewer.api')), - url(r'^$', never_cache(RedirectView.as_view(url='/toastergui/'))), # Examples: # url(r'^toaster/', include('toaster.foo.urls')),
@@ -37,10 +38,17 @@ urlpatterns = patterns('', # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), - # Uncomment the next line to enable the admin: - # url(r'^admin/', include(admin.site.urls)), + + # if no application is selected, we have the magic toastergui app here + url(r'^$', never_cache(RedirectView.as_view(url='/toastergui/'))), ) +import toastermain.settings +if toastermain.settings.MANAGED: + urlpatterns = urlpatterns + [ + # Uncomment the next line to enable the admin: + url(r'^admin/', include(admin.site.urls)), + ] # Automatically discover urls.py in various apps, beside our own # and map module directories to the patterns
Signature · 1 line
1.9.1
PATCH 5/11 toaster: create project section navigation structure
In reply to Alex DAMIANFrom: Alexandru DAMIAN <[email protected]>
We create the navigation structure for the project section. This includes adding URLs for configuration, builds, all layers, layer details and all targets pages.
Changes to existing pages to exemplify navigation links.
--- lib/toaster/toastergui/templates/newproject.html | 5 ++- lib/toaster/toastergui/templates/project.html | 47 ++++++++++++----------- lib/toaster/toastergui/urls.py | 11 +++++- lib/toaster/toastergui/views.py | 48 +++++++++++++++++++++++- 4 files changed, 85 insertions(+), 26 deletions(-)
lib/toaster/toastergui/templates/newproject.html +3 -2
@@ -28,8 +28,9 @@ <i class="icon-question-sign get-help" title="This sets the branch for the Yocto Project core layers (meta, meta-yocto and meta-yocto-bsp), and for the layers you use from the OpenEmbedded Metadata Index"></i> </label> <select name="projectversion" id="projectversion"> - <!-- TODO: XHR data from http://layers.openembedded.org/layerindex/branch/master/layers/ --> - <option value="master" {%if projectversion == "master" %}selected{%endif%}>master</option> + {% for br in branches %} + <option value="{{br.id}}"{%if projectversion == br.id %} selected{%endif%}>{{br.name}} ({{br.short_description}})</option> + {% endfor %} </select> </fieldset>
lib/toaster/toastergui/templates/project.html +25 -22
82 lines not on this page · raw message
lib/toaster/toastergui/urls.py +10 -1
@@ -63,12 +63,21 @@ urlpatterns = patterns('toastergui.views', # urls not linked from the dashboard - url(r'^layers/$', 'layer', name='all-layers'), url(r'^layerversions/(?P<layerversion_id>\d+)/recipes/.*$', 'layer_versions_recipes', name='layer_versions_recipes'), # project URLs url(r'^newproject/$', 'newproject', name='newproject'), + url(r'^importlayer/$', 'importlayer', name='importlayer'), + + url(r'^layers/$', 'layers', name='layers'), + url(r'^layer/(?P<layerid>\d+)/$', 'layerdetails', name='layerdetails'), + url(r'^targets/$', 'targets', name='targets'), + url(r'^machines/$', 'machines', name='machines'), + url(r'^project/(?P<pid>\d+)/$', 'project', name='project'), + url(r'^project/(?P<pid>\d+)/configuration$', 'projectconf', name='projectconf'), + url(r'^project/(?P<pid>\d+)/builds$', 'projectbuilds', name='projectbuild'), + url(r'^xhr_projectbuild/(?P<pid>\d+)/$', 'xhr_projectbuild', name='xhr_projectbuild'), url(r'^xhr_projectedit/(?P<pid>\d+)/$', 'xhr_projectedit', name='xhr_projectedit'),
lib/toaster/toastergui/views.py +47 -1
75 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 6/11 toaster: add all layers page
In reply to Alex DAMIANFrom: Alexandru DAMIAN <[email protected]>
We add a page where the user can browse
and import layers from all the layers known
by Toaster.
[YOCTO #6590]
--- lib/toaster/toastergui/templates/layers.html | 173 +++++++++++++++++++++++++++ lib/toaster/toastergui/views.py | 74 +++++++++++- 2 files changed, 246 insertions(+), 1 deletion(-) create mode 100755 lib/toaster/toastergui/templates/layers.html
lib/toaster/toastergui/templates/layers.html new file +173 -0
@@ -0,0 +1,173 @@ +{% extends "base.html" %} +{% load projecttags %} +{% load humanize %} +{% block pagecontent %} + <div class="page-header"> + <h1> + All layers + <i class="icon-question-sign get-help heading-help" title="This page lists all the layers compatible with Yocto Project 1.7 'Dxxxx' that Toaster knows about. They include community-created layers suitable for use on top of OpenEmbedded Core and any layers you have imported"></i> + </h1> + </div> + <!--div class="alert"> + <div class="input-append" style="margin-bottom:0px;"> + <input class="input-xxlarge" type="text" placeholder="Search layers" value="browser" /> + <a class="add-on btn"> + <i class="icon-remove"></i> + </a> + <button class="btn" type="button">Search</button> + <a class="btn btn-link" href="#">Show all layers</a> + </div> + </div--> + <div id="layer-added" class="alert alert-info lead" style="display:none;"></div> + <div id="layer-removed" class="alert alert-info lead" style="display:none;"> + <button type="button" class="close" data-dismiss="alert">×</button> + <strong>1</strong> layer deleted from <a href="project-with-targets.html">your project</a>: <a href="#">meta-aarch64</a> + </div> + + +{% include "basetable_top.html" %} + {% for lv in objects %} + <tr class="data"> + <td class="layer">{{lv.layer.name}}</td> + <td class="description">{{lv.layer.summary}}</td> + <td class="source"><a href="{% url 'layerdetails' lv.pk %}">{{lv.layer_source.name}}</a></td> + <td class="git-repo"><a href="{% url 'layerdetails' lv.pk %}"><code>{{lv.layer.layer_index_url}}</code></a></td> + <td class="git-subdir" style="display: table-cell;"><a href="{% url 'layerdetails' lv.pk %}"><code>{{lv.dirpath}}</code></a></td> + <td class="branch">{% if lv.branch %}{{lv.branch}}{% else %}{{lv.up_branch.name}}{% endif %}</td> + <td class="dependencies">{% for lvs in lv.dependencies.all %}{{lvs.layer.name}}<br/>{%endfor%}</td> + <td class="add-layers"> + <button id="remove-layer-{{lv.pk}}" class="btn btn-danger btn-block remove-layer" title="1 layer deleted" style="display:none;"> + <i class="icon-trash"></i> + Delete layer + </button> + <button id="add-layer-{{lv.pk}}" class="btn btn-block add-layer" title="1 layer added"> + <i class="icon-plus"></i> + Add layer + </button> + </td> + </tr> + {% endfor %} +{% include "basetable_bottom.html" %} + + <!-- Modals --> + + <!-- 'Layer dependencies modal' --> + <div id="dependencies-message" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button> + <h3>meta-acer dependencies</h3> + </div> + <div class="modal-body"> + <p><strong>meta-acer</strong> depends on some layers that are not added to your project. Select the ones you want to add:</p> + <ul class="unstyled"> + <li> + <label class="checkbox"> + <input type="checkbox" checked="checked"> + meta-android + </label> + </li> + <li> + <label class="checkbox"> + <input type="checkbox" checked="checked"> + meta-oe + </label> + </li> + </ul> + </div> + <div class="modal-footer"> + <button id="add-layer-dependencies" type="submit" class="btn btn-primary" data-dismiss="modal" >Add layers</button> + <button class="btn" data-dismiss="modal">Cancel</button> + </div> + </div> + + <script src="assets/js/jquery-1.9.1.min.js" type='text/javascript'></script> + <script src="assets/js/jquery.tablesorter.min.js" type='text/javascript'></script> + <script src="assets/js/jquery-ui-1.10.3.custom.min.js"></script> + <script src="assets/js/bootstrap.min.js" type='text/javascript'></script> + <script src="assets/js/prettify.js" type='text/javascript'></script> + <script src="assets/js/jit.js" type='text/javascript'></script> + <script src="assets/js/main.js" type='text/javascript'></script> + + <script> + $(document).ready(function() { + + //show or hide selected columns on load + $("input:checkbox").each(function(){ + var selectedType = $(this).val(); + if($(this).is(":checked")){ + $("."+selectedType).show(); + } + else{ + $("."+selectedType).hide(); + } + }); + + // enable add layer button + $('#add-layer-with-deps').removeAttr('disabled'); + + //edit columns functionality (show / hide table columns) + $("input:checkbox").change(); + $("input:checkbox").change(function(){ + var selectedType = $(this).val(); + if($(this).is(":checked")){ + $("."+selectedType).show(); + } + else{ + $("."+selectedType).hide(); + } + }); + + //turn edit columns dropdown into a multi-select menu + $('.dropdown-menu input, .dropdown-menu label').click(function(e) { + e.stopPropagation(); + }); + + //show tooltip with applied filter + $('#filtered').tooltip({container:'table', placement:'bottom', delay:{hide:1500}, html:true}); + + $('#filtered').click(function() { + $(this).tooltip('hide'); + }); + + //show layer added tooltip + $("#remove-layer, #add-layer, #add-layer-with-deps2").tooltip({ trigger: 'manual' }); + + // add layer without dependencies + $("#add-layer").click(function(){ + $('#layer-removed').hide(); + $('#layer-added').html('<button type="button" class="close" data-dismiss="alert">×</button><strong>1</strong> layer added to <a href="project-with-targets.html">your project</a>: <a href="#">meta-aarch64</a>').fadeIn(); + $('#add-layer').tooltip('show'); + $("#add-layer").hide(); + $(".add-layers .tooltip").delay(2000).fadeOut(function(){ + $("#remove-layer").delay(300).fadeIn(); + }); + }); + + // add layer with dependencies + $(document).on("click", "#add-layer-dependencies", function() { + $('#layer-removed').hide(); + $('#layer-added').html('<button type="button" class="close" data-dismiss="alert">×</button><strong>3</strong> layers added to <a href="project-with-targets.html">your project</a>: <a href="#">meta-acer</a> and its dependencies <a href="#">meta-android</a> and <a href="#">meta-oe</a>').delay(400).fadeIn(function(){ + $('#add-layer-with-deps').tooltip('show'); + $("#add-layer-with-deps, #add-layer-with-deps").hide(); + $(".add-layers .tooltip").delay(2000).fadeOut(function(){ + $("#remove-layer-with-deps").delay(300).fadeIn(); + }); + }); + }); + + // delete layer + $("#remove-layer").click(function(){ + $('#layer-added').hide(); + $('#layer-removed').show(); + $('#remove-layer').tooltip('show'); + $("#remove-layer").hide(); + $(".add-layers .tooltip").delay(2000).fadeOut(function(){ + $("#add-layer").delay(300).fadeIn(); + }); + }); + + }); + +</script> + +{% endblock %}
lib/toaster/toastergui/views.py +73 -1
86 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 7/11 toaster: update checksettings command for auto-detection
In reply to Alex DAMIANFrom: Alexandru DAMIAN <[email protected]>
We enhance the checksettings command to try to automatically detect settings for running on localhost.
The checksettings will look for a nearby poky layer source, for a nearby build directory, and will try to import settings from "toasterconf.json" files found in the local layer.
On new configuration, it will also perform updates from the layer source.
--- bin/toaster | 9 +- .../management/commands/checksettings.py | 190 ++++++++++++++++++++- 2 files changed, 188 insertions(+), 11 deletions(-)
bin/toaster +6 -3
@@ -65,10 +65,10 @@ function webserverStartAll() fi if [ "x$TOASTER_MANAGED" == "x1" ]; then python $BBBASEDIR/lib/toaster/manage.py migrate bldcontrol || retval=1 - python $BBBASEDIR/lib/toaster/manage.py checksettings || retval=1 + python $BBBASEDIR/lib/toaster/manage.py checksettings --traceback || retval=1 fi - echo "Starting webserver" if [ $retval -eq 0 ]; then + echo "Starting webserver" python $BBBASEDIR/lib/toaster/manage.py runserver 0.0.0.0:8000 </dev/null >${BUILDDIR}/toaster_web.log 2>&1 & echo $! >${BUILDDIR}/.toastermain.pid sleep 1 if ! cat "${BUILDDIR}/.toastermain.pid" | xargs -I{} kill -0 {} ; then
@@ -144,7 +144,10 @@ if [ -z "$ZSH_NAME" ] && [ `basename \"$0\"` = `basename \"$BASH_SOURCE\"` ]; th } TOASTER_MANAGED=1 export TOASTER_MANAGED=1 - webserverStartAll || (echo "Fail to start the web server, stopping" 1>&2 && exit 1) + if ! webserverStartAll; then + echo "Failed to start the web server, stopping" 1>&2; + exit 1; + fi xdg-open http://0.0.0.0:8000/ >/dev/null 2>&1 & trap trap_ctrlc SIGINT echo "Running. Stop with Ctrl-C"
lib/toaster/bldcontrol/management/commands/checksettings.py +182 -8
220 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 8/11 toaster: update the bldcontrol to the new orm models
In reply to Alex DAMIANFrom: Alexandru DAMIAN <[email protected]>
We update the build controller application to make proper use of the bitbake specification in project settings.
Added heuristic to detect when the meta* layers and bitbake are checked out from Yocto Project poky, and use a single git checkout.
Building without a proper oe-init-build-env is not yet supported.
--- lib/toaster/bldcontrol/bbcontroller.py | 35 ++++-- .../bldcontrol/management/commands/runbuilds.py | 2 +- .../migrations/0006_auto__add_brbitbake.py | 128 +++++++++++++++++++++ lib/toaster/bldcontrol/models.py | 5 + 4 files changed, 158 insertions(+), 12 deletions(-) create mode 100644 lib/toaster/bldcontrol/migrations/0006_auto__add_brbitbake.py
lib/toaster/bldcontrol/bbcontroller.py +24 -11
@@ -25,7 +25,7 @@ import sys import re from django.db import transaction from django.db.models import Q -from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget +from bldcontrol.models import BuildEnvironment, BRLayer, BRVariable, BRTarget, BRBitbake import subprocess from toastermain import settings
@@ -123,8 +123,10 @@ class BuildEnvironmentController(object): self.connection must be none. """ - def setLayers(self,ls): - """ Sets the layer variables in the config file, after validating local layer paths. + def setLayers(self, bbs, ls): + """ Checks-out bitbake executor and layers from git repositories. + Sets the layer variables in the config file, after validating local layer paths. + The bitbakes must be a 1-length list of BRBitbake The layer paths must be in a list of BRLayer object a word of attention: by convention, the first layer for any build will be poky!
@@ -230,15 +232,22 @@ class LocalhostBEController(BuildEnvironmentController): self.be.save() print "Stopped server" - def setLayers(self, layers): + def setLayers(self, bitbakes, layers): """ a word of attention: by convention, the first layer for any build will be poky! """ assert self.be.sourcedir is not None + assert len(bitbakes) == 1 # set layers in the layersource # 1. get a list of repos, and map dirpaths for each layer gitrepos = {} + gitrepos[bitbakes[0].giturl] = [] + gitrepos[bitbakes[0].giturl].append( ("bitbake", bitbakes[0].dirpath, bitbakes[0].commit) ) + for layer in layers: + # we don't process local URLs + if layer.giturl.startswith("file://"): + continue if not layer.giturl in gitrepos: gitrepos[layer.giturl] = [] gitrepos[layer.giturl].append( (layer.name, layer.dirpath, layer.commit))
@@ -250,7 +259,7 @@ class LocalhostBEController(BuildEnvironmentController): def _getgitdirectoryname(url): import re - components = re.split(r'[\.\/]', url) + components = re.split(r'[:\.\/]', url) return components[-2] if components[-1] == "git" else components[-1] layerlist = []
@@ -258,7 +267,7 @@ class LocalhostBEController(BuildEnvironmentController): # 2. checkout the repositories for giturl in gitrepos.keys(): localdirname = os.path.join(self.be.sourcedir, _getgitdirectoryname(giturl)) - print "DEBUG: giturl checking out in current directory", localdirname + print "DEBUG: giturl ", giturl ,"checking out in current directory", localdirname # make sure our directory is a git repository if os.path.exists(localdirname):
@@ -268,11 +277,14 @@ class LocalhostBEController(BuildEnvironmentController): self._shellcmd("git clone \"%s\" \"%s\"" % (giturl, localdirname)) # checkout the needed commit commit = gitrepos[giturl][0][2] - self._shellcmd("git fetch --all && git checkout \"%s\"" % commit , localdirname) - print "DEBUG: checked out commit ", commit, "to", localdirname - # if this is the first checkout, take the localdirname as poky dir - if self.pokydirname is None: + # branch magic name "HEAD" will inhibit checkout + if commit != "HEAD": + print "DEBUG: checking out commit ", commit, "to", localdirname + self._shellcmd("git fetch --all && git checkout \"%s\"" % commit , localdirname) + + # take the localdirname as poky dir if we can find the oe-init-build-env + if self.pokydirname is None and os.path.exists(os.path.join(localdirname, "oe-init-build-env")): print "DEBUG: selected poky dir name", localdirname self.pokydirname = localdirname
@@ -282,7 +294,8 @@ class LocalhostBEController(BuildEnvironmentController): if not os.path.exists(localdirpath): raise BuildSetupException("Cannot find layer git path '%s' in checked out repository '%s:%s'. Aborting." % (localdirpath, giturl, commit)) - layerlist.append(localdirpath) + if name != "bitbake": + layerlist.append(localdirpath) print "DEBUG: current layer list ", layerlist
lib/toaster/bldcontrol/management/commands/runbuilds.py +1 -1
@@ -43,7 +43,7 @@ class Command(NoArgsCommand): # set up the buid environment with the needed layers print "Build %s, Environment %s" % (br, bec.be) - bec.setLayers(br.brlayer_set.all()) + bec.setLayers(br.brbitbake_set.all(), br.brlayer_set.all()) # get the bb server running bbctrl = bec.getBBController()
lib/toaster/bldcontrol/migrations/0006_auto__add_brbitbake.py new file +128 -0
129 lines not on this page · raw message
lib/toaster/bldcontrol/models.py +5 -0
@@ -75,6 +75,11 @@ class BRLayer(models.Model): commit = models.CharField(max_length = 254) dirpath = models.CharField(max_length = 254) +class BRBitbake(models.Model): + req = models.ForeignKey(BuildRequest, unique = True) # only one bitbake for a request + giturl = models.CharField(max_length =254) + commit = models.CharField(max_length = 254) + dirpath = models.CharField(max_length = 254) class BRVariable(models.Model): req = models.ForeignKey(BuildRequest)
Signature · 1 line
1.9.1
PATCH 9/11 toatergui: update pages to match project models
In reply to Alex DAMIANFrom: Alexandru DAMIAN <[email protected]>
We update pages and queries to match the new project models.
--- lib/toaster/toastergui/templates/newproject.html | 4 ++-- lib/toaster/toastergui/templates/project.html | 4 ++-- lib/toaster/toastergui/views.py | 13 ++++++------- 3 files changed, 10 insertions(+), 11 deletions(-)
lib/toaster/toastergui/templates/newproject.html +2 -2
@@ -28,8 +28,8 @@ <i class="icon-question-sign get-help" title="This sets the branch for the Yocto Project core layers (meta, meta-yocto and meta-yocto-bsp), and for the layers you use from the OpenEmbedded Metadata Index"></i> </label> <select name="projectversion" id="projectversion"> - {% for br in branches %} - <option value="{{br.id}}"{%if projectversion == br.id %} selected{%endif%}>{{br.name}} ({{br.short_description}})</option> + {% for release in releases %} + <option value="{{release.id}}"{%if projectversion == release.id %} selected{%endif%}>{{release.name}} ({{release.description}})</option> {% endfor %} </select> </fieldset>
lib/toaster/toastergui/templates/project.html +2 -2
@@ -269,7 +269,7 @@ $(document).ready(function () { <ul class="unstyled configuration-list"> {% for pl in project.projectlayer_set.all %} <li> - <a href="#">{{pl.name}} (<span class="layer-version">{{pl.giturl}}</span>)</a> + <a href="#">{{pl.layercommit.layer.name}} (<span class="layer-version">{{pl.layercommit.layer.layer_index_url}}</span>)</a> {% if pl.optional %} <i title="" data-original-title="" class="icon-trash" id="del-layer-icon" x-data="{{pl.pk}}"></i> {% endif %}
@@ -358,7 +358,7 @@ $(document).ready(function () { </p> <h3>Yocto Project version</h3> <p class="lead"> - {{project.branch}} - {{project.short_description}} + {{project.release}} - {{project.short_description}} <i title="" data-original-title="" class="icon-pencil"></i> </p> </div>
lib/toaster/toastergui/views.py +6 -7
@@ -1772,7 +1772,7 @@ if toastermain.settings.MANAGED: from django.contrib.auth.decorators import login_required from orm.models import Project, ProjectLayer, ProjectTarget, ProjectVariable - from orm.models import Branch, LayerSource, ToasterSetting + from orm.models import Branch, LayerSource, ToasterSetting, Release from bldcontrol.models import BuildRequest import traceback
@@ -1792,7 +1792,7 @@ if toastermain.settings.MANAGED: context = { 'email': request.user.email if request.user.is_authenticated() else '', 'username': request.user.username if request.user.is_authenticated() else '', - 'branches': Branch.objects.order_by("-up_id"), + 'releases': Release.objects.order_by("id"), 'defaultbranch': ToasterSetting.objects.get(name = "DEFAULT_RELEASE").value, }
@@ -1819,15 +1819,14 @@ if toastermain.settings.MANAGED: # save the project prj = Project.objects.create_project(name = request.POST['projectname'], - branch = Branch.objects.get(pk = request.POST['projectversion'].split(" ")[0]), - short_description=request.POST['projectversion'].split(" ")[1:]) + release = Release.objects.get(pk = request.POST['projectversion'])) prj.user_id = request.user.pk prj.save() return redirect(reverse(project, args = (prj.pk,))) except (IntegrityError, BadParameterException) as e: # fill in page with previously submitted values - map(lambda x: context.__setitem__(x, request.POST[x]), mandatory_fields) + map(lambda x: context.__setitem__(x, request.POST.get(x, "-- missing")), mandatory_fields) if isinstance(e, IntegrityError) and "username" in str(e): context['alert'] = "Your chosen username is already used" else:
@@ -1917,7 +1916,7 @@ if toastermain.settings.MANAGED: # return all project settings return HttpResponse(json.dumps( { "error": "ok", - "layers": map(lambda x: (x.name, x.giturl), prj.projectlayer_set.all()), + "layers": map(lambda x: (x.layercommit.layer.name, x.layercommit.layer.layer_index_url), prj.projectlayer_set.all()), "targets" : map(lambda x: {"target" : x.target, "task" : x.task, "pk": x.pk}, prj.projecttarget_set.all()), "variables": map(lambda x: (x.name, x.value), prj.projectvariable_set.all()), }), content_type = "application/json")
@@ -1945,7 +1944,7 @@ if toastermain.settings.MANAGED: queryset_all = Layer_Version.objects.all() if 'project' in request.session: - queryset_all = queryset_all.filter(up_branch = request.session['project'].branch) + queryset_all = queryset_all.filter(up_branch__in = Branch.objects.filter(name = request.session['project'].release.name)) queryset_with_search = _get_queryset(Layer_Version, queryset_all, None, search_term, ordering_string, '-layer__name') queryset = _get_queryset(Layer_Version, queryset_all, filter_string, search_term, ordering_string, '-layer__name')
Signature · 1 line
1.9.1
PATCH 10/11 buildinfohelper: BuildRequest project file update soft linked
In reply to Alex DAMIANFrom: Alexandru DAMIAN <[email protected]>
--- lib/bb/ui/buildinfohelper.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/ui/buildinfohelper.py +1 -1
@@ -69,7 +69,7 @@ class ORMWrapper(object): from bldcontrol.models import BuildEnvironment, BuildRequest br, be = brbe.split(":") buildrequest = BuildRequest.objects.get(pk = br) - build.project = buildrequest.project + build.project_id = buildrequest.project_id build.save() return build
Signature · 1 line
1.9.1
PATCH 11/11 toaster: create Build methods for calculating progress and ETA
In reply to Alex DAMIANFrom: Alexandru DAMIAN <[email protected]>
We move the code to calculate build progress as percent and the ETA of the build to the model, so that they can be reused across different pages.
--- lib/toaster/orm/models.py | 18 ++++++++++++++++++ lib/toaster/toastergui/views.py | 13 +------------ 2 files changed, 19 insertions(+), 12 deletions(-)
lib/toaster/orm/models.py +18 -0
@@ -120,6 +120,24 @@ class Build(models.Model): build_name = models.CharField(max_length=100) bitbake_version = models.CharField(max_length=50) + def completeper(self): + tf = Task.objects.filter(build = self) + tfc = tf.count() + if tfc > 0: + completeper = tf.exclude(order__isnull=True).count()*100/tf.count() + else: + completeper = 0 + return completeper + + def eta(self): + from django.utils import timezone + eta = 0 + completeper = self.completeper() + if self.completeper() > 0: + eta = timezone.now() + ((timezone.now() - self.started_on)*(100-completeper)/completeper) + return eta + + def get_sorted_target_list(self): tgts = Target.objects.filter(build_id = self.id).order_by( 'target' ); return( tgts );
lib/toaster/toastergui/views.py +1 -12
@@ -224,17 +224,6 @@ def builds(request): # build view-specific information; this is rendered specifically in the builds page, at the top of the page (i.e. Recent builds) build_mru = Build.objects.filter(completed_on__gte=(timezone.now()-timedelta(hours=24))).order_by("-started_on")[:3] - for b in [ x for x in build_mru if x.outcome == Build.IN_PROGRESS ]: - tf = Task.objects.filter(build = b) - tfc = tf.count() - if tfc > 0: - b.completeper = tf.exclude(order__isnull=True).count()*100/tf.count() - else: - b.completeper = 0 - - b.eta = 0 - if b.completeper > 0: - b.eta = timezone.now() + ((timezone.now() - b.started_on)*(100-b.completeper)/b.completeper) # set up list of fstypes for each build fstypes_map = {};
@@ -1854,7 +1843,7 @@ if toastermain.settings.MANAGED: context = { "project" : prj, #"buildrequests" : prj.buildrequest_set.filter(state=BuildRequest.REQ_QUEUED), - "buildrequests" : map(lambda x: (x, {"machine" : x.brvariable_set.filter(name="MACHINE")[0]}), prj.buildrequest_set.order_by("-pk")), + "buildrequests" : map(lambda x: (x, {"machine" : x.brvariable_set.filter(name="MACHINE")[0]}), prj.buildrequest_set.filter(state__lt = BuildRequest.REQ_INPROGRESS).order_by("-pk")), "builds" : prj.build_set.all(), "puser": puser, }
Signature · 1 line
1.9.1