kolla-cli/doc/build/html/_modules/kollacli/api/async.html
Borne Mace 6f695e5fef Updated api docs
Jira-Issue: OSTACKDEV-19
2016-03-30 16:13:19 -07:00

226 lines
20 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>kollacli.api.async &mdash; kollacli 1.0.0.dev379 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: '1.0.0.dev379',
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="kollacli 1.0.0.dev379 documentation" href="../../../index.html" />
<link rel="up" title="Module code" href="../../index.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><a href="../../../index.html">kollacli 1.0.0.dev379 documentation</a> &raquo;</li>
<li><a href="../../index.html" accesskey="U">Module code</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<h1>Source code for kollacli.api.async</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright(c) 2016, Oracle and/or its affiliates. All Rights Reserved.</span>
<span class="c1">#</span>
<span class="c1"># Licensed under the Apache License, Version 2.0 (the &quot;License&quot;); you may</span>
<span class="c1"># not use this file except in compliance with the License. You may obtain</span>
<span class="c1"># a copy of the License at</span>
<span class="c1">#</span>
<span class="c1"># http://www.apache.org/licenses/LICENSE-2.0</span>
<span class="c1">#</span>
<span class="c1"># Unless required by applicable law or agreed to in writing, software</span>
<span class="c1"># distributed under the License is distributed on an &quot;AS IS&quot; BASIS, WITHOUT</span>
<span class="c1"># WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the</span>
<span class="c1"># License for the specific language governing permissions and limitations</span>
<span class="c1"># under the License.</span>
<span class="kn">import</span> <span class="nn">kollacli.i18n</span> <span class="kn">as</span> <span class="nn">u</span>
<span class="kn">from</span> <span class="nn">kollacli.api.exceptions</span> <span class="kn">import</span> <span class="n">InvalidArgument</span>
<span class="kn">from</span> <span class="nn">kollacli.api.job</span> <span class="kn">import</span> <span class="n">Job</span>
<span class="kn">from</span> <span class="nn">kollacli.common.ansible</span> <span class="kn">import</span> <span class="n">actions</span>
<span class="kn">from</span> <span class="nn">kollacli.common.inventory</span> <span class="kn">import</span> <span class="n">Inventory</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">check_arg</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">safe_decode</span>
<div class="viewcode-block" id="AsyncApi"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.async.AsyncApi">[docs]</a><span class="k">class</span> <span class="nc">AsyncApi</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="c1"># TODO(bmace) -- update this to only take host names</span>
<span class="c1"># and we will probably only support compute host individual deploys</span>
<div class="viewcode-block" id="AsyncApi.async_deploy"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.async.AsyncApi.async_deploy">[docs]</a> <span class="k">def</span> <span class="nf">async_deploy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostnames</span><span class="o">=</span><span class="p">[],</span> <span class="n">groupnames</span><span class="o">=</span><span class="p">[],</span> <span class="n">servicenames</span><span class="o">=</span><span class="p">[],</span>
<span class="n">serial_flag</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">verbose_level</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Deploy.</span>
<span class="sd"> Deploy containers to hosts.</span>
<span class="sd"> :param hostnames: hosts to deploy to. If empty, then deploy to all.</span>
<span class="sd"> :type hostnames: list of strings</span>
<span class="sd"> :param groupnames: names of groups</span>
<span class="sd"> :type groupnames: list of strings</span>
<span class="sd"> :param servicenames: names of services</span>
<span class="sd"> :type servicenames: list of strings</span>
<span class="sd"> :param serial_flag: if true, deploy will be done one host at a time</span>
<span class="sd"> :type serial_flag: boolean</span>
<span class="sd"> :param verbose_level: the higher the number, the more verbose</span>
<span class="sd"> :type verbose_level: integer</span>
<span class="sd"> :return: Job object</span>
<span class="sd"> :rtype: Job</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">hostnames</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host names&#39;</span><span class="p">),</span> <span class="nb">list</span><span class="p">,</span>
<span class="n">empty_ok</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">none_ok</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">groupnames</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Group names&#39;</span><span class="p">),</span> <span class="nb">list</span><span class="p">,</span>
<span class="n">empty_ok</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">none_ok</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">servicenames</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Service names&#39;</span><span class="p">),</span> <span class="nb">list</span><span class="p">,</span>
<span class="n">empty_ok</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="n">none_ok</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">serial_flag</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Serial flag&#39;</span><span class="p">),</span> <span class="nb">bool</span><span class="p">)</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">verbose_level</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Verbose level&#39;</span><span class="p">),</span> <span class="nb">int</span><span class="p">)</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">hostnames</span><span class="p">)</span>
<span class="n">groupnames</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">groupnames</span><span class="p">)</span>
<span class="n">servicenames</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">servicenames</span><span class="p">)</span>
<span class="n">ansible_job</span> <span class="o">=</span> <span class="n">actions</span><span class="o">.</span><span class="n">deploy</span><span class="p">(</span><span class="n">hostnames</span><span class="p">,</span> <span class="n">groupnames</span><span class="p">,</span> <span class="n">servicenames</span><span class="p">,</span>
<span class="n">serial_flag</span><span class="p">,</span> <span class="n">verbose_level</span><span class="p">)</span>
<span class="k">return</span> <span class="n">Job</span><span class="p">(</span><span class="n">ansible_job</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="AsyncApi.async_upgrade"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.async.AsyncApi.async_upgrade">[docs]</a> <span class="k">def</span> <span class="nf">async_upgrade</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">verbose_level</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Upgrade.</span>
<span class="sd"> :param verbose_level: the higher the number, the more verbose</span>
<span class="sd"> :type verbose_level: integer</span>
<span class="sd"> :return: Job object</span>
<span class="sd"> :rtype: Job</span>
<span class="sd"> Upgrade containers to new version specified by the property</span>
<span class="sd"> &quot;openstack_release.&quot;</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">verbose_level</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Verbose level&#39;</span><span class="p">),</span> <span class="nb">int</span><span class="p">)</span>
<span class="n">ansible_job</span> <span class="o">=</span> <span class="n">actions</span><span class="o">.</span><span class="n">upgrade</span><span class="p">(</span><span class="n">verbose_level</span><span class="p">)</span>
<span class="k">return</span> <span class="n">Job</span><span class="p">(</span><span class="n">ansible_job</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="AsyncApi.async_host_destroy"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.async.AsyncApi.async_host_destroy">[docs]</a> <span class="k">def</span> <span class="nf">async_host_destroy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostnames</span><span class="p">,</span> <span class="n">destroy_type</span><span class="p">,</span> <span class="n">verbose_level</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="n">include_data</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Destroy Hosts.</span>
<span class="sd"> Stops and removes all kolla related docker containers on the</span>
<span class="sd"> specified hosts.</span>
<span class="sd"> :param hostnames: host names</span>
<span class="sd"> :type hostnames: list</span>
<span class="sd"> :param destroy_type: either &#39;kill&#39; or &#39;stop&#39;</span>
<span class="sd"> :type destroy_type: string</span>
<span class="sd"> :param verbose_level: the higher the number, the more verbose</span>
<span class="sd"> :type verbose_level: integer</span>
<span class="sd"> :param include_data: if true, destroy data containers too.</span>
<span class="sd"> :type include_data: boolean</span>
<span class="sd"> :return: Job object</span>
<span class="sd"> :rtype: Job</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">hostnames</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host names&#39;</span><span class="p">),</span> <span class="nb">list</span><span class="p">)</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">destroy_type</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Destroy type&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">)</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">verbose_level</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Verbose level&#39;</span><span class="p">),</span> <span class="nb">int</span><span class="p">)</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">include_data</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Include data&#39;</span><span class="p">),</span> <span class="nb">bool</span><span class="p">)</span>
<span class="k">if</span> <span class="n">destroy_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;stop&#39;</span><span class="p">,</span> <span class="s1">&#39;kill&#39;</span><span class="p">]:</span>
<span class="k">raise</span> <span class="n">InvalidArgument</span><span class="p">(</span>
<span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Invalid destroy type ({type}). Must be either &#39;</span>
<span class="s1">&#39;&quot;stop&quot; or &quot;kill&quot;.&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="nb">type</span><span class="o">=</span><span class="n">destroy_type</span><span class="p">))</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">hostnames</span><span class="p">)</span>
<span class="n">inventory</span> <span class="o">=</span> <span class="n">Inventory</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">validate_hostnames</span><span class="p">(</span><span class="n">hostnames</span><span class="p">)</span>
<span class="n">ansible_job</span> <span class="o">=</span> <span class="n">actions</span><span class="o">.</span><span class="n">destroy_hosts</span><span class="p">(</span><span class="n">hostnames</span><span class="p">,</span> <span class="n">destroy_type</span><span class="p">,</span>
<span class="n">verbose_level</span><span class="p">,</span> <span class="n">include_data</span><span class="p">)</span>
<span class="k">return</span> <span class="n">Job</span><span class="p">(</span><span class="n">ansible_job</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="AsyncApi.async_host_precheck"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.async.AsyncApi.async_host_precheck">[docs]</a> <span class="k">def</span> <span class="nf">async_host_precheck</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostnames</span><span class="p">,</span> <span class="n">verbose_level</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Check pre-deployment configuration of hosts.</span>
<span class="sd"> Check if host is ready for a new deployment. This will fail if</span>
<span class="sd"> any of the hosts are not configured correctly or if they have</span>
<span class="sd"> already been deployed to.</span>
<span class="sd"> :param hostnames: host names</span>
<span class="sd"> :type hostnames: list</span>
<span class="sd"> :param verbose_level: the higher the number, the more verbose</span>
<span class="sd"> :type verbose_level: integer</span>
<span class="sd"> :return: Job object</span>
<span class="sd"> :rtype: Job</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">hostnames</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host names&#39;</span><span class="p">),</span> <span class="nb">list</span><span class="p">)</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">verbose_level</span><span class="p">,</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Verbose level&#39;</span><span class="p">),</span> <span class="nb">int</span><span class="p">)</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">hostnames</span><span class="p">)</span>
<span class="n">inventory</span> <span class="o">=</span> <span class="n">Inventory</span><span class="o">.</span><span class="n">load</span><span class="p">()</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">validate_hostnames</span><span class="p">(</span><span class="n">hostnames</span><span class="p">)</span>
<span class="n">ansible_job</span> <span class="o">=</span> <span class="n">actions</span><span class="o">.</span><span class="n">precheck</span><span class="p">(</span><span class="n">hostnames</span><span class="p">,</span> <span class="n">verbose_level</span><span class="p">)</span>
<span class="k">return</span> <span class="n">Job</span><span class="p">(</span><span class="n">ansible_job</span><span class="p">)</span></div></div>
</pre></div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<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><a href="../../../index.html">kollacli 1.0.0.dev379 documentation</a> &raquo;</li>
<li><a href="../../index.html" >Module code</a> &raquo;</li>
</ul>
</div>
<div class="footer">
&copy; Copyright 2016, Oracle.
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3.
</div>
</body>
</html>