xref: /OK3568_Linux_fs/yocto/poky/documentation/toaster-manual/reference.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun**********************
4*4882a593SmuzhiyunConcepts and Reference
5*4882a593Smuzhiyun**********************
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunIn order to configure and use Toaster, you should understand some
8*4882a593Smuzhiyunconcepts and have some basic command reference material available. This
9*4882a593Smuzhiyunfinal chapter provides conceptual information on layer sources,
10*4882a593Smuzhiyunreleases, and JSON configuration files. Also provided is a quick look at
11*4882a593Smuzhiyunsome useful ``manage.py`` commands that are Toaster-specific.
12*4882a593SmuzhiyunInformation on ``manage.py`` commands is available across the Web and
13*4882a593Smuzhiyunthis manual by no means attempts to provide a command
14*4882a593Smuzhiyuncomprehensive reference.
15*4882a593Smuzhiyun
16*4882a593SmuzhiyunLayer Source
17*4882a593Smuzhiyun============
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunIn general, a "layer source" is a source of information about existing
20*4882a593Smuzhiyunlayers. In particular, we are concerned with layers that you can use
21*4882a593Smuzhiyunwith the Yocto Project and Toaster. This chapter describes a particular
22*4882a593Smuzhiyuntype of layer source called a "layer index."
23*4882a593Smuzhiyun
24*4882a593SmuzhiyunA layer index is a web application that contains information about a set
25*4882a593Smuzhiyunof custom layers. A good example of an existing layer index is the
26*4882a593SmuzhiyunOpenEmbedded Layer Index. A public instance of this layer index exists
27*4882a593Smuzhiyunat :oe_layerindex:`/`. You can find the code for this
28*4882a593Smuzhiyunlayer index's web application at :yocto_git:`/layerindex-web/`.
29*4882a593Smuzhiyun
30*4882a593SmuzhiyunWhen you tie a layer source into Toaster, it can query the layer source
31*4882a593Smuzhiyunthrough a
32*4882a593Smuzhiyun`REST <https://en.wikipedia.org/wiki/Representational_state_transfer>`__
33*4882a593SmuzhiyunAPI, store the information about the layers in the Toaster database, and
34*4882a593Smuzhiyunthen show the information to users. Users are then able to view that
35*4882a593Smuzhiyuninformation and build layers from Toaster itself without having to
36*4882a593Smuzhiyunclone or edit the BitBake layers configuration file ``bblayers.conf``.
37*4882a593Smuzhiyun
38*4882a593SmuzhiyunTying a layer source into Toaster is convenient when you have many
39*4882a593Smuzhiyuncustom layers that need to be built on a regular basis by a community of
40*4882a593Smuzhiyundevelopers. In fact, Toaster comes pre-configured with the OpenEmbedded
41*4882a593SmuzhiyunMetadata Index.
42*4882a593Smuzhiyun
43*4882a593Smuzhiyun.. note::
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun   You do not have to use a layer source to use Toaster. Tying into a
46*4882a593Smuzhiyun   layer source is optional.
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunSetting Up and Using a Layer Source
49*4882a593Smuzhiyun-----------------------------------
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunTo use your own layer source, you need to set up the layer source and
52*4882a593Smuzhiyunthen tie it into Toaster. This section describes how to tie into a layer
53*4882a593Smuzhiyunindex in a manner similar to the way Toaster ties into the OpenEmbedded
54*4882a593SmuzhiyunMetadata Index.
55*4882a593Smuzhiyun
56*4882a593SmuzhiyunUnderstanding Your Layers
57*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~
58*4882a593Smuzhiyun
59*4882a593SmuzhiyunThe obvious first step for using a layer index is to have several custom
60*4882a593Smuzhiyunlayers that developers build and access using the Yocto Project on a
61*4882a593Smuzhiyunregular basis. This set of layers needs to exist and you need to be
62*4882a593Smuzhiyunfamiliar with where they reside. You will need that information when you
63*4882a593Smuzhiyunset up the code for the web application that "hooks" into your set of
64*4882a593Smuzhiyunlayers.
65*4882a593Smuzhiyun
66*4882a593SmuzhiyunFor general information on layers, see the
67*4882a593Smuzhiyun":ref:`overview-manual/yp-intro:the yocto project layer model`"
68*4882a593Smuzhiyunsection in the Yocto Project Overview and Concepts Manual. For information on how
69*4882a593Smuzhiyunto create layers, see the ":ref:`dev-manual/common-tasks:understanding and creating layers`"
70*4882a593Smuzhiyunsection in the Yocto Project Development Tasks Manual.
71*4882a593Smuzhiyun
72*4882a593SmuzhiyunConfiguring Toaster to Hook Into Your Layer Index
73*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
74*4882a593Smuzhiyun
75*4882a593SmuzhiyunIf you want Toaster to use your layer index, you must host the web
76*4882a593Smuzhiyunapplication in a server to which Toaster can connect. You also need to
77*4882a593Smuzhiyungive Toaster the information about your layer index. In other words, you
78*4882a593Smuzhiyunhave to configure Toaster to use your layer index. This section
79*4882a593Smuzhiyundescribes two methods by which you can configure and use your layer
80*4882a593Smuzhiyunindex.
81*4882a593Smuzhiyun
82*4882a593SmuzhiyunIn the previous section, the code for the OpenEmbedded Metadata Index
83*4882a593Smuzhiyun(i.e. :oe_layerindex:`/`) was referenced. You can use
84*4882a593Smuzhiyunthis code, which is at :yocto_git:`/layerindex-web/`, as a base to create
85*4882a593Smuzhiyunyour own layer index.
86*4882a593Smuzhiyun
87*4882a593SmuzhiyunUse the Administration Interface
88*4882a593Smuzhiyun^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
89*4882a593Smuzhiyun
90*4882a593SmuzhiyunAccess the administration interface through a browser by entering the
91*4882a593SmuzhiyunURL of your Toaster instance and adding "``/admin``" to the end of the
92*4882a593SmuzhiyunURL. As an example, if you are running Toaster locally, use the
93*4882a593Smuzhiyunfollowing URL::
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun   http://127.0.0.1:8000/admin
96*4882a593Smuzhiyun
97*4882a593SmuzhiyunThe administration interface has a "Layer sources" section that includes
98*4882a593Smuzhiyunan "Add layer source" button. Click that button and provide the required
99*4882a593Smuzhiyuninformation. Make sure you select "layerindex" as the layer source type.
100*4882a593Smuzhiyun
101*4882a593SmuzhiyunUse the Fixture Feature
102*4882a593Smuzhiyun^^^^^^^^^^^^^^^^^^^^^^^
103*4882a593Smuzhiyun
104*4882a593SmuzhiyunThe Django fixture feature overrides the default layer server when you
105*4882a593Smuzhiyunuse it to specify a custom URL. To use the fixture feature, create (or
106*4882a593Smuzhiyunedit) the file ``bitbake/lib/toaster.orm/fixtures/custom.xml``, and then
107*4882a593Smuzhiyunset the following Toaster setting to your custom URL:
108*4882a593Smuzhiyun
109*4882a593Smuzhiyun.. code-block:: xml
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun   <?xml version="1.0" ?>
112*4882a593Smuzhiyun   <django-objects version="1.0">
113*4882a593Smuzhiyun      <object model="orm.toastersetting" pk="100">
114*4882a593Smuzhiyun         <field name="name" type="CharField">CUSTOM_LAYERINDEX_SERVER</field>
115*4882a593Smuzhiyun         <field name="value" type="CharField">https://layers.my_organization.org/layerindex/branch/master/layers/</field>
116*4882a593Smuzhiyun      </object>
117*4882a593Smuzhiyun   <django-objects>
118*4882a593Smuzhiyun
119*4882a593SmuzhiyunWhen you start Toaster for the first time, or
120*4882a593Smuzhiyunif you delete the file ``toaster.sqlite`` and restart, the database will
121*4882a593Smuzhiyunpopulate cleanly from this layer index server.
122*4882a593Smuzhiyun
123*4882a593SmuzhiyunOnce the information has been updated, verify the new layer information
124*4882a593Smuzhiyunis available by using the Toaster web interface. To do that, visit the
125*4882a593Smuzhiyun"All compatible layers" page inside a Toaster project. The layers from
126*4882a593Smuzhiyunyour layer source should be listed there.
127*4882a593Smuzhiyun
128*4882a593SmuzhiyunIf you change the information in your layer index server, refresh the
129*4882a593SmuzhiyunToaster database by running the following command:
130*4882a593Smuzhiyun
131*4882a593Smuzhiyun.. code-block:: shell
132*4882a593Smuzhiyun
133*4882a593Smuzhiyun   $ bitbake/lib/toaster/manage.py lsupdates
134*4882a593Smuzhiyun
135*4882a593Smuzhiyun
136*4882a593SmuzhiyunIf Toaster can reach the API URL, you should see a message telling you that
137*4882a593SmuzhiyunToaster is updating the layer source information.
138*4882a593Smuzhiyun
139*4882a593SmuzhiyunReleases
140*4882a593Smuzhiyun========
141*4882a593Smuzhiyun
142*4882a593SmuzhiyunWhen you create a Toaster project using the web interface, you are asked
143*4882a593Smuzhiyunto choose a "Release." In the context of Toaster, the term "Release"
144*4882a593Smuzhiyunrefers to a set of layers and a BitBake version the OpenEmbedded build
145*4882a593Smuzhiyunsystem uses to build something. As shipped, Toaster is pre-configured
146*4882a593Smuzhiyunwith releases that correspond to Yocto Project release branches.
147*4882a593SmuzhiyunHowever, you can modify, delete, and create new releases according to
148*4882a593Smuzhiyunyour needs. This section provides some background information on
149*4882a593Smuzhiyunreleases.
150*4882a593Smuzhiyun
151*4882a593SmuzhiyunPre-Configured Releases
152*4882a593Smuzhiyun-----------------------
153*4882a593Smuzhiyun
154*4882a593SmuzhiyunAs shipped, Toaster is configured to use a specific set of releases. Of
155*4882a593Smuzhiyuncourse, you can always configure Toaster to use any release. For
156*4882a593Smuzhiyunexample, you might want your project to build against a specific commit
157*4882a593Smuzhiyunof any of the "out-of-the-box" releases. Or, you might want your project
158*4882a593Smuzhiyunto build against different revisions of OpenEmbedded and BitBake.
159*4882a593Smuzhiyun
160*4882a593SmuzhiyunAs shipped, Toaster is configured to work with the following releases:
161*4882a593Smuzhiyun
162*4882a593Smuzhiyun-  *Yocto Project &DISTRO; "&DISTRO_NAME;" or OpenEmbedded "&DISTRO_NAME;":*
163*4882a593Smuzhiyun   This release causes your Toaster projects to build against the head
164*4882a593Smuzhiyun   of the &DISTRO_NAME_NO_CAP; branch at
165*4882a593Smuzhiyun   :yocto_git:`/poky/log/?h=&DISTRO_NAME_NO_CAP;` or
166*4882a593Smuzhiyun   :oe_git:`/openembedded-core/commit/?h=&DISTRO_NAME_NO_CAP;`.
167*4882a593Smuzhiyun
168*4882a593Smuzhiyun-  *Yocto Project "Master" or OpenEmbedded "Master":* This release
169*4882a593Smuzhiyun   causes your Toaster Projects to build against the head of the master
170*4882a593Smuzhiyun   branch, which is where active development takes place, at
171*4882a593Smuzhiyun   :yocto_git:`/poky/log/` or :oe_git:`/openembedded-core/log/`.
172*4882a593Smuzhiyun
173*4882a593Smuzhiyun-  *Local Yocto Project or Local OpenEmbedded:* This release causes your
174*4882a593Smuzhiyun   Toaster Projects to build against the head of the ``poky`` or
175*4882a593Smuzhiyun   ``openembedded-core`` clone you have local to the machine running
176*4882a593Smuzhiyun   Toaster.
177*4882a593Smuzhiyun
178*4882a593SmuzhiyunConfiguring Toaster
179*4882a593Smuzhiyun===================
180*4882a593Smuzhiyun
181*4882a593SmuzhiyunIn order to use Toaster, you must configure the database with the
182*4882a593Smuzhiyundefault content. The following subsections describe various aspects of
183*4882a593SmuzhiyunToaster configuration.
184*4882a593Smuzhiyun
185*4882a593SmuzhiyunConfiguring the Workflow
186*4882a593Smuzhiyun------------------------
187*4882a593Smuzhiyun
188*4882a593SmuzhiyunThe ``bldcontrol/management/commands/checksettings.py`` file controls
189*4882a593Smuzhiyunworkflow configuration. Here is the process to
190*4882a593Smuzhiyuninitially populate this database.
191*4882a593Smuzhiyun
192*4882a593Smuzhiyun1. The default project settings are set from
193*4882a593Smuzhiyun   ``orm/fixtures/settings.xml``.
194*4882a593Smuzhiyun
195*4882a593Smuzhiyun2. The default project distro and layers are added from
196*4882a593Smuzhiyun   ``orm/fixtures/poky.xml`` if poky is installed. If poky is not
197*4882a593Smuzhiyun   installed, they are added from ``orm/fixtures/oe-core.xml``.
198*4882a593Smuzhiyun
199*4882a593Smuzhiyun3. If the ``orm/fixtures/custom.xml`` file exists, then its values are
200*4882a593Smuzhiyun   added.
201*4882a593Smuzhiyun
202*4882a593Smuzhiyun4. The layer index is then scanned and added to the database.
203*4882a593Smuzhiyun
204*4882a593SmuzhiyunOnce these steps complete, Toaster is set up and ready to use.
205*4882a593Smuzhiyun
206*4882a593SmuzhiyunCustomizing Pre-Set Data
207*4882a593Smuzhiyun------------------------
208*4882a593Smuzhiyun
209*4882a593SmuzhiyunThe pre-set data for Toaster is easily customizable. You can create the
210*4882a593Smuzhiyun``orm/fixtures/custom.xml`` file to customize the values that go into
211*4882a593Smuzhiyunthe database. Customization is additive, and can either extend or
212*4882a593Smuzhiyuncompletely replace the existing values.
213*4882a593Smuzhiyun
214*4882a593SmuzhiyunYou use the ``orm/fixtures/custom.xml`` file to change the default
215*4882a593Smuzhiyunproject settings for the machine, distro, file images, and layers. When
216*4882a593Smuzhiyuncreating a new project, you can use the file to define the offered
217*4882a593Smuzhiyunalternate project release selections. For example, you can add one or
218*4882a593Smuzhiyunmore additional selections that present custom layer sets or distros,
219*4882a593Smuzhiyunand any other local or proprietary content.
220*4882a593Smuzhiyun
221*4882a593SmuzhiyunAdditionally, you can completely disable the content from the
222*4882a593Smuzhiyun``oe-core.xml`` and ``poky.xml`` files by defining the section shown
223*4882a593Smuzhiyunbelow in the ``settings.xml`` file. For example, this option is
224*4882a593Smuzhiyunparticularly useful if your custom configuration defines fewer releases
225*4882a593Smuzhiyunor layers than the default fixture files.
226*4882a593Smuzhiyun
227*4882a593SmuzhiyunThe following example sets "name" to "CUSTOM_XML_ONLY" and its value to
228*4882a593Smuzhiyun"True".
229*4882a593Smuzhiyun
230*4882a593Smuzhiyun.. code-block:: xml
231*4882a593Smuzhiyun
232*4882a593Smuzhiyun   <object model="orm.toastersetting" pk="99">
233*4882a593Smuzhiyun      <field type="CharField" name="name">CUSTOM_XML_ONLY</field>
234*4882a593Smuzhiyun      <field type="CharField" name="value">True</field>
235*4882a593Smuzhiyun   </object>
236*4882a593Smuzhiyun
237*4882a593SmuzhiyunUnderstanding Fixture File Format
238*4882a593Smuzhiyun---------------------------------
239*4882a593Smuzhiyun
240*4882a593SmuzhiyunHere is an overview of the file format used by the
241*4882a593Smuzhiyun``oe-core.xml``, ``poky.xml``, and ``custom.xml`` files.
242*4882a593Smuzhiyun
243*4882a593SmuzhiyunThe following subsections describe each of the sections in the fixture
244*4882a593Smuzhiyunfiles, and outline an example section of the XML code. you can use to
245*4882a593Smuzhiyunhelp understand this information and create a local ``custom.xml`` file.
246*4882a593Smuzhiyun
247*4882a593SmuzhiyunDefining the Default Distro and Other Values
248*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
249*4882a593Smuzhiyun
250*4882a593SmuzhiyunThis section defines the default distro value for new projects. By
251*4882a593Smuzhiyundefault, it reserves the first Toaster Setting record "1". The following
252*4882a593Smuzhiyundemonstrates how to set the project default value for
253*4882a593Smuzhiyun:term:`DISTRO`:
254*4882a593Smuzhiyun
255*4882a593Smuzhiyun.. code-block:: xml
256*4882a593Smuzhiyun
257*4882a593Smuzhiyun   <!-- Set the project default value for DISTRO -->
258*4882a593Smuzhiyun   <object model="orm.toastersetting" pk="1">
259*4882a593Smuzhiyun      <field type="CharField" name="name">DEFCONF_DISTRO</field>
260*4882a593Smuzhiyun      <field type="CharField" name="value">poky</field>
261*4882a593Smuzhiyun   </object>
262*4882a593Smuzhiyun
263*4882a593SmuzhiyunYou can override
264*4882a593Smuzhiyunother default project values by adding additional Toaster Setting
265*4882a593Smuzhiyunsections such as any of the settings coming from the ``settings.xml``
266*4882a593Smuzhiyunfile. Also, you can add custom values that are included in the BitBake
267*4882a593Smuzhiyunenvironment. The "pk" values must be unique. By convention, values that
268*4882a593Smuzhiyunset default project values have a "DEFCONF" prefix.
269*4882a593Smuzhiyun
270*4882a593SmuzhiyunDefining BitBake Version
271*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~
272*4882a593Smuzhiyun
273*4882a593SmuzhiyunThe following defines which version of BitBake is used for the following
274*4882a593Smuzhiyunrelease selection:
275*4882a593Smuzhiyun
276*4882a593Smuzhiyun.. code-block:: xml
277*4882a593Smuzhiyun
278*4882a593Smuzhiyun   <!-- Bitbake versions which correspond to the metadata release -->
279*4882a593Smuzhiyun   <object model="orm.bitbakeversion" pk="1">
280*4882a593Smuzhiyun      <field type="CharField" name="name">&DISTRO_NAME_NO_CAP;</field>
281*4882a593Smuzhiyun      <field type="CharField" name="giturl">git://git.yoctoproject.org/poky</field>
282*4882a593Smuzhiyun      <field type="CharField" name="branch">&DISTRO_NAME_NO_CAP;</field>
283*4882a593Smuzhiyun      <field type="CharField" name="dirpath">bitbake</field>
284*4882a593Smuzhiyun   </object>
285*4882a593Smuzhiyun
286*4882a593SmuzhiyunDefining Release
287*4882a593Smuzhiyun~~~~~~~~~~~~~~~~
288*4882a593Smuzhiyun
289*4882a593SmuzhiyunThe following defines the releases when you create a new project:
290*4882a593Smuzhiyun
291*4882a593Smuzhiyun.. code-block:: xml
292*4882a593Smuzhiyun
293*4882a593Smuzhiyun   <!-- Releases available -->
294*4882a593Smuzhiyun   <object model="orm.release" pk="1">
295*4882a593Smuzhiyun      <field type="CharField" name="name">&DISTRO_NAME_NO_CAP;</field>
296*4882a593Smuzhiyun      <field type="CharField" name="description">Yocto Project &DISTRO; "&DISTRO_NAME;"</field>
297*4882a593Smuzhiyun      <field rel="ManyToOneRel" to="orm.bitbakeversion" name="bitbake_version">1</field>
298*4882a593Smuzhiyun      <field type="CharField" name="branch_name">&DISTRO_NAME_NO_CAP;</field>
299*4882a593Smuzhiyun      <field type="TextField" name="helptext">Toaster will run your builds using the tip of the <a href="https://git.yoctoproject.org/cgit/cgit.cgi/poky/log/?h=&DISTRO_NAME_NO_CAP;">Yocto Project &DISTRO_NAME; branch</a>.</field>
300*4882a593Smuzhiyun   </object>
301*4882a593Smuzhiyun
302*4882a593SmuzhiyunThe "pk" value must match the above respective BitBake version record.
303*4882a593Smuzhiyun
304*4882a593SmuzhiyunDefining the Release Default Layer Names
305*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
306*4882a593Smuzhiyun
307*4882a593SmuzhiyunThe following defines the default layers for each release:
308*4882a593Smuzhiyun
309*4882a593Smuzhiyun.. code-block:: xml
310*4882a593Smuzhiyun
311*4882a593Smuzhiyun   <!-- Default project layers for each release -->
312*4882a593Smuzhiyun   <object model="orm.releasedefaultlayer" pk="1">
313*4882a593Smuzhiyun      <field rel="ManyToOneRel" to="orm.release" name="release">1</field>
314*4882a593Smuzhiyun      <field type="CharField" name="layer_name">openembedded-core</field>
315*4882a593Smuzhiyun   </object>
316*4882a593Smuzhiyun
317*4882a593SmuzhiyunThe 'pk' values in the example above should start at "1" and increment
318*4882a593Smuzhiyununiquely. You can use the same layer name in multiple releases.
319*4882a593Smuzhiyun
320*4882a593SmuzhiyunDefining Layer Definitions
321*4882a593Smuzhiyun~~~~~~~~~~~~~~~~~~~~~~~~~~
322*4882a593Smuzhiyun
323*4882a593SmuzhiyunLayer definitions are the most complex. The following defines each of
324*4882a593Smuzhiyunthe layers, and then defines the exact layer version of the layer used
325*4882a593Smuzhiyunfor each respective release. You must have one ``orm.layer`` entry for
326*4882a593Smuzhiyuneach layer. Then, with each entry you need a set of
327*4882a593Smuzhiyun``orm.layer_version`` entries that connects the layer with each release
328*4882a593Smuzhiyunthat includes the layer. In general all releases include the layer.
329*4882a593Smuzhiyun
330*4882a593Smuzhiyun.. code-block:: xml
331*4882a593Smuzhiyun
332*4882a593Smuzhiyun   <object model="orm.layer" pk="1">
333*4882a593Smuzhiyun      <field type="CharField" name="name">openembedded-core</field>
334*4882a593Smuzhiyun      <field type="CharField" name="layer_index_url"></field>
335*4882a593Smuzhiyun      <field type="CharField" name="vcs_url">git://git.yoctoproject.org/poky</field>
336*4882a593Smuzhiyun      <field type="CharField" name="vcs_web_url">https://git.yoctoproject.org/cgit/cgit.cgi/poky</field>
337*4882a593Smuzhiyun      <field type="CharField" name="vcs_web_tree_base_url">https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/%path%?h=%branch%</field>
338*4882a593Smuzhiyun      <field type="CharField" name="vcs_web_file_base_url">https://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/%path%?h=%branch%</field>
339*4882a593Smuzhiyun   </object>
340*4882a593Smuzhiyun   <object model="orm.layer_version" pk="1">
341*4882a593Smuzhiyun      <field rel="ManyToOneRel" to="orm.layer" name="layer">1</field>
342*4882a593Smuzhiyun      <field type="IntegerField" name="layer_source">0</field>
343*4882a593Smuzhiyun      <field rel="ManyToOneRel" to="orm.release" name="release">1</field>
344*4882a593Smuzhiyun      <field type="CharField" name="branch">&DISTRO_NAME_NO_CAP;</field>
345*4882a593Smuzhiyun      <field type="CharField" name="dirpath">meta</field>
346*4882a593Smuzhiyun   </object> <object model="orm.layer_version" pk="2">
347*4882a593Smuzhiyun      <field rel="ManyToOneRel" to="orm.layer" name="layer">1</field>
348*4882a593Smuzhiyun      <field type="IntegerField" name="layer_source">0</field>
349*4882a593Smuzhiyun      <field rel="ManyToOneRel" to="orm.release" name="release">2</field>
350*4882a593Smuzhiyun      <field type="CharField" name="branch">HEAD</field>
351*4882a593Smuzhiyun      <field type="CharField" name="commit">HEAD</field>
352*4882a593Smuzhiyun      <field type="CharField" name="dirpath">meta</field>
353*4882a593Smuzhiyun   </object>
354*4882a593Smuzhiyun   <object model="orm.layer_version" pk="3">
355*4882a593Smuzhiyun      <field rel="ManyToOneRel" to="orm.layer" name="layer">1</field>
356*4882a593Smuzhiyun      <field type="IntegerField" name="layer_source">0</field>
357*4882a593Smuzhiyun      <field rel="ManyToOneRel" to="orm.release" name="release">3</field>
358*4882a593Smuzhiyun      <field type="CharField" name="branch">master</field>
359*4882a593Smuzhiyun      <field type="CharField" name="dirpath">meta</field>
360*4882a593Smuzhiyun   </object>
361*4882a593Smuzhiyun
362*4882a593SmuzhiyunThe layer "pk" values above must be unique, and typically start at "1". The
363*4882a593Smuzhiyunlayer version "pk" values must also be unique across all layers, and typically
364*4882a593Smuzhiyunstart at "1".
365*4882a593Smuzhiyun
366*4882a593SmuzhiyunRemote Toaster Monitoring
367*4882a593Smuzhiyun=========================
368*4882a593Smuzhiyun
369*4882a593SmuzhiyunToaster has an API that allows remote management applications to
370*4882a593Smuzhiyundirectly query the state of the Toaster server and its builds in a
371*4882a593Smuzhiyunmachine-to-machine manner. This API uses the
372*4882a593Smuzhiyun`REST <https://en.wikipedia.org/wiki/Representational_state_transfer>`__
373*4882a593Smuzhiyuninterface and the transfer of JSON files. For example, you might monitor
374*4882a593Smuzhiyuna build inside a container through well supported known HTTP ports in
375*4882a593Smuzhiyunorder to easily access a Toaster server inside the container. In this
376*4882a593Smuzhiyunexample, when you use this direct JSON API, you avoid having web page
377*4882a593Smuzhiyunparsing against the display the user sees.
378*4882a593Smuzhiyun
379*4882a593SmuzhiyunChecking Health
380*4882a593Smuzhiyun---------------
381*4882a593Smuzhiyun
382*4882a593SmuzhiyunBefore you use remote Toaster monitoring, you should do a health check.
383*4882a593SmuzhiyunTo do this, ping the Toaster server using the following call to see if
384*4882a593Smuzhiyunit is still alive::
385*4882a593Smuzhiyun
386*4882a593Smuzhiyun   http://host:port/health
387*4882a593Smuzhiyun
388*4882a593SmuzhiyunBe sure to provide values for host and port. If the server is alive, you will
389*4882a593Smuzhiyunget the response HTML:
390*4882a593Smuzhiyun
391*4882a593Smuzhiyun.. code-block:: html
392*4882a593Smuzhiyun
393*4882a593Smuzhiyun   <!DOCTYPE html>
394*4882a593Smuzhiyun   <html lang="en">
395*4882a593Smuzhiyun      <head><title>Toaster Health</title></head>
396*4882a593Smuzhiyun      <body>Ok</body>
397*4882a593Smuzhiyun   </html>
398*4882a593Smuzhiyun
399*4882a593SmuzhiyunDetermining Status of Builds in Progress
400*4882a593Smuzhiyun----------------------------------------
401*4882a593Smuzhiyun
402*4882a593SmuzhiyunSometimes it is useful to determine the status of a build in progress.
403*4882a593SmuzhiyunTo get the status of pending builds, use the following call::
404*4882a593Smuzhiyun
405*4882a593Smuzhiyun   http://host:port/toastergui/api/building
406*4882a593Smuzhiyun
407*4882a593SmuzhiyunBe sure to provide values for host and port. The output is a JSON file that
408*4882a593Smuzhiyunitemizes all builds in progress. This file includes the time in seconds since
409*4882a593Smuzhiyuneach respective build started as well as the progress of the cloning, parsing,
410*4882a593Smuzhiyunand task execution. Here is sample output for a build in progress:
411*4882a593Smuzhiyun
412*4882a593Smuzhiyun.. code-block:: JSON
413*4882a593Smuzhiyun
414*4882a593Smuzhiyun   {"count": 1,
415*4882a593Smuzhiyun    "building": [
416*4882a593Smuzhiyun      {"machine": "beaglebone",
417*4882a593Smuzhiyun        "seconds": "463.869",
418*4882a593Smuzhiyun        "task": "927:2384",
419*4882a593Smuzhiyun        "distro": "poky",
420*4882a593Smuzhiyun        "clone": "1:1",
421*4882a593Smuzhiyun        "id": 2,
422*4882a593Smuzhiyun        "start": "2017-09-22T09:31:44.887Z",
423*4882a593Smuzhiyun        "name": "20170922093200",
424*4882a593Smuzhiyun        "parse": "818:818",
425*4882a593Smuzhiyun        "project": "my_rocko",
426*4882a593Smuzhiyun        "target": "core-image-minimal"
427*4882a593Smuzhiyun      }]
428*4882a593Smuzhiyun   }
429*4882a593Smuzhiyun
430*4882a593SmuzhiyunThe JSON data for this query is returned in a
431*4882a593Smuzhiyunsingle line. In the previous example the line has been artificially
432*4882a593Smuzhiyunsplit for readability.
433*4882a593Smuzhiyun
434*4882a593SmuzhiyunChecking Status of Builds Completed
435*4882a593Smuzhiyun-----------------------------------
436*4882a593Smuzhiyun
437*4882a593SmuzhiyunOnce a build is completed, you get the status when you use the following
438*4882a593Smuzhiyuncall::
439*4882a593Smuzhiyun
440*4882a593Smuzhiyun   http://host:port/toastergui/api/builds
441*4882a593Smuzhiyun
442*4882a593SmuzhiyunBe sure to provide values for host and port. The output is a JSON file that
443*4882a593Smuzhiyunitemizes all complete builds, and includes build summary information. Here
444*4882a593Smuzhiyunis sample output for a completed build:
445*4882a593Smuzhiyun
446*4882a593Smuzhiyun.. code-block:: JSON
447*4882a593Smuzhiyun
448*4882a593Smuzhiyun   {"count": 1,
449*4882a593Smuzhiyun    "builds": [
450*4882a593Smuzhiyun      {"distro": "poky",
451*4882a593Smuzhiyun         "errors": 0,
452*4882a593Smuzhiyun         "machine": "beaglebone",
453*4882a593Smuzhiyun         "project": "my_rocko",
454*4882a593Smuzhiyun         "stop": "2017-09-22T09:26:36.017Z",
455*4882a593Smuzhiyun         "target": "quilt-native",
456*4882a593Smuzhiyun         "seconds": "78.193",
457*4882a593Smuzhiyun         "outcome": "Succeeded",
458*4882a593Smuzhiyun         "id": 1,
459*4882a593Smuzhiyun         "start": "2017-09-22T09:25:17.824Z",
460*4882a593Smuzhiyun         "warnings": 1,
461*4882a593Smuzhiyun         "name": "20170922092618"
462*4882a593Smuzhiyun      }]
463*4882a593Smuzhiyun   }
464*4882a593Smuzhiyun
465*4882a593SmuzhiyunThe JSON data for this query is returned in a single line. In the
466*4882a593Smuzhiyunprevious example the line has been artificially split for readability.
467*4882a593Smuzhiyun
468*4882a593SmuzhiyunDetermining Status of a Specific Build
469*4882a593Smuzhiyun--------------------------------------
470*4882a593Smuzhiyun
471*4882a593SmuzhiyunSometimes it is useful to determine the status of a specific build. To
472*4882a593Smuzhiyunget the status of a specific build, use the following call::
473*4882a593Smuzhiyun
474*4882a593Smuzhiyun   http://host:port/toastergui/api/build/ID
475*4882a593Smuzhiyun
476*4882a593SmuzhiyunBe sure to provide values for
477*4882a593Smuzhiyunhost, port, and ID. You can find the value for ID from the Builds
478*4882a593SmuzhiyunCompleted query. See the ":ref:`toaster-manual/reference:checking status of builds completed`"
479*4882a593Smuzhiyunsection for more information.
480*4882a593Smuzhiyun
481*4882a593SmuzhiyunThe output is a JSON file that itemizes the specific build and includes
482*4882a593Smuzhiyunbuild summary information. Here is sample output for a specific
483*4882a593Smuzhiyunbuild:
484*4882a593Smuzhiyun
485*4882a593Smuzhiyun.. code-block:: JSON
486*4882a593Smuzhiyun
487*4882a593Smuzhiyun   {"build":
488*4882a593Smuzhiyun      {"distro": "poky",
489*4882a593Smuzhiyun       "errors": 0,
490*4882a593Smuzhiyun       "machine": "beaglebone",
491*4882a593Smuzhiyun       "project": "my_rocko",
492*4882a593Smuzhiyun       "stop": "2017-09-22T09:26:36.017Z",
493*4882a593Smuzhiyun       "target": "quilt-native",
494*4882a593Smuzhiyun       "seconds": "78.193",
495*4882a593Smuzhiyun       "outcome": "Succeeded",
496*4882a593Smuzhiyun       "id": 1,
497*4882a593Smuzhiyun       "start": "2017-09-22T09:25:17.824Z",
498*4882a593Smuzhiyun       "warnings": 1,
499*4882a593Smuzhiyun       "name": "20170922092618",
500*4882a593Smuzhiyun       "cooker_log": "/opt/user/poky/build-toaster-2/tmp/log/cooker/beaglebone/build_20170922_022607.991.log"
501*4882a593Smuzhiyun      }
502*4882a593Smuzhiyun   }
503*4882a593Smuzhiyun
504*4882a593SmuzhiyunThe JSON data for this query is returned in a single line. In the
505*4882a593Smuzhiyunprevious example the line has been artificially split for readability.
506*4882a593Smuzhiyun
507*4882a593SmuzhiyunUseful Commands
508*4882a593Smuzhiyun===============
509*4882a593Smuzhiyun
510*4882a593SmuzhiyunIn addition to the web user interface and the scripts that start and
511*4882a593Smuzhiyunstop Toaster, command-line commands are available through the ``manage.py``
512*4882a593Smuzhiyunmanagement script. You can find general documentation on ``manage.py``
513*4882a593Smuzhiyunat the
514*4882a593Smuzhiyun`Django <https://docs.djangoproject.com/en/2.2/topics/settings/>`__
515*4882a593Smuzhiyunsite. However, several ``manage.py`` commands have been created that are
516*4882a593Smuzhiyunspecific to Toaster and are used to control configuration and back-end
517*4882a593Smuzhiyuntasks. You can locate these commands in the
518*4882a593Smuzhiyun:term:`Source Directory` (e.g. ``poky``) at
519*4882a593Smuzhiyun``bitbake/lib/manage.py``. This section documents those commands.
520*4882a593Smuzhiyun
521*4882a593Smuzhiyun.. note::
522*4882a593Smuzhiyun
523*4882a593Smuzhiyun   -  When using ``manage.py`` commands given a default configuration,
524*4882a593Smuzhiyun      you must be sure that your working directory is set to the
525*4882a593Smuzhiyun      :term:`Build Directory`. Using
526*4882a593Smuzhiyun      ``manage.py`` commands from the Build Directory allows Toaster to
527*4882a593Smuzhiyun      find the ``toaster.sqlite`` file, which is located in the Build
528*4882a593Smuzhiyun      Directory.
529*4882a593Smuzhiyun
530*4882a593Smuzhiyun   -  For non-default database configurations, it is possible that you
531*4882a593Smuzhiyun      can use ``manage.py`` commands from a directory other than the
532*4882a593Smuzhiyun      Build Directory. To do so, the ``toastermain/settings.py`` file
533*4882a593Smuzhiyun      must be configured to point to the correct database backend.
534*4882a593Smuzhiyun
535*4882a593Smuzhiyun``buildslist``
536*4882a593Smuzhiyun--------------
537*4882a593Smuzhiyun
538*4882a593SmuzhiyunThe ``buildslist`` command lists all builds that Toaster has recorded.
539*4882a593SmuzhiyunAccess the command as follows:
540*4882a593Smuzhiyun
541*4882a593Smuzhiyun.. code-block:: shell
542*4882a593Smuzhiyun
543*4882a593Smuzhiyun   $ bitbake/lib/toaster/manage.py buildslist
544*4882a593Smuzhiyun
545*4882a593SmuzhiyunThe command returns a list, which includes numeric
546*4882a593Smuzhiyunidentifications, of the builds that Toaster has recorded in the current
547*4882a593Smuzhiyundatabase.
548*4882a593Smuzhiyun
549*4882a593SmuzhiyunYou need to run the ``buildslist`` command first to identify existing
550*4882a593Smuzhiyunbuilds in the database before using the
551*4882a593Smuzhiyun:ref:`toaster-manual/reference:\`\`builddelete\`\`` command. Here is an
552*4882a593Smuzhiyunexample that assumes default repository and build directory names:
553*4882a593Smuzhiyun
554*4882a593Smuzhiyun.. code-block:: shell
555*4882a593Smuzhiyun
556*4882a593Smuzhiyun   $ cd poky/build
557*4882a593Smuzhiyun   $ python ../bitbake/lib/toaster/manage.py buildslist
558*4882a593Smuzhiyun
559*4882a593SmuzhiyunIf your Toaster database had only one build, the above
560*4882a593Smuzhiyun:ref:`toaster-manual/reference:\`\`buildslist\`\``
561*4882a593Smuzhiyuncommand would return something like the following::
562*4882a593Smuzhiyun
563*4882a593Smuzhiyun   1: qemux86 poky core-image-minimal
564*4882a593Smuzhiyun
565*4882a593Smuzhiyun``builddelete``
566*4882a593Smuzhiyun---------------
567*4882a593Smuzhiyun
568*4882a593SmuzhiyunThe ``builddelete`` command deletes data associated with a build. Access
569*4882a593Smuzhiyunthe command as follows:
570*4882a593Smuzhiyun
571*4882a593Smuzhiyun.. code-block::
572*4882a593Smuzhiyun
573*4882a593Smuzhiyun   $ bitbake/lib/toaster/manage.py builddelete build_id
574*4882a593Smuzhiyun
575*4882a593SmuzhiyunThe command deletes all the build data for the specified
576*4882a593Smuzhiyunbuild_id. This command is useful for removing old and unused data from
577*4882a593Smuzhiyunthe database.
578*4882a593Smuzhiyun
579*4882a593SmuzhiyunPrior to running the ``builddelete`` command, you need to get the ID
580*4882a593Smuzhiyunassociated with builds by using the
581*4882a593Smuzhiyun:ref:`toaster-manual/reference:\`\`buildslist\`\`` command.
582*4882a593Smuzhiyun
583*4882a593Smuzhiyun``perf``
584*4882a593Smuzhiyun--------
585*4882a593Smuzhiyun
586*4882a593SmuzhiyunThe ``perf`` command measures Toaster performance. Access the command as
587*4882a593Smuzhiyunfollows:
588*4882a593Smuzhiyun
589*4882a593Smuzhiyun.. code-block:: shell
590*4882a593Smuzhiyun
591*4882a593Smuzhiyun   $ bitbake/lib/toaster/manage.py perf
592*4882a593Smuzhiyun
593*4882a593SmuzhiyunThe command is a sanity check that returns page loading times in order to
594*4882a593Smuzhiyunidentify performance problems.
595*4882a593Smuzhiyun
596*4882a593Smuzhiyun``checksettings``
597*4882a593Smuzhiyun-----------------
598*4882a593Smuzhiyun
599*4882a593SmuzhiyunThe ``checksettings`` command verifies existing Toaster settings. Access
600*4882a593Smuzhiyunthe command as follows:
601*4882a593Smuzhiyun
602*4882a593Smuzhiyun.. code-block:: shell
603*4882a593Smuzhiyun
604*4882a593Smuzhiyun   $ bitbake/lib/toaster/manage.py checksettings
605*4882a593Smuzhiyun
606*4882a593SmuzhiyunToaster uses settings that are based on the database to configure the
607*4882a593Smuzhiyunbuilding tasks. The ``checksettings`` command verifies that the database
608*4882a593Smuzhiyunsettings are valid in the sense that they have the minimal information
609*4882a593Smuzhiyunneeded to start a build.
610*4882a593Smuzhiyun
611*4882a593SmuzhiyunIn order for the ``checksettings`` command to work, the database must be
612*4882a593Smuzhiyuncorrectly set up and not have existing data. To be sure the database is
613*4882a593Smuzhiyunready, you can run the following:
614*4882a593Smuzhiyun
615*4882a593Smuzhiyun.. code-block:: shell
616*4882a593Smuzhiyun
617*4882a593Smuzhiyun   $ bitbake/lib/toaster/manage.py syncdb
618*4882a593Smuzhiyun   $ bitbake/lib/toaster/manage.py migrate orm
619*4882a593Smuzhiyun   $ bitbake/lib/toaster/manage.py migrate bldcontrol
620*4882a593Smuzhiyun
621*4882a593SmuzhiyunAfter running these commands, you can run the ``checksettings`` command.
622*4882a593Smuzhiyun
623*4882a593Smuzhiyun``runbuilds``
624*4882a593Smuzhiyun-------------
625*4882a593Smuzhiyun
626*4882a593SmuzhiyunThe ``runbuilds`` command launches scheduled builds. Access the command
627*4882a593Smuzhiyunas follows:
628*4882a593Smuzhiyun
629*4882a593Smuzhiyun.. code-block:: shell
630*4882a593Smuzhiyun
631*4882a593Smuzhiyun   $ bitbake/lib/toaster/manage.py runbuilds
632*4882a593Smuzhiyun
633*4882a593SmuzhiyunThe ``runbuilds`` command checks if scheduled builds exist in the database
634*4882a593Smuzhiyunand then launches them per schedule. The command returns after the builds
635*4882a593Smuzhiyunstart but before they complete. The Toaster Logging Interface records and
636*4882a593Smuzhiyunupdates the database when the builds complete.
637