lorax/lorax-composer/lorax-composer.html
2018-03-16 16:41:16 -07:00

226 lines
14 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>lorax-composer &mdash; Lorax 19.7.11 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '19.7.11',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Lorax 19.7.11 documentation" href="index.html" />
<link rel="next" title="Product and Updates Images" href="product-images.html" />
<link rel="prev" title="livemedia-creator" href="livemedia-creator.html" />
</head>
<body>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="product-images.html" title="Product and Updates Images"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="livemedia-creator.html" title="livemedia-creator"
accesskey="P">previous</a> |</li>
<li><a href="index.html">Lorax 19.7.11 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="lorax-composer">
<h1>lorax-composer<a class="headerlink" href="#lorax-composer" title="Permalink to this headline"></a></h1>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Authors:</th><td class="field-body">Brian C. Lane &lt;<a class="reference external" href="mailto:bcl&#37;&#52;&#48;redhat&#46;com">bcl<span>&#64;</span>redhat<span>&#46;</span>com</a>&gt;</td>
</tr>
</tbody>
</table>
<p>lorax-composer is an API server that is compatible with the Weldr project&#8217;s
bdcs-api REST protocol. More information on Weldr can be found <a class="reference external" href="http://www.weldr.io">on the Weldr
blog</a>.</p>
<p>The server runs as root, and communication with it is via a unix domain socket
(<tt class="docutils literal"><span class="pre">/run/weldr/api.socket</span></tt> by default). The directory and socket are owned by
root:weldr so that any user in the weldr group can use the API to control
lorax-composer.</p>
<p>When starting the server it will check for the correct permissions and
ownership of a pre-existing directory, or it will create a new one if it
doesn&#8217;t exist. The socket path and group owner&#8217;s name can be changed from the
cmdline by passing it the <tt class="docutils literal"><span class="pre">--socket</span></tt> and <tt class="docutils literal"><span class="pre">--group</span></tt> arguments.</p>
<p>As of version 19.7.7 it will drop root privileges for the API thread. The queue
and compose thread still runs as root because it needs to be able to
mount/umount files and run Anaconda.</p>
<div class="section" id="logs">
<h2>Logs<a class="headerlink" href="#logs" title="Permalink to this headline"></a></h2>
<p>Logs are stored under <tt class="docutils literal"><span class="pre">/var/log/lorax-composer/</span></tt> and include all console
messages as well as extra debugging info and API requests.</p>
</div>
<div class="section" id="quickstart">
<h2>Quickstart<a class="headerlink" href="#quickstart" title="Permalink to this headline"></a></h2>
<ol class="arabic simple">
<li>Create a <tt class="docutils literal"><span class="pre">weldr</span></tt> user and group by running <tt class="docutils literal"><span class="pre">useradd</span> <span class="pre">weldr</span></tt></li>
<li>Remove any pre-existing socket directory with <tt class="docutils literal"><span class="pre">rm</span> <span class="pre">-rf</span> <span class="pre">/run/weldr/</span></tt>
A new directory with correct permissions will be created the first time the server runs.</li>
<li>Either start it via systemd with <tt class="docutils literal"><span class="pre">systemctl</span> <span class="pre">start</span> <span class="pre">lorax-composer</span></tt> or
run it directly with <tt class="docutils literal"><span class="pre">lorax-composer</span> <span class="pre">/path/to/recipes/</span></tt></li>
</ol>
<p>The <tt class="docutils literal"><span class="pre">/path/to/recipes/</span></tt> is where the recipe&#8217;s git repo will be created, and
all the recipes created with the <tt class="docutils literal"><span class="pre">/api/v0/recipes/new</span></tt> route will be stored.
If there are recipe <tt class="docutils literal"><span class="pre">.toml</span></tt> files in the top level of the directory they will
be imported into the recipe git storage.</p>
</div>
<div class="section" id="composing-images">
<h2>Composing Images<a class="headerlink" href="#composing-images" title="Permalink to this headline"></a></h2>
<p>As of version 19.7.7 lorax-composer can create <tt class="docutils literal"><span class="pre">tar</span></tt> output images. You can use curl to start
a compose like this:</p>
<div class="highlight-python"><pre>curl --unix-socket /run/weldr/api.socket -X POST -H "Content-Type: application/json" -d '{"recipe_name": "http-server", "compose_type": "tar", "branch": "master"}' http:///api/v0/compose</pre>
</div>
<p>And then monitor it by passing the returned build UUID to <tt class="docutils literal"><span class="pre">/compose/status/&lt;uuid&gt;</span></tt>.</p>
<p>Version 19.7.10 adds support for <tt class="docutils literal"><span class="pre">live-iso</span></tt> and <tt class="docutils literal"><span class="pre">partitioned-disk</span></tt></p>
</div>
<div class="section" id="adding-output-types">
<h2>Adding Output Types<a class="headerlink" href="#adding-output-types" title="Permalink to this headline"></a></h2>
<p>livemedia-creator supports a large number of output types, and only some of
these are currently available via lorax-composer. To add a new output type to
lorax-composer a kickstart file needs to be added to <tt class="docutils literal"><span class="pre">./share/composer/</span></tt>. The
name of the kickstart is what will be used by the <tt class="docutils literal"><span class="pre">/compose/types</span></tt> route, and the
<tt class="docutils literal"><span class="pre">compose_type</span></tt> field of the POST to start a compose. It also needs to have
code added to the <a class="reference internal" href="pylorax.api.html#pylorax.api.compose.compose_args" title="pylorax.api.compose.compose_args"><tt class="xref py py-func docutils literal"><span class="pre">pylorax.api.compose.compose_args()</span></tt></a> function. The
<tt class="docutils literal"><span class="pre">_MAP</span></tt> entry in this function defines what lorax-composer will pass to
<a class="reference internal" href="pylorax.html#pylorax.installer.novirt_install" title="pylorax.installer.novirt_install"><tt class="xref py py-func docutils literal"><span class="pre">pylorax.installer.novirt_install()</span></tt></a> when it runs the compose. When the
compose is finished the output files need to be copied out of the build
directory (<tt class="docutils literal"><span class="pre">/var/lib/lorax/composer/results/&lt;UUID&gt;/compose/</span></tt>),
<a class="reference internal" href="pylorax.api.html#pylorax.api.compose.move_compose_results" title="pylorax.api.compose.move_compose_results"><tt class="xref py py-func docutils literal"><span class="pre">pylorax.api.compose.move_compose_results()</span></tt></a> handles this for each type.
You should move them instead of copying to save space.</p>
<p>If the new output type does not have support in livemedia-creator it should be
added there first. This will make the output available to the widest number of
users.</p>
<div class="section" id="example-add-partitioned-disk-support">
<h3>Example: Add partitioned disk support<a class="headerlink" href="#example-add-partitioned-disk-support" title="Permalink to this headline"></a></h3>
<p>Partitioned disk support is something that livemedia-creator already supports
via the <tt class="docutils literal"><span class="pre">--make-disk</span></tt> cmdline argument. To add this to lorax-composer it
needs 3 things:</p>
<ul class="simple">
<li>A <tt class="docutils literal"><span class="pre">partitioned-disk.ks</span></tt> file in <tt class="docutils literal"><span class="pre">./share/composer/</span></tt></li>
<li>A new entry in the _MAP in <a class="reference internal" href="pylorax.api.html#pylorax.api.compose.compose_args" title="pylorax.api.compose.compose_args"><tt class="xref py py-func docutils literal"><span class="pre">pylorax.api.compose.compose_args()</span></tt></a></li>
<li>Add a bit of code to <a class="reference internal" href="pylorax.api.html#pylorax.api.compose.move_compose_results" title="pylorax.api.compose.move_compose_results"><tt class="xref py py-func docutils literal"><span class="pre">pylorax.api.compose.move_compose_results()</span></tt></a> to move the disk image from
the compose directory to the results directory.</li>
</ul>
<p>The <tt class="docutils literal"><span class="pre">partitioned-disk.ks</span></tt> is pretty similar to the example minimal kickstart
in <tt class="docutils literal"><span class="pre">./docs/rhel7-minimal.ks</span></tt>. You should remove the <tt class="docutils literal"><span class="pre">url</span></tt> and <tt class="docutils literal"><span class="pre">repo</span></tt>
commands, they will be added by the compose process. Make sure the bootloader
packages are included in the <tt class="docutils literal"><span class="pre">%packages</span></tt> section at the end of the kickstart,
and you will want to leave off the <tt class="docutils literal"><span class="pre">%end</span></tt> so that the compose can append the
list of packages from the recipe.</p>
<p>The new <tt class="docutils literal"><span class="pre">_MAP</span></tt> entry should be a copy of one of the existing entries, but with <tt class="docutils literal"><span class="pre">make_disk</span></tt> set
to <tt class="docutils literal"><span class="pre">True</span></tt>. Make sure that none of the other <tt class="docutils literal"><span class="pre">make_*</span></tt> options are <tt class="docutils literal"><span class="pre">True</span></tt>. The <tt class="docutils literal"><span class="pre">image_name</span></tt> is
what the name of the final image will be.</p>
<p><tt class="docutils literal"><span class="pre">move_compose_results()</span></tt> can be as simple as moving the output file into
the results directory, or it could do some post-processing on it. The end of
the function should always clean up the <tt class="docutils literal"><span class="pre">./compose/</span></tt> directory, removing any
unneeded extra files. This is especially true for the <tt class="docutils literal"><span class="pre">live-iso</span></tt> since it produces
the contents of the iso as well as the boot.iso itself.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">lorax-composer</a><ul>
<li><a class="reference internal" href="#logs">Logs</a></li>
<li><a class="reference internal" href="#quickstart">Quickstart</a></li>
<li><a class="reference internal" href="#composing-images">Composing Images</a></li>
<li><a class="reference internal" href="#adding-output-types">Adding Output Types</a><ul>
<li><a class="reference internal" href="#example-add-partitioned-disk-support">Example: Add partitioned disk support</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="livemedia-creator.html"
title="previous chapter">livemedia-creator</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="product-images.html"
title="next chapter">Product and Updates Images</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/lorax-composer.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="search.html" method="get">
<input type="text" name="q" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="product-images.html" title="Product and Updates Images"
>next</a> |</li>
<li class="right" >
<a href="livemedia-creator.html" title="livemedia-creator"
>previous</a> |</li>
<li><a href="index.html">Lorax 19.7.11 documentation</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2018, Red Hat, Inc..
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
</div>
</body>
</html>