toaster-manual-reference.rst 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. .. SPDX-License-Identifier: CC-BY-2.0-UK
  2. **********************
  3. Concepts and Reference
  4. **********************
  5. In order to configure and use Toaster, you should understand some
  6. concepts and have some basic command reference material available. This
  7. final chapter provides conceptual information on layer sources,
  8. releases, and JSON configuration files. Also provided is a quick look at
  9. some useful ``manage.py`` commands that are Toaster-specific.
  10. Information on ``manage.py`` commands does exist across the Web and the
  11. information in this manual by no means attempts to provide a command
  12. comprehensive reference.
  13. Layer Source
  14. ============
  15. In general, a "layer source" is a source of information about existing
  16. layers. In particular, we are concerned with layers that you can use
  17. with the Yocto Project and Toaster. This chapter describes a particular
  18. type of layer source called a "layer index."
  19. A layer index is a web application that contains information about a set
  20. of custom layers. A good example of an existing layer index is the
  21. OpenEmbedded Layer Index. A public instance of this layer index exists
  22. at ` <http://layers.openembedded.org>`__. You can find the code for this
  23. layer index's web application at
  24. ` <http://git.yoctoproject.org/cgit/cgit.cgi/layerindex-web/>`__.
  25. When you tie a layer source into Toaster, it can query the layer source
  26. through a
  27. `REST <http://en.wikipedia.org/wiki/Representational_state_transfer>`__
  28. API, store the information about the layers in the Toaster database, and
  29. then show the information to users. Users are then able to view that
  30. information and build layers from Toaster itself without worrying about
  31. cloning or editing the BitBake layers configuration file
  32. ``bblayers.conf``.
  33. Tying a layer source into Toaster is convenient when you have many
  34. custom layers that need to be built on a regular basis by a community of
  35. developers. In fact, Toaster comes pre-configured with the OpenEmbedded
  36. Metadata Index.
  37. .. note::
  38. You do not have to use a layer source to use Toaster. Tying into a
  39. layer source is optional.
  40. .. _layer-source-using-with-toaster:
  41. Setting Up and Using a Layer Source
  42. -----------------------------------
  43. To use your own layer source, you need to set up the layer source and
  44. then tie it into Toaster. This section describes how to tie into a layer
  45. index in a manner similar to the way Toaster ties into the OpenEmbedded
  46. Metadata Index.
  47. Understanding Your Layers
  48. ~~~~~~~~~~~~~~~~~~~~~~~~~
  49. The obvious first step for using a layer index is to have several custom
  50. layers that developers build and access using the Yocto Project on a
  51. regular basis. This set of layers needs to exist and you need to be
  52. familiar with where they reside. You will need that information when you
  53. set up the code for the web application that "hooks" into your set of
  54. layers.
  55. For general information on layers, see the "`The Yocto Project Layer
  56. Model <&YOCTO_DOCS_OM_URL;#the-yocto-project-layer-model>`__" section in
  57. the Yocto Project Overview and Concepts Manual. For information on how
  58. to create layers, see the "`Understanding and Creating
  59. Layers <&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers>`__"
  60. section in the Yocto Project Development Tasks Manual.
  61. .. _configuring-toaster-to-hook-into-your-layer-source:
  62. Configuring Toaster to Hook Into Your Layer Index
  63. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  64. If you want Toaster to use your layer index, you must host the web
  65. application in a server to which Toaster can connect. You also need to
  66. give Toaster the information about your layer index. In other words, you
  67. have to configure Toaster to use your layer index. This section
  68. describes two methods by which you can configure and use your layer
  69. index.
  70. In the previous section, the code for the OpenEmbedded Metadata Index
  71. (i.e. ` <http://layers.openembedded.org>`__) was referenced. You can use
  72. this code, which is at
  73. ` <http://git.yoctoproject.org/cgit/cgit.cgi/layerindex-web/>`__, as a
  74. base to create your own layer index.
  75. Use the Administration Interface
  76. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  77. Access the administration interface through a browser by entering the
  78. URL of your Toaster instance and adding "``/admin``" to the end of the
  79. URL. As an example, if you are running Toaster locally, use the
  80. following URL: http://127.0.0.1:8000/admin
  81. The administration interface has a "Layer sources" section that includes
  82. an "Add layer source" button. Click that button and provide the required
  83. information. Make sure you select "layerindex" as the layer source type.
  84. Use the Fixture Feature
  85. ^^^^^^^^^^^^^^^^^^^^^^^
  86. The Django fixture feature overrides the default layer server when you
  87. use it to specify a custom URL. To use the fixture feature, create (or
  88. edit) the file ``bitbake/lib/toaster.orm/fixtures/custom.xml``, and then
  89. set the following Toaster setting to your custom URL: <?xml
  90. version="1.0" ?> <django-objects version="1.0"> <object
  91. model="orm.toastersetting" pk="100"> <field name="name"
  92. type="CharField">CUSTOM_LAYERINDEX_SERVER</field> <field name="value"
  93. type="CharField">https://layers.my_organization.org/layerindex/branch/master/layers/</field>
  94. </object> <django-objects> When you start Toaster for the first time, or
  95. if you delete the file ``toaster.sqlite`` and restart, the database will
  96. populate cleanly from this layer index server.
  97. Once the information has been updated, verify the new layer information
  98. is available by using the Toaster web interface. To do that, visit the
  99. "All compatible layers" page inside a Toaster project. The layers from
  100. your layer source should be listed there.
  101. If you change the information in your layer index server, refresh the
  102. Toaster database by running the following command: $
  103. bitbake/lib/toaster/manage.py lsupdates If Toaster can reach the API
  104. URL, you should see a message telling you that Toaster is updating the
  105. layer source information.
  106. .. _toaster-releases:
  107. Releases
  108. ========
  109. When you create a Toaster project using the web interface, you are asked
  110. to choose a "Release." In the context of Toaster, the term "Release"
  111. refers to a set of layers and a BitBake version the OpenEmbedded build
  112. system uses to build something. As shipped, Toaster is pre-configured
  113. with releases that correspond to Yocto Project release branches.
  114. However, you can modify, delete, and create new releases according to
  115. your needs. This section provides some background information on
  116. releases.
  117. .. _toaster-releases-supported:
  118. Pre-Configured Releases
  119. -----------------------
  120. As shipped, Toaster is configured to use a specific set of releases. Of
  121. course, you can always configure Toaster to use any release. For
  122. example, you might want your project to build against a specific commit
  123. of any of the "out-of-the-box" releases. Or, you might want your project
  124. to build against different revisions of OpenEmbedded and BitBake.
  125. As shipped, Toaster is configured to work with the following releases:
  126. - *Yocto Project DISTRO "DISTRO_NAME" or OpenEmbedded "DISTRO_NAME":*
  127. This release causes your Toaster projects to build against the head
  128. of the DISTRO_NAME_NO_CAP branch at
  129. ` <&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/log/?h=rocko>`__ or
  130. ` <http://git.openembedded.org/openembedded-core/commit/?h=rocko>`__.
  131. - *Yocto Project "Master" or OpenEmbedded "Master":* This release
  132. causes your Toaster Projects to build against the head of the master
  133. branch, which is where active development takes place, at
  134. ` <&YOCTO_GIT_URL;/cgit/cgit.cgi/poky/log/>`__ or
  135. ` <http://git.openembedded.org/openembedded-core/log/>`__.
  136. - *Local Yocto Project or Local OpenEmbedded:* This release causes your
  137. Toaster Projects to build against the head of the ``poky`` or
  138. ``openembedded-core`` clone you have local to the machine running
  139. Toaster.
  140. Configuring Toaster
  141. ===================
  142. In order to use Toaster, you must configure the database with the
  143. default content. The following subsections describe various aspects of
  144. Toaster configuration.
  145. Configuring the Workflow
  146. ------------------------
  147. The ``bldcontrol/management/commands/checksettings.py`` file controls
  148. workflow configuration. The following steps outline the process to
  149. initially populate this database.
  150. 1. The default project settings are set from
  151. ``orm/fixtures/settings.xml``.
  152. 2. The default project distro and layers are added from
  153. ``orm/fixtures/poky.xml`` if poky is installed. If poky is not
  154. installed, they are added from ``orm/fixtures/oe-core.xml``.
  155. 3. If the ``orm/fixtures/custom.xml`` file exists, then its values are
  156. added.
  157. 4. The layer index is then scanned and added to the database.
  158. Once these steps complete, Toaster is set up and ready to use.
  159. Customizing Pre-Set Data
  160. ------------------------
  161. The pre-set data for Toaster is easily customizable. You can create the
  162. ``orm/fixtures/custom.xml`` file to customize the values that go into to
  163. the database. Customization is additive, and can either extend or
  164. completely replace the existing values.
  165. You use the ``orm/fixtures/custom.xml`` file to change the default
  166. project settings for the machine, distro, file images, and layers. When
  167. creating a new project, you can use the file to define the offered
  168. alternate project release selections. For example, you can add one or
  169. more additional selections that present custom layer sets or distros,
  170. and any other local or proprietary content.
  171. Additionally, you can completely disable the content from the
  172. ``oe-core.xml`` and ``poky.xml`` files by defining the section shown
  173. below in the ``settings.xml`` file. For example, this option is
  174. particularly useful if your custom configuration defines fewer releases
  175. or layers than the default fixture files.
  176. The following example sets "name" to "CUSTOM_XML_ONLY" and its value to
  177. "True". <object model="orm.toastersetting" pk="99"> <field
  178. type="CharField" name="name">CUSTOM_XML_ONLY</field> <field
  179. type="CharField" name="value">True</field> </object>
  180. Understanding Fixture File Format
  181. ---------------------------------
  182. The following is an overview of the file format used by the
  183. ``oe-core.xml``, ``poky.xml``, and ``custom.xml`` files.
  184. The following subsections describe each of the sections in the fixture
  185. files, and outline an example section of the XML code. you can use to
  186. help understand this information and create a local ``custom.xml`` file.
  187. Defining the Default Distro and Other Values
  188. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  189. This section defines the default distro value for new projects. By
  190. default, it reserves the first Toaster Setting record "1". The following
  191. demonstrates how to set the project default value for
  192. :term:`DISTRO`: <!-- Set the project
  193. default value for DISTRO --> <object model="orm.toastersetting" pk="1">
  194. <field type="CharField" name="name">DEFCONF_DISTRO</field> <field
  195. type="CharField" name="value">poky</field> </object> You can override
  196. other default project values by adding additional Toaster Setting
  197. sections such as any of the settings coming from the ``settings.xml``
  198. file. Also, you can add custom values that are included in the BitBake
  199. environment. The "pk" values must be unique. By convention, values that
  200. set default project values have a "DEFCONF" prefix.
  201. Defining BitBake Version
  202. ~~~~~~~~~~~~~~~~~~~~~~~~
  203. The following defines which version of BitBake is used for the following
  204. release selection: <!-- Bitbake versions which correspond to the
  205. metadata release --> <object model="orm.bitbakeversion" pk="1"> <field
  206. type="CharField" name="name">rocko</field> <field type="CharField"
  207. name="giturl">git://git.yoctoproject.org/poky</field> <field
  208. type="CharField" name="branch">rocko</field> <field type="CharField"
  209. name="dirpath">bitbake</field> </object>
  210. .. _defining-releases:
  211. Defining Release
  212. ~~~~~~~~~~~~~~~~
  213. The following defines the releases when you create a new project. <!--
  214. Releases available --> <object model="orm.release" pk="1"> <field
  215. type="CharField" name="name">rocko</field> <field type="CharField"
  216. name="description">Yocto Project 2.4 "Rocko"</field> <field
  217. rel="ManyToOneRel" to="orm.bitbakeversion"
  218. name="bitbake_version">1</field> <field type="CharField"
  219. name="branch_name">rocko</field> <field type="TextField"
  220. name="helptext">Toaster will run your builds using the tip of the <a
  221. href="http://git.yoctoproject.org/cgit/cgit.cgi/poky/log/?h=rocko">Yocto
  222. Project Rocko branch</a>.</field> </object> The "pk" value must match
  223. the above respective BitBake version record.
  224. Defining the Release Default Layer Names
  225. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  226. The following defines the default layers for each release: <!-- Default
  227. project layers for each release --> <object
  228. model="orm.releasedefaultlayer" pk="1"> <field rel="ManyToOneRel"
  229. to="orm.release" name="release">1</field> <field type="CharField"
  230. name="layer_name">openembedded-core</field> </object> The 'pk' values in
  231. the example above should start at "1" and increment uniquely. You can
  232. use the same layer name in multiple releases.
  233. Defining Layer Definitions
  234. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  235. Layer definitions are the most complex. The following defines each of
  236. the layers, and then defines the exact layer version of the layer used
  237. for each respective release. You must have one ``orm.layer`` entry for
  238. each layer. Then, with each entry you need a set of
  239. ``orm.layer_version`` entries that connects the layer with each release
  240. that includes the layer. In general all releases include the layer.
  241. <object model="orm.layer" pk="1"> <field type="CharField"
  242. name="name">openembedded-core</field> <field type="CharField"
  243. name="layer_index_url"></field> <field type="CharField"
  244. name="vcs_url">git://git.yoctoproject.org/poky</field> <field
  245. type="CharField"
  246. name="vcs_web_url">http://git.yoctoproject.org/cgit/cgit.cgi/poky</field>
  247. <field type="CharField"
  248. name="vcs_web_tree_base_url">http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/%path%?h=%branch%</field>
  249. <field type="CharField"
  250. name="vcs_web_file_base_url">http://git.yoctoproject.org/cgit/cgit.cgi/poky/tree/%path%?h=%branch%</field>
  251. </object> <object model="orm.layer_version" pk="1"> <field
  252. rel="ManyToOneRel" to="orm.layer" name="layer">1</field> <field
  253. type="IntegerField" name="layer_source">0</field> <field
  254. rel="ManyToOneRel" to="orm.release" name="release">1</field> <field
  255. type="CharField" name="branch">rocko</field> <field type="CharField"
  256. name="dirpath">meta</field> </object> <object model="orm.layer_version"
  257. pk="2"> <field rel="ManyToOneRel" to="orm.layer" name="layer">1</field>
  258. <field type="IntegerField" name="layer_source">0</field> <field
  259. rel="ManyToOneRel" to="orm.release" name="release">2</field> <field
  260. type="CharField" name="branch">HEAD</field> <field type="CharField"
  261. name="commit">HEAD</field> <field type="CharField"
  262. name="dirpath">meta</field> </object> <object model="orm.layer_version"
  263. pk="3"> <field rel="ManyToOneRel" to="orm.layer" name="layer">1</field>
  264. <field type="IntegerField" name="layer_source">0</field> <field
  265. rel="ManyToOneRel" to="orm.release" name="release">3</field> <field
  266. type="CharField" name="branch">master</field> <field type="CharField"
  267. name="dirpath">meta</field> </object> The layer "pk" values above must
  268. be unique, and typically start at "1". The layer version "pk" values
  269. must also be unique across all layers, and typically start at "1".
  270. Remote Toaster Monitoring
  271. =========================
  272. Toaster has an API that allows remote management applications to
  273. directly query the state of the Toaster server and its builds in a
  274. machine-to-machine manner. This API uses the
  275. `REST <http://en.wikipedia.org/wiki/Representational_state_transfer>`__
  276. interface and the transfer of JSON files. For example, you might monitor
  277. a build inside a container through well supported known HTTP ports in
  278. order to easily access a Toaster server inside the container. In this
  279. example, when you use this direct JSON API, you avoid having web page
  280. parsing against the display the user sees.
  281. Checking Health
  282. ---------------
  283. Before you use remote Toaster monitoring, you should do a health check.
  284. To do this, ping the Toaster server using the following call to see if
  285. it is still alive: http://host:port/health Be sure to provide values for
  286. host and port. If the server is alive, you will get the response HTML:
  287. <!DOCTYPE html> <html lang="en"> <head><title>Toaster
  288. Health</title></head> <body>Ok</body> </html>
  289. Determining Status of Builds in Progress
  290. ----------------------------------------
  291. Sometimes it is useful to determine the status of a build in progress.
  292. To get the status of pending builds, use the following call:
  293. http://host:port/toastergui/api/building Be sure to provide values for
  294. host and port. The output is a JSON file that itemizes all builds in
  295. progress. This file includes the time in seconds since each respective
  296. build started as well as the progress of the cloning, parsing, and task
  297. execution. The following is sample output for a build in progress:
  298. {"count": 1, "building": [ {"machine": "beaglebone", "seconds":
  299. "463.869", "task": "927:2384", "distro": "poky", "clone": "1:1", "id":
  300. 2, "start": "2017-09-22T09:31:44.887Z", "name": "20170922093200",
  301. "parse": "818:818", "project": "my_rocko", "target":
  302. "core-image-minimal" }] } The JSON data for this query is returned in a
  303. single line. In the previous example the line has been artificially
  304. split for readability.
  305. Checking Status of Builds Completed
  306. -----------------------------------
  307. Once a build is completed, you get the status when you use the following
  308. call: http://host:port/toastergui/api/builds Be sure to provide values
  309. for host and port. The output is a JSON file that itemizes all complete
  310. builds, and includes build summary information. The following is sample
  311. output for a completed build: {"count": 1, "builds": [ {"distro":
  312. "poky", "errors": 0, "machine": "beaglebone", "project": "my_rocko",
  313. "stop": "2017-09-22T09:26:36.017Z", "target": "quilt-native", "seconds":
  314. "78.193", "outcome": "Succeeded", "id": 1, "start":
  315. "2017-09-22T09:25:17.824Z", "warnings": 1, "name": "20170922092618" }] }
  316. The JSON data for this query is returned in a single line. In the
  317. previous example the line has been artificially split for readability.
  318. Determining Status of a Specific Build
  319. --------------------------------------
  320. Sometimes it is useful to determine the status of a specific build. To
  321. get the status of a specific build, use the following call:
  322. http://host:port/toastergui/api/build/ID Be sure to provide values for
  323. host, port, and ID. You can find the value for ID from the Builds
  324. Completed query. See the "`Checking Status of Builds
  325. Completed <#checking-status-of-builds-completed>`__" section for more
  326. information.
  327. The output is a JSON file that itemizes the specific build and includes
  328. build summary information. The following is sample output for a specific
  329. build: {"build": {"distro": "poky", "errors": 0, "machine":
  330. "beaglebone", "project": "my_rocko", "stop": "2017-09-22T09:26:36.017Z",
  331. "target": "quilt-native", "seconds": "78.193", "outcome": "Succeeded",
  332. "id": 1, "start": "2017-09-22T09:25:17.824Z", "warnings": 1, "name":
  333. "20170922092618", "cooker_log":
  334. "/opt/user/poky/build-toaster-2/tmp/log/cooker/beaglebone/build_20170922_022607.991.log"
  335. } } The JSON data for this query is returned in a single line. In the
  336. previous example the line has been artificially split for readability.
  337. .. _toaster-useful-commands:
  338. Useful Commands
  339. ===============
  340. In addition to the web user interface and the scripts that start and
  341. stop Toaster, command-line commands exist through the ``manage.py``
  342. management script. You can find general documentation on ``manage.py``
  343. at the
  344. `Django <https://docs.djangoproject.com/en/1.7/topics/settings/>`__
  345. site. However, several ``manage.py`` commands have been created that are
  346. specific to Toaster and are used to control configuration and back-end
  347. tasks. You can locate these commands in the `Source
  348. Directory <&YOCTO_DOCS_REF_URL;#source-directory>`__ (e.g. ``poky``) at
  349. ``bitbake/lib/manage.py``. This section documents those commands.
  350. .. note::
  351. - When using ``manage.py`` commands given a default configuration,
  352. you must be sure that your working directory is set to the `Build
  353. Directory <&YOCTO_DOCS_REF_URL;#build-directory>`__. Using
  354. ``manage.py`` commands from the Build Directory allows Toaster to
  355. find the ``toaster.sqlite`` file, which is located in the Build
  356. Directory.
  357. - For non-default database configurations, it is possible that you
  358. can use ``manage.py`` commands from a directory other than the
  359. Build Directory. To do so, the ``toastermain/settings.py`` file
  360. must be configured to point to the correct database backend.
  361. .. _toaster-command-buildslist:
  362. ``buildslist``
  363. --------------
  364. The ``buildslist`` command lists all builds that Toaster has recorded.
  365. Access the command as follows: $ bitbake/lib/toaster/manage.py
  366. buildslist The command returns a list, which includes numeric
  367. identifications, of the builds that Toaster has recorded in the current
  368. database.
  369. You need to run the ``buildslist`` command first to identify existing
  370. builds in the database before using the
  371. ```builddelete`` <#toaster-command-builddelete>`__ command. Here is an
  372. example that assumes default repository and build directory names: $ cd
  373. ~/poky/build $ python ../bitbake/lib/toaster/manage.py buildslist If
  374. your Toaster database had only one build, the above ``buildslist``
  375. command would return something like the following: 1: qemux86 poky
  376. core-image-minimal
  377. .. _toaster-command-builddelete:
  378. ``builddelete``
  379. ---------------
  380. The ``builddelete`` command deletes data associated with a build. Access
  381. the command as follows: $ bitbake/lib/toaster/manage.py builddelete
  382. build_id The command deletes all the build data for the specified
  383. build_id. This command is useful for removing old and unused data from
  384. the database.
  385. Prior to running the ``builddelete`` command, you need to get the ID
  386. associated with builds by using the
  387. ```buildslist`` <#toaster-command-buildslist>`__ command.
  388. .. _toaster-command-perf:
  389. ``perf``
  390. --------
  391. The ``perf`` command measures Toaster performance. Access the command as
  392. follows: $ bitbake/lib/toaster/manage.py perf The command is a sanity
  393. check that returns page loading times in order to identify performance
  394. problems.
  395. .. _toaster-command-checksettings:
  396. ``checksettings``
  397. -----------------
  398. The ``checksettings`` command verifies existing Toaster settings. Access
  399. the command as follows: $ bitbake/lib/toaster/manage.py checksettings
  400. Toaster uses settings that are based on the database to configure the
  401. building tasks. The ``checksettings`` command verifies that the database
  402. settings are valid in the sense that they have the minimal information
  403. needed to start a build.
  404. In order for the ``checksettings`` command to work, the database must be
  405. correctly set up and not have existing data. To be sure the database is
  406. ready, you can run the following: $ bitbake/lib/toaster/mana​ge.py
  407. syncdb $ bitbake/lib/toaster/mana​ge.py migrate orm $
  408. bitbake/lib/toaster/mana​ge.py migrate bldcontrol After running these
  409. commands, you can run the ``checksettings`` command.
  410. .. _toaster-command-runbuilds:
  411. ``runbuilds``
  412. -------------
  413. The ``runbuilds`` command launches scheduled builds. Access the command
  414. as follows: $ bitbake/lib/toaster/manage.py runbuilds The ``runbuilds``
  415. command checks if scheduled builds exist in the database and then
  416. launches them per schedule. The command returns after the builds start
  417. but before they complete. The Toaster Logging Interface records and
  418. updates the database when the builds complete.