Bug 8049 - Make changes to orm to enable image customisation
Summary: Make changes to orm to enable image customisation
Status: VERIFIED FIXED
Alias: None
Product: Toaster
Classification: Build System, Metadata & Runtime
Component: toaster (show other bugs)
Version: 2.0
Hardware: x86 Multiple
: Medium+ enhancement
Target Milestone: 2.0
Assignee: Michael Wood
QA Contact: Mihail Stanciu
URL:
Whiteboard:
Depends on:
Blocks: 7681 8056 8077
  Show dependency tree
 
Reported: 2015-07-24 16:09 UTC by Belen Barros Pena
Modified: 2016-04-13 13:07 UTC (History)
8 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments
All Toaster tables (215.13 KB, application/pdf)
2015-07-24 16:51 UTC, Belen Barros Pena
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Belen Barros Pena 2015-07-24 16:09:53 UTC
Some new tables are needed in the Toaster database to enable the image customisation feature.
Comment 1 Alexandru Damian 2015-07-24 16:46:53 UTC
During discussions with the team, Brian made the call to use the "intermediate" table pattern for storing data for display. As such, we need to create tables that correspond to the objects that appear in the frontend design.

* ProjectAvailableLayer - this lists the layers that are available for adding in the current project; it's a cache of the Layer_Versions table, filtered for the project; it has unique layer names; it points back to the layer which would have to be checked out on the build command.

* the ProjectLayer table (containing the layers currently added in the project) need to reference the ProjectAvailableLayer table instead of the Layer_Version table;

* ProjectAvailableRecipe - this lists the recipes that are available for adding in the current project; it is generated by selecting the Recipe objects available for the current project; it hold entries to the ProjectAvailableLayer that is providing the recipes - as such, the computation of which Recipes are actually build-able is done by selecting the objects linked to ProjectAvailableLayer which are listed in ProjectLayer

* the ProjectAvailableRecipe also holds definitions of custom recipes for this object; the definition names are entries in this table, with the content stored in the ProjectCustomRecipeContent table; at the current moment, the content is thought of package lists, so each entry in the ProjectCustomRecipeContent is a package name, for example

* the list of packages that is available to the Project is another table - ProjectAvailablePackage; which is populated from the Package table, once a build is done; The ProjectAvailablePackage needs to hold a link to ProjectAvailableRecipe (analogous to the Package table containing a link to the  Recipe table) so we can now which package is provided by which Recipe and which Layer.


The particulars of the data fields on the ProjectAvailable* objects are driven by the interface needs. In any case, the *created* and *updated* fields can be automatically populated by Django (see bldcontrol.models)


I think that the most efficient method of keeping these tables in sync with data coming in from the different sources (LayerIndex, Builds, Imported Layers, etc) is to use django.db.models.signals to get hooks on when Layer_Version, Recipe and Package data get created/updated/deleted and perform corresponding actions on the ProjectAvailable* objects.
Comment 2 Ed Bartosh 2015-07-24 16:49:17 UTC
Alex, thank you for detailed info!
Comment 3 Belen Barros Pena 2015-07-24 16:51:46 UTC
Created attachment 2601 [details]
All Toaster tables

I am not sure this helps at all, but attached is a description of the contents of all Toaster tables.
Comment 4 Ed Bartosh 2015-07-28 16:14:21 UTC
After looking at the code working with ProjectLayer table I think it's quite dangerous to change it to work with ProjectAvailableLayer instead of Layer_Versions. It looks like a refactoring work, which I'd not recommend to do now considering 1.9 schedule and the current project status.

I'm going to keep all new models as independent from the current functionality as possible. This should allow us to implement image customization without breaking existing functionality.

Opinions?
Comment 5 Alexandru Damian 2015-07-29 10:46:08 UTC
Just for FYI, I have a patch that generates the correct layer_version entries for the project layers list:

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/commit/?h=adamian/20150727_tables&id=4cd4aedf99c942a1cfad4bcad59b6bcf02fd9e98

This enables the correct displaying of the "available layers for project" table information, and it generates what the "ProjectAvailableLayer" table should contain for a specific project.

The performance is not too bad, and if it easier to create Project methods that return querysets for the project available layers, recipes and packages, as an intermediate step to create the caching tables.
Comment 6 Ed Bartosh 2015-07-30 17:05:06 UTC
Created first 3 models: https://lists.yoctoproject.org/pipermail/toaster/2015-July/002435.html

Please, suggest what to do next. Thank you.
Comment 7 Ed Bartosh 2015-07-30 17:09:03 UTC
It would be also good to know about possible set of REST APIs required by frontend.
Comment 8 Ed Bartosh 2015-07-31 07:51:44 UTC
Added CustomImageRecipe model to the poky-contrib:ed/toaster/ic-models. Please review.
Comment 9 Ed Bartosh 2015-08-01 08:24:16 UTC
Added draft of the ProjectAvailableRecipesTable to the same branch. It requires more work on 'Customise' column. The rest of content is more or less ok.
Comment 10 Ed Bartosh 2015-08-03 08:52:18 UTC
Added draft code to populate ProjectAvailableLayer and ProjectAvailableRecipe with the data from layer index and builds. This should be enough to start working on frontent of this view: https://www.yoctoproject.org/toaster/all-image-recipes.html
Comment 11 Ed Bartosh 2015-08-09 12:13:44 UTC
Implemented set of ReST API calls and covered their code with tests: https://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=ed/toaster/ic-models
Comment 12 Mihail Stanciu 2016-04-13 13:07:26 UTC
Verified as part of 2.1.rc1: 296dfbc9b3a3c0ed64b8e748c2868928b9c2aa8b