Remove the doc/build

when run `tox -e docs` in localhosts, Sphinx will genatrate doc/build,
it is not necessary for kolla-cli, should be removed from the project

Change-Id: I0a0a15c9dacb20c80f7b71eea3532f39ab9dc36b
This commit is contained in:
zhulingjie 2019-07-10 13:42:54 +08:00
parent 0695a17c58
commit a0d28608aa
71 changed files with 0 additions and 18120 deletions

View File

@ -1,125 +0,0 @@
<!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>Overview: module code &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 documentation" 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 4.0.1.dev498 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<h1>All modules for which code is available</h1>
<ul><li><a href="kollacli/api/client.html">kollacli.api.client</a></li>
<li><a href="kollacli/api/control_plane.html">kollacli.api.control_plane</a></li>
<li><a href="kollacli/api/exceptions.html">kollacli.api.exceptions</a></li>
<li><a href="kollacli/api/group.html">kollacli.api.group</a></li>
<li><a href="kollacli/api/host.html">kollacli.api.host</a></li>
<li><a href="kollacli/api/job.html">kollacli.api.job</a></li>
<li><a href="kollacli/api/password.html">kollacli.api.password</a></li>
<li><a href="kollacli/api/properties.html">kollacli.api.properties</a></li>
<li><a href="kollacli/api/service.html">kollacli.api.service</a></li>
<li><a href="kollacli/api/support.html">kollacli.api.support</a></li>
<li><a href="kollacli/commands/deploy.html">kollacli.commands.deploy</a></li>
<li><a href="kollacli/commands/exceptions.html">kollacli.commands.exceptions</a></li>
<li><a href="kollacli/commands/group.html">kollacli.commands.group</a></li>
<li><a href="kollacli/commands/host.html">kollacli.commands.host</a></li>
<li><a href="kollacli/commands/password.html">kollacli.commands.password</a></li>
<li><a href="kollacli/commands/property.html">kollacli.commands.property</a></li>
<li><a href="kollacli/commands/pull.html">kollacli.commands.pull</a></li>
<li><a href="kollacli/commands/reconfigure.html">kollacli.commands.reconfigure</a></li>
<li><a href="kollacli/commands/service.html">kollacli.commands.service</a></li>
<li><a href="kollacli/commands/support.html">kollacli.commands.support</a></li>
<li><a href="kollacli/commands/upgrade.html">kollacli.commands.upgrade</a></li>
<li><a href="kollacli/common/allinone.html">kollacli.common.allinone</a></li>
<li><a href="kollacli/common/ansible/actions.html">kollacli.common.ansible.actions</a></li>
<li><a href="kollacli/common/ansible/job.html">kollacli.common.ansible.job</a></li>
<li><a href="kollacli/common/ansible/playbook.html">kollacli.common.ansible.playbook</a></li>
<li><a href="kollacli/common/host.html">kollacli.common.host</a></li>
<li><a href="kollacli/common/host_group.html">kollacli.common.host_group</a></li>
<li><a href="kollacli/common/inventory.html">kollacli.common.inventory</a></li>
<li><a href="kollacli/common/passwords.html">kollacli.common.passwords</a></li>
<li><a href="kollacli/common/properties.html">kollacli.common.properties</a></li>
<li><a href="kollacli/common/service.html">kollacli.common.service</a></li>
<li><a href="kollacli/common/sshutils.html">kollacli.common.sshutils</a></li>
<li><a href="kollacli/common/subservice.html">kollacli.common.subservice</a></li>
<li><a href="kollacli/common/support.html">kollacli.common.support</a></li>
<li><a href="kollacli/common/utils.html">kollacli.common.utils</a></li>
<li><a href="kollacli/shell.html">kollacli.shell</a></li>
</ul>
</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 4.0.1.dev498 documentation</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>

View File

@ -1,271 +0,0 @@
<!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 4.0.0.dev483 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: '4.0.0.dev483',
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 4.0.0.dev483 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 4.0.0.dev483 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>
<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">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="n">servicenames</span><span class="o">=</span><span class="p">[]):</span>
<span class="c1"># type: (List[str], bool, int, List[str]) -&gt; Job</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 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"> :param servicenames: services to deploy. If empty, then deploy all.</span>
<span class="sd"> :type servicenames: list of strings</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">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">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">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">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">serial_flag</span><span class="p">,</span> <span class="n">verbose_level</span><span class="p">,</span> <span class="n">servicenames</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="n">servicenames</span><span class="o">=</span><span class="p">[]):</span>
<span class="c1"># type: (int, List[str]) -&gt; Job</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"> :param servicenames: services to upgrade. If empty, then upgrade all.</span>
<span class="sd"> :type servicenames: list of strings</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">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">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">upgrade</span><span class="p">(</span><span class="n">verbose_level</span><span class="p">,</span> <span class="n">servicenames</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="n">remove_images</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="c1"># type: (List[str], str, int, bool, bool) -&gt; Job</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"> :param remove_images: if true, destroy will remove the docker images</span>
<span class="sd"> :type remove_images: 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="n">check_arg</span><span class="p">(</span><span class="n">remove_images</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;Remove images&#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="n">remove_images</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="c1"># type: (List[str], int) -&gt; Job</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 class="viewcode-block" id="AsyncApi.async_host_stop"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.async.AsyncApi.async_host_stop">[docs]</a> <span class="k">def</span> <span class="nf">async_host_stop</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="c1"># type: (List[str], int) -&gt; Job</span>
<span class="sd">&quot;&quot;&quot;Stop Hosts.</span>
<span class="sd"> Stops all kolla related docker containers on the specified hosts.</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">stop_hosts</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 class="viewcode-block" id="AsyncApi.async_reconfigure"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.async.AsyncApi.async_reconfigure">[docs]</a> <span class="k">def</span> <span class="nf">async_reconfigure</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="c1"># type: (int) -&gt; Job</span>
<span class="sd">&quot;&quot;&quot;Reconfigure.</span>
<span class="sd"> Reconfigure containers on hosts.</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">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">reconfigure</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 4.0.0.dev483 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>

View File

@ -1,222 +0,0 @@
<!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.client &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.client</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright(c) 2017, 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">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">from</span> <span class="nn">logging.handlers</span> <span class="kn">import</span> <span class="n">RotatingFileHandler</span>
<span class="kn">from</span> <span class="nn">kollacli.api.control_plane</span> <span class="kn">import</span> <span class="n">ControlPlaneApi</span>
<span class="kn">from</span> <span class="nn">kollacli.api.group</span> <span class="kn">import</span> <span class="n">GroupApi</span>
<span class="kn">from</span> <span class="nn">kollacli.api.host</span> <span class="kn">import</span> <span class="n">HostApi</span>
<span class="kn">from</span> <span class="nn">kollacli.api.password</span> <span class="kn">import</span> <span class="n">PasswordApi</span>
<span class="kn">from</span> <span class="nn">kollacli.api.properties</span> <span class="kn">import</span> <span class="n">PropertyApi</span>
<span class="kn">from</span> <span class="nn">kollacli.api.service</span> <span class="kn">import</span> <span class="n">ServiceApi</span>
<span class="kn">from</span> <span class="nn">kollacli.api.support</span> <span class="kn">import</span> <span class="n">SupportApi</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_log_level</span>
<span class="n">CONSOLE_MESSAGE_FORMAT</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%(message)s</span><span class="s1">&#39;</span>
<span class="n">LOG_FILE_MESSAGE_FORMAT</span> <span class="o">=</span> \
<span class="s1">&#39;[</span><span class="si">%(asctime)s</span><span class="s1">] </span><span class="si">%(levelname)-8s</span><span class="s1"> </span><span class="si">%(name)s</span><span class="s1"> </span><span class="si">%(message)s</span><span class="s1">&#39;</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="bp">None</span>
<span class="n">VERSION</span> <span class="o">=</span> <span class="s1">&#39;2.0&#39;</span>
<div class="viewcode-block" id="ClientApi"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.client.ClientApi">[docs]</a><span class="k">class</span> <span class="nc">ClientApi</span><span class="p">(</span>
<span class="n">ControlPlaneApi</span><span class="p">,</span>
<span class="n">GroupApi</span><span class="p">,</span>
<span class="n">HostApi</span><span class="p">,</span>
<span class="n">PasswordApi</span><span class="p">,</span>
<span class="n">PropertyApi</span><span class="p">,</span>
<span class="n">ServiceApi</span><span class="p">,</span>
<span class="n">SupportApi</span><span class="p">,</span>
<span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Client API Notes</span>
<span class="sd"> Objects returned by the API contain a local copy of the information</span>
<span class="sd"> in the datastore. While changes made to the local copy will be</span>
<span class="sd"> reflected in the local object, changes made to the datastore</span>
<span class="sd"> from other objects will not be reflected in this local copy. The</span>
<span class="sd"> object will need to be re-fetched from the datastore to reflect</span>
<span class="sd"> the updates.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_configure_logging</span><span class="p">()</span>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="ClientApi.get_version"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.client.ClientApi.get_version">[docs]</a> <span class="k">def</span> <span class="nf">get_version</span><span class="p">():</span>
<span class="c1"># type: () -&gt; str</span>
<span class="k">return</span> <span class="n">VERSION</span>
</div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="ClientApi.base_call"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.client.ClientApi.base_call">[docs]</a> <span class="k">def</span> <span class="nf">base_call</span><span class="p">():</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;base call&#39;</span><span class="p">)</span>
</div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="ClientApi.enable_console_logging"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.client.ClientApi.enable_console_logging">[docs]</a> <span class="k">def</span> <span class="nf">enable_console_logging</span><span class="p">(</span><span class="n">level</span><span class="p">,</span> <span class="n">enable</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
<span class="c1"># type: (int, bool) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;enable/disable console logging for the api</span>
<span class="sd"> enable: True/False</span>
<span class="sd"> level: logging.INFO, logging.DEBUG, logging.WARNING,</span>
<span class="sd"> logging.CRITICAL...</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">root_logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">)</span>
<span class="n">console</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">StreamHandler</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="p">)</span>
<span class="k">if</span> <span class="n">enable</span><span class="p">:</span>
<span class="n">console</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">level</span><span class="p">)</span>
<span class="n">formatter</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">Formatter</span><span class="p">(</span><span class="n">CONSOLE_MESSAGE_FORMAT</span><span class="p">)</span>
<span class="n">console</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">formatter</span><span class="p">)</span>
<span class="n">root_logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">console</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">root_logger</span><span class="o">.</span><span class="n">removeHandler</span><span class="p">(</span><span class="n">console</span><span class="p">)</span>
</div>
<span class="k">def</span> <span class="nf">_configure_logging</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">global</span> <span class="n">LOG</span>
<span class="n">root_logger</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s1">&#39;&#39;</span><span class="p">)</span>
<span class="n">root_logger</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span><span class="p">)</span>
<span class="n">handler_found</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">handlers</span> <span class="o">=</span> <span class="n">root_logger</span><span class="o">.</span><span class="n">handlers</span>
<span class="k">for</span> <span class="n">handler</span> <span class="ow">in</span> <span class="n">handlers</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">handler</span><span class="p">,</span> <span class="n">RotatingFileHandler</span><span class="p">):</span>
<span class="n">handler_found</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">break</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">handler_found</span><span class="p">:</span>
<span class="c1"># logger has not been set up</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">rotate_handler</span> <span class="o">=</span> <span class="n">RotatingFileHandler</span><span class="p">(</span>
<span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">sep</span><span class="p">),</span>
<span class="s1">&#39;var&#39;</span><span class="p">,</span> <span class="s1">&#39;log&#39;</span><span class="p">,</span> <span class="s1">&#39;kolla&#39;</span><span class="p">,</span> <span class="s1">&#39;kolla.log&#39;</span><span class="p">),</span>
<span class="n">maxBytes</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_kolla_log_file_size</span><span class="p">(),</span>
<span class="n">backupCount</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">IOError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="c1"># most likely the caller is not part of the kolla group</span>
<span class="k">raise</span> <span class="ne">IOError</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;Permission denied to run the kolla client.&#39;</span>
<span class="s1">&#39;</span><span class="se">\n</span><span class="s1">Please add user to the kolla group and &#39;</span>
<span class="s1">&#39;then log out and back in. {error}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">error</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">)))</span>
<span class="n">formatter</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">Formatter</span><span class="p">(</span><span class="n">LOG_FILE_MESSAGE_FORMAT</span><span class="p">)</span>
<span class="n">rotate_handler</span><span class="o">.</span><span class="n">setFormatter</span><span class="p">(</span><span class="n">formatter</span><span class="p">)</span>
<span class="n">rotate_handler</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">get_log_level</span><span class="p">())</span>
<span class="n">root_logger</span><span class="o">.</span><span class="n">addHandler</span><span class="p">(</span><span class="n">rotate_handler</span><span class="p">)</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">_get_kolla_log_file_size</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; int</span>
<span class="n">envvar</span> <span class="o">=</span> <span class="s1">&#39;KOLLA_LOG_FILE_SIZE&#39;</span>
<span class="n">size_str</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">envvar</span><span class="p">,</span> <span class="s1">&#39;500000&#39;</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">size</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">size_str</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="n">size</span> <span class="o">=</span> <span class="mi">50000</span>
<span class="k">return</span> <span class="n">size</span></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 4.0.1.dev498 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>

View File

@ -1,135 +0,0 @@
<!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.deploy &mdash; kollacli 4.0.0.dev483 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: '4.0.0.dev483',
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 4.0.0.dev483 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 4.0.0.dev483 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.deploy</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">logging</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.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="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<div class="viewcode-block" id="DeployApi"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.deploy.DeployApi">[docs]</a><span class="k">class</span> <span class="nc">DeployApi</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="DeployApi.deploy_set_mode"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.deploy.DeployApi.deploy_set_mode">[docs]</a> <span class="k">def</span> <span class="nf">deploy_set_mode</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">remote_mode</span><span class="p">):</span>
<span class="c1"># type: (bool) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Set deploy mode.</span>
<span class="sd"> Set deploy mode to either local or remote. Local indicates</span>
<span class="sd"> that the openstack deployment will be to the local host.</span>
<span class="sd"> Remote means that the deployment is executed via ssh.</span>
<span class="sd"> NOTE: local mode is not supported and should never be used</span>
<span class="sd"> in production environments.</span>
<span class="sd"> :param remote_mode: if remote mode is True deployment is done via ssh</span>
<span class="sd"> :type remote_mode: bool</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">remote_mode</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;Remote mode&#39;</span><span class="p">),</span> <span class="nb">bool</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">set_deploy_mode</span><span class="p">(</span><span class="n">remote_mode</span><span class="p">)</span>
<span class="n">Inventory</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">inventory</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 4.0.0.dev483 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>

View File

@ -1,172 +0,0 @@
<!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.exceptions &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.exceptions</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="sd">&quot;&quot;&quot;Exception definitions.&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">kollacli.i18n</span> <span class="kn">as</span> <span class="nn">u</span>
<div class="viewcode-block" id="ClientException"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.exceptions.ClientException">[docs]</a><span class="k">class</span> <span class="nc">ClientException</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;KollaClient Base Class Exception&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">message</span><span class="p">:</span>
<span class="n">message</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;An unknown exception occurred.&#39;</span><span class="p">)</span>
<span class="nb">super</span><span class="p">(</span><span class="n">ClientException</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="NotInInventory"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.exceptions.NotInInventory">[docs]</a><span class="k">class</span> <span class="nc">NotInInventory</span><span class="p">(</span><span class="n">ClientException</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Not in inventory exception&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj_type</span><span class="p">,</span> <span class="n">obj_names</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">obj_names</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
<span class="c1"># list of names</span>
<span class="n">invalid_objs</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">comma</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">for</span> <span class="n">obj_name</span> <span class="ow">in</span> <span class="n">obj_names</span><span class="p">:</span>
<span class="n">invalid_objs</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">invalid_objs</span><span class="p">,</span> <span class="n">comma</span><span class="p">,</span> <span class="n">obj_name</span><span class="p">])</span>
<span class="n">comma</span> <span class="o">=</span> <span class="s1">&#39;,&#39;</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># single object name</span>
<span class="n">invalid_objs</span> <span class="o">=</span> <span class="n">obj_names</span>
<span class="n">message</span> <span class="o">=</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;{type} ({objs}) does not exist.&#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">obj_type</span><span class="p">,</span> <span class="n">objs</span><span class="o">=</span><span class="n">invalid_objs</span><span class="p">))</span>
<span class="nb">super</span><span class="p">(</span><span class="n">NotInInventory</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="HostError"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.exceptions.HostError">[docs]</a><span class="k">class</span> <span class="nc">HostError</span><span class="p">(</span><span class="n">ClientException</span><span class="p">):</span>
<span class="k">pass</span>
</div>
<div class="viewcode-block" id="HostsSshCheckError"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.exceptions.HostsSshCheckError">[docs]</a><span class="k">class</span> <span class="nc">HostsSshCheckError</span><span class="p">(</span><span class="n">ClientException</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Host failed its ssh check&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</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="o">*</span><span class="n">args</span><span class="p">):</span>
<span class="n">failed_hosts</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">comma</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">for</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="n">hostnames</span><span class="p">:</span>
<span class="n">failed_hosts</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">failed_hosts</span><span class="p">,</span> <span class="n">comma</span><span class="p">,</span> <span class="n">hostname</span><span class="p">])</span>
<span class="n">comma</span> <span class="o">=</span> <span class="s1">&#39;,&#39;</span>
<span class="n">message</span> <span class="o">=</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(s) ssh check failed: {hosts}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">hosts</span><span class="o">=</span><span class="n">failed_hosts</span><span class="p">))</span>
<span class="nb">super</span><span class="p">(</span><span class="n">HostsSshCheckError</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="InvalidArgument"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.exceptions.InvalidArgument">[docs]</a><span class="k">class</span> <span class="nc">InvalidArgument</span><span class="p">(</span><span class="n">ClientException</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Invalid argument&quot;&quot;&quot;</span>
<span class="k">pass</span>
</div>
<div class="viewcode-block" id="InvalidConfiguration"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.exceptions.InvalidConfiguration">[docs]</a><span class="k">class</span> <span class="nc">InvalidConfiguration</span><span class="p">(</span><span class="n">ClientException</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Invalid configuration&quot;&quot;&quot;</span>
<span class="k">pass</span>
</div>
<div class="viewcode-block" id="FailedOperation"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.exceptions.FailedOperation">[docs]</a><span class="k">class</span> <span class="nc">FailedOperation</span><span class="p">(</span><span class="n">ClientException</span><span class="p">):</span>
<span class="k">pass</span>
</div>
<div class="viewcode-block" id="MissingArgument"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.exceptions.MissingArgument">[docs]</a><span class="k">class</span> <span class="nc">MissingArgument</span><span class="p">(</span><span class="n">ClientException</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Missing argument&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">argname</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
<span class="n">message</span> <span class="o">=</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;Argument is missing: {name}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">argname</span><span class="p">))</span>
<span class="nb">super</span><span class="p">(</span><span class="n">MissingArgument</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span></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 4.0.1.dev498 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>

View File

@ -1,303 +0,0 @@
<!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.group &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.group</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">from</span> <span class="nn">copy</span> <span class="kn">import</span> <span class="n">copy</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.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="GroupApi"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.GroupApi">[docs]</a><span class="k">class</span> <span class="nc">GroupApi</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="GroupApi.group_add"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.GroupApi.group_add">[docs]</a> <span class="k">def</span> <span class="nf">group_add</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">groupnames</span><span class="p">):</span>
<span class="c1"># type: (List[str]) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Add groups to the inventory</span>
<span class="sd"> :param groupnames: names of the groups to add to the inventory</span>
<span class="sd"> :type groupnames: list of strings</span>
<span class="sd"> &quot;&quot;&quot;</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">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">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="k">for</span> <span class="n">groupname</span> <span class="ow">in</span> <span class="n">groupnames</span><span class="p">:</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">add_group</span><span class="p">(</span><span class="n">groupname</span><span class="p">)</span>
<span class="n">Inventory</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">inventory</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="GroupApi.group_remove"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.GroupApi.group_remove">[docs]</a> <span class="k">def</span> <span class="nf">group_remove</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">groupnames</span><span class="p">):</span>
<span class="c1"># type: (List[str]) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Remove groups from the inventory</span>
<span class="sd"> :param groupnames: names of the groups to remove from the inventory</span>
<span class="sd"> :type groupnames: list of strings</span>
<span class="sd"> &quot;&quot;&quot;</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">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">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="k">for</span> <span class="n">groupname</span> <span class="ow">in</span> <span class="n">groupnames</span><span class="p">:</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">remove_group</span><span class="p">(</span><span class="n">groupname</span><span class="p">)</span>
<span class="n">Inventory</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">inventory</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="GroupApi.group_get_all"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.GroupApi.group_get_all">[docs]</a> <span class="k">def</span> <span class="nf">group_get_all</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; List[Group]</span>
<span class="sd">&quot;&quot;&quot;Get all groups in the inventory</span>
<span class="sd"> :return: groups</span>
<span class="sd"> :rtype: list of Group objects</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_groups</span><span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="n">get_all</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="GroupApi.group_get"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.GroupApi.group_get">[docs]</a> <span class="k">def</span> <span class="nf">group_get</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">groupnames</span><span class="p">):</span>
<span class="c1"># type: (List[str]) -&gt; List[Group]</span>
<span class="sd">&quot;&quot;&quot;Get selected groups in the inventory</span>
<span class="sd"> :param groupnames: names of groups to be read</span>
<span class="sd"> :type groupnames: list of strings</span>
<span class="sd"> :return: groups</span>
<span class="sd"> :rtype: list of Group objects</span>
<span class="sd"> &quot;&quot;&quot;</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">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="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_groups</span><span class="p">(</span><span class="n">groupnames</span><span class="p">)</span>
</div>
<span class="k">def</span> <span class="nf">_get_groups</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">groupnames</span><span class="p">,</span> <span class="n">get_all</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="c1"># type: (List[str], bool) -&gt; List[Group]</span>
<span class="n">groups</span> <span class="o">=</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="k">if</span> <span class="n">get_all</span><span class="p">:</span>
<span class="n">groupnames</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_groupnames</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">validate_groupnames</span><span class="p">(</span><span class="n">groupnames</span><span class="p">)</span>
<span class="n">group_services</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_group_services</span><span class="p">()</span>
<span class="k">for</span> <span class="n">groupname</span> <span class="ow">in</span> <span class="n">groupnames</span><span class="p">:</span>
<span class="n">inv_group</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_group</span><span class="p">(</span><span class="n">groupname</span><span class="p">)</span>
<span class="n">group</span> <span class="o">=</span> <span class="n">Group</span><span class="p">(</span><span class="n">groupname</span><span class="p">,</span>
<span class="n">group_services</span><span class="p">[</span><span class="n">groupname</span><span class="p">],</span>
<span class="n">inv_group</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">())</span>
<span class="n">groups</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">group</span><span class="p">)</span>
<span class="k">return</span> <span class="n">groups</span>
</div>
<div class="viewcode-block" id="Group"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.Group">[docs]</a><span class="k">class</span> <span class="nc">Group</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">groupname</span><span class="p">,</span> <span class="n">servicenames</span><span class="p">,</span> <span class="n">hostnames</span><span class="p">):</span>
<span class="c1"># type: (str, List[str], List[str]) -&gt; None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">groupname</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_servicenames</span> <span class="o">=</span> <span class="n">servicenames</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_hostnames</span> <span class="o">=</span> <span class="n">hostnames</span>
<div class="viewcode-block" id="Group.get_name"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.Group.get_name">[docs]</a> <span class="k">def</span> <span class="nf">get_name</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; str</span>
<span class="sd">&quot;&quot;&quot;Get name</span>
<span class="sd"> :return: group name</span>
<span class="sd"> :rtype: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
</div>
<div class="viewcode-block" id="Group.get_services"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.Group.get_services">[docs]</a> <span class="k">def</span> <span class="nf">get_services</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; List[str]</span>
<span class="sd">&quot;&quot;&quot;Get names of services associated with this group.</span>
<span class="sd"> :return: service names</span>
<span class="sd"> :rtype: list of strings</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">copy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_servicenames</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Group.add_service"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.Group.add_service">[docs]</a> <span class="k">def</span> <span class="nf">add_service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">servicename</span><span class="p">):</span>
<span class="c1"># type: (str) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Add service to group</span>
<span class="sd"> :param servicename: name of the service to add to the group</span>
<span class="sd"> :type servicename: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">servicename</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 name&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">)</span>
<span class="n">servicename</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">servicename</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_servicenames</span><span class="p">([</span><span class="n">servicename</span><span class="p">],</span> <span class="n">client_filter</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">group_services</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_group_services</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_servicenames</span> <span class="o">=</span> <span class="n">group_services</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">]</span>
<span class="k">if</span> <span class="n">servicename</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_servicenames</span><span class="p">:</span>
<span class="c1"># service not associated with group, add it</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">add_group_to_service</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">servicename</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_servicenames</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="n">Inventory</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">inventory</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Group.remove_service"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.Group.remove_service">[docs]</a> <span class="k">def</span> <span class="nf">remove_service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">servicename</span><span class="p">):</span>
<span class="c1"># type: (str) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Remove service from group</span>
<span class="sd"> :param servicename: name of the service to remove from the group</span>
<span class="sd"> :type servicename: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">servicename</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 name&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">)</span>
<span class="n">servicename</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">servicename</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_servicenames</span><span class="p">([</span><span class="n">servicename</span><span class="p">],</span> <span class="n">client_filter</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">group_services</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_group_services</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_servicenames</span> <span class="o">=</span> <span class="n">group_services</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">]</span>
<span class="k">if</span> <span class="n">servicename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_servicenames</span><span class="p">:</span>
<span class="c1"># service is associated with group, remove it</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">remove_group_from_service</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">servicename</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_servicenames</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="n">Inventory</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">inventory</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Group.get_hosts"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.Group.get_hosts">[docs]</a> <span class="k">def</span> <span class="nf">get_hosts</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; List[str]</span>
<span class="sd">&quot;&quot;&quot;Get names of hosts associated with this group.</span>
<span class="sd"> :return: host names</span>
<span class="sd"> :rtype: list of strings</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">copy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_hostnames</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Group.add_host"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.Group.add_host">[docs]</a> <span class="k">def</span> <span class="nf">add_host</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostname</span><span class="p">):</span>
<span class="c1"># type: (str) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Add host to group</span>
<span class="sd"> :param hostname: name of the host to add to the group</span>
<span class="sd"> :type hostname: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">hostname</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 name&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">)</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">hostname</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">hostname</span><span class="p">])</span>
<span class="n">group</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_group</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_hostnames</span> <span class="o">=</span> <span class="n">group</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">()</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hostnames</span><span class="p">:</span>
<span class="c1"># host not associated with group, add it</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">add_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_hostnames</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="n">Inventory</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">inventory</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Group.remove_host"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.group.Group.remove_host">[docs]</a> <span class="k">def</span> <span class="nf">remove_host</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostname</span><span class="p">):</span>
<span class="c1"># type: (str) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Remove host from group</span>
<span class="sd"> :param hostname: name of the host to remove from the group</span>
<span class="sd"> :type hostname: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">hostname</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 name&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">)</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">hostname</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">hostname</span><span class="p">])</span>
<span class="n">group</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_group</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_hostnames</span> <span class="o">=</span> <span class="n">group</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">()</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hostnames</span><span class="p">:</span>
<span class="c1"># host is associated with group, remove it</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">remove_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_hostnames</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="n">Inventory</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">inventory</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 4.0.1.dev498 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>

View File

@ -1,354 +0,0 @@
<!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.host &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.host</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright(c) 2017, 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">from</span> <span class="nn">copy</span> <span class="kn">import</span> <span class="n">copy</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="HostApi"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.HostApi">[docs]</a><span class="k">class</span> <span class="nc">HostApi</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="HostApi.host_add"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.HostApi.host_add">[docs]</a> <span class="k">def</span> <span class="nf">host_add</span><span class="p">(</span><span class="n">hostnames</span><span class="p">):</span>
<span class="c1"># type: (List[str]) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Add hosts to the inventory</span>
<span class="sd"> :param hostnames: list of strings</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">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">any_changed</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">for</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="n">hostnames</span><span class="p">:</span>
<span class="n">changed</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">add_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">changed</span><span class="p">:</span>
<span class="n">any_changed</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">if</span> <span class="n">any_changed</span><span class="p">:</span>
<span class="n">Inventory</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">inventory</span><span class="p">)</span>
</div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="HostApi.host_remove"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.HostApi.host_remove">[docs]</a> <span class="k">def</span> <span class="nf">host_remove</span><span class="p">(</span><span class="n">hostnames</span><span class="p">):</span>
<span class="c1"># type: (List[str]) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Remove hosts from the inventory</span>
<span class="sd"> :param hostnames: list of strings</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">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">any_changed</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">for</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="n">hostnames</span><span class="p">:</span>
<span class="n">changed</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">remove_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">changed</span><span class="p">:</span>
<span class="n">any_changed</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">if</span> <span class="n">any_changed</span><span class="p">:</span>
<span class="n">Inventory</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">inventory</span><span class="p">)</span>
</div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="HostApi.host_get_all"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.HostApi.host_get_all">[docs]</a> <span class="k">def</span> <span class="nf">host_get_all</span><span class="p">():</span>
<span class="c1"># type: () -&gt; List[Host]</span>
<span class="sd">&quot;&quot;&quot;Get all hosts in the inventory</span>
<span class="sd"> :return: Hosts</span>
<span class="sd"> :rtype: list of Host objects</span>
<span class="sd"> &quot;&quot;&quot;</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">hosts</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">host_groups</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_host_groups</span><span class="p">()</span>
<span class="k">for</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">groupnames</span> <span class="ow">in</span> <span class="n">host_groups</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">hosts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Host</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">groupnames</span><span class="p">))</span>
<span class="k">return</span> <span class="n">hosts</span>
</div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="HostApi.host_get"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.HostApi.host_get">[docs]</a> <span class="k">def</span> <span class="nf">host_get</span><span class="p">(</span><span class="n">hostnames</span><span class="p">):</span>
<span class="c1"># type: (List[str]) -&gt; List[Host]</span>
<span class="sd">&quot;&quot;&quot;Get selected hosts in the inventory</span>
<span class="sd"> :param hostnames: list of strings</span>
<span class="sd"> :return: hosts</span>
<span class="sd"> :rtype: list of Host objects</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">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">hosts</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">host_groups</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_host_groups</span><span class="p">()</span>
<span class="k">for</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="n">hostnames</span><span class="p">:</span>
<span class="n">hosts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">Host</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">host_groups</span><span class="p">[</span><span class="n">hostname</span><span class="p">]))</span>
<span class="k">return</span> <span class="n">hosts</span>
</div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="HostApi.host_ssh_check"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.HostApi.host_ssh_check">[docs]</a> <span class="k">def</span> <span class="nf">host_ssh_check</span><span class="p">(</span><span class="n">hostnames</span><span class="p">):</span>
<span class="c1"># type: (List[str]) -&gt; Dict[str,Dict[str,object]]</span>
<span class="sd">&quot;&quot;&quot;Check hosts for ssh connectivity</span>
<span class="sd"> Check status is a dictionary of form:</span>
<span class="sd"> - {hostname: {</span>
<span class="sd"> &#39;success&#39;:&lt;True|False&gt;,</span>
<span class="sd"> &#39;msg&#39;:message_string},</span>
<span class="sd"> ...</span>
<span class="sd"> }</span>
<span class="sd"> :param hostnames: list of strings</span>
<span class="sd"> :return: check status</span>
<span class="sd"> :rtype: dictionary</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">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">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">validate_hostnames</span><span class="p">(</span><span class="n">hostnames</span><span class="p">)</span>
<span class="n">summary</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">ssh_check_hosts</span><span class="p">(</span><span class="n">hostnames</span><span class="p">)</span>
<span class="k">return</span> <span class="n">summary</span>
</div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="HostApi.host_setup"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.HostApi.host_setup">[docs]</a> <span class="k">def</span> <span class="nf">host_setup</span><span class="p">(</span><span class="n">hosts_info</span><span class="p">):</span>
<span class="c1"># type: (Dict[str,Dict[str,object]]) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Setup multiple hosts for ssh access</span>
<span class="sd"> hosts_info is a dictionary of form:</span>
<span class="sd"> - {hostname&#39;: {</span>
<span class="sd"> &#39;password&#39;: password</span>
<span class="sd"> &#39;uname&#39;: user_name},</span>
<span class="sd"> ...</span>
<span class="sd"> }</span>
<span class="sd"> The uname entry is optional.</span>
<span class="sd"> :param hosts_info: dictionary</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">hosts_info</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;Hosts info&#39;</span><span class="p">),</span> <span class="nb">dict</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">hosts_info</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">setup_hosts</span><span class="p">(</span><span class="n">hosts_info</span><span class="p">)</span>
</div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="HostApi.host_destroy"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.HostApi.host_destroy">[docs]</a> <span class="k">def</span> <span class="nf">host_destroy</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="n">remove_images</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="c1"># type: (List[str], str, int, bool, bool) -&gt; Job</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"> :param remove_images: if true, destroy will remove the docker images</span>
<span class="sd"> :type remove_images: 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="n">check_arg</span><span class="p">(</span><span class="n">remove_images</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;Remove images&#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="n">remove_images</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>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="HostApi.host_precheck"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.HostApi.host_precheck">[docs]</a> <span class="k">def</span> <span class="nf">host_precheck</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="c1"># type: (List[str], int) -&gt; Job</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>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="HostApi.host_stop"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.HostApi.host_stop">[docs]</a> <span class="k">def</span> <span class="nf">host_stop</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="c1"># type: (List[str], int) -&gt; Job</span>
<span class="sd">&quot;&quot;&quot;Stop Hosts.</span>
<span class="sd"> Stops all kolla related docker containers on the specified hosts.</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">stop_hosts</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>
<div class="viewcode-block" id="Host"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.Host">[docs]</a><span class="k">class</span> <span class="nc">Host</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Host&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">groupnames</span><span class="o">=</span><span class="p">[]):</span>
<span class="c1"># type: (str, List[str]) -&gt; None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">hostname</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_groupnames</span> <span class="o">=</span> <span class="n">groupnames</span>
<div class="viewcode-block" id="Host.get_name"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.Host.get_name">[docs]</a> <span class="k">def</span> <span class="nf">get_name</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; str</span>
<span class="sd">&quot;&quot;&quot;Get name</span>
<span class="sd"> :return: host name</span>
<span class="sd"> :rtype: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
</div>
<div class="viewcode-block" id="Host.get_groups"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.host.Host.get_groups">[docs]</a> <span class="k">def</span> <span class="nf">get_groups</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; List[str]</span>
<span class="sd">&quot;&quot;&quot;Get names of the groups associated with this host</span>
<span class="sd"> :return: group names</span>
<span class="sd"> :rtype: list of strings</span>
<span class="sd"> Note: If the groups associated with this host change after this</span>
<span class="sd"> host is fetched, the host must be re-fetched to reflect those</span>
<span class="sd"> changes.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">copy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_groupnames</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 4.0.1.dev498 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>

View File

@ -1,154 +0,0 @@
<!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.job &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.job</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>
<div class="viewcode-block" id="Job"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.job.Job">[docs]</a><span class="k">class</span> <span class="nc">Job</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Job&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ansible_job</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_ansible_job</span> <span class="o">=</span> <span class="n">ansible_job</span>
<div class="viewcode-block" id="Job.wait"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.job.Job.wait">[docs]</a> <span class="k">def</span> <span class="nf">wait</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; int</span>
<span class="sd">&quot;&quot;&quot;Wait for job to complete</span>
<span class="sd"> :return: 0 if job succeeded, 1 if job failed</span>
<span class="sd"> :rtype: int</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ansible_job</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="Job.get_status"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.job.Job.get_status">[docs]</a> <span class="k">def</span> <span class="nf">get_status</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; int</span>
<span class="sd">&quot;&quot;&quot;Get status of job</span>
<span class="sd"> :return: None: job is still running</span>
<span class="sd"> 0: job succeeded</span>
<span class="sd"> 1: job failed</span>
<span class="sd"> 2: job killed by user</span>
<span class="sd"> :rtype: int or None</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ansible_job</span><span class="o">.</span><span class="n">get_status</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="Job.get_error_message"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.job.Job.get_error_message">[docs]</a> <span class="k">def</span> <span class="nf">get_error_message</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; str</span>
<span class="sd">&quot;&quot;&quot;Get error message</span>
<span class="sd"> :return: if job failed, this will return the error message.</span>
<span class="sd"> :rtype: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ansible_job</span><span class="o">.</span><span class="n">get_error_message</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="Job.get_console_output"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.job.Job.get_console_output">[docs]</a> <span class="k">def</span> <span class="nf">get_console_output</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; str</span>
<span class="sd">&quot;&quot;&quot;Get the console output from the job</span>
<span class="sd"> :return: console output useful for debugging failed jobs.</span>
<span class="sd"> :rtype: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ansible_job</span><span class="o">.</span><span class="n">get_command_output</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="Job.kill"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.job.Job.kill">[docs]</a> <span class="k">def</span> <span class="nf">kill</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;kill the job&quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_ansible_job</span><span class="o">.</span><span class="n">kill</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 4.0.1.dev498 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>

View File

@ -1,174 +0,0 @@
<!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.password &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.password</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.common.passwords</span> <span class="kn">import</span> <span class="n">clear_password</span>
<span class="kn">from</span> <span class="nn">kollacli.common.passwords</span> <span class="kn">import</span> <span class="n">get_password_names</span>
<span class="kn">from</span> <span class="nn">kollacli.common.passwords</span> <span class="kn">import</span> <span class="n">init_passwords</span>
<span class="kn">from</span> <span class="nn">kollacli.common.passwords</span> <span class="kn">import</span> <span class="n">set_password</span>
<span class="kn">from</span> <span class="nn">kollacli.common.passwords</span> <span class="kn">import</span> <span class="n">set_password_sshkey</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">check_arg</span>
<div class="viewcode-block" id="PasswordApi"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.password.PasswordApi">[docs]</a><span class="k">class</span> <span class="nc">PasswordApi</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="PasswordApi.password_set"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.password.PasswordApi.password_set">[docs]</a> <span class="k">def</span> <span class="nf">password_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
<span class="c1"># type: (str, str) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Set password</span>
<span class="sd"> :param name: name of the password</span>
<span class="sd"> :type name: string</span>
<span class="sd"> :param value: value of the password</span>
<span class="sd"> :type value: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">name</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;Password name&#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">value</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;Password value&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">,</span> <span class="n">display_param</span><span class="o">=</span><span class="bp">False</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">set_password</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="PasswordApi.password_set_sshkey"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.password.PasswordApi.password_set_sshkey">[docs]</a> <span class="k">def</span> <span class="nf">password_set_sshkey</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">private_key</span><span class="p">,</span> <span class="n">public_key</span><span class="p">):</span>
<span class="c1"># type: (str, str, str) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Set password to an ssh key</span>
<span class="sd"> :param name: name of the password</span>
<span class="sd"> :type name: string</span>
<span class="sd"> :param private_key: ssh private key</span>
<span class="sd"> :type value: string</span>
<span class="sd"> :param public_key: ssh public key</span>
<span class="sd"> :type value: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">name</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;Password name&#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">private_key</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;Private key&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">,</span> <span class="n">display_param</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">public_key</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;Public key&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">,</span> <span class="n">display_param</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="n">set_password_sshkey</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">private_key</span><span class="p">,</span> <span class="n">public_key</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="PasswordApi.password_clear"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.password.PasswordApi.password_clear">[docs]</a> <span class="k">def</span> <span class="nf">password_clear</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>
<span class="c1"># type: (str) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Clear password</span>
<span class="sd"> :param name: name of the password</span>
<span class="sd"> :type name: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">name</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;Password name&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">)</span>
<span class="n">clear_password</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="PasswordApi.password_get_names"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.password.PasswordApi.password_get_names">[docs]</a> <span class="k">def</span> <span class="nf">password_get_names</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; List[str]</span>
<span class="sd">&quot;&quot;&quot;Get password names</span>
<span class="sd"> :return: password names</span>
<span class="sd"> :rtype: list of strings</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">get_password_names</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="PasswordApi.password_init"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.password.PasswordApi.password_init">[docs]</a> <span class="k">def</span> <span class="nf">password_init</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Init empty passwords</span>
<span class="sd"> Init empty passwords and ssh keys in /etc/kolla/passwords.yml</span>
<span class="sd"> to auto-generated values</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">init_passwords</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 4.0.1.dev498 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>

View File

@ -1,276 +0,0 @@
<!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.properties &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.properties</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">logging</span>
<span class="kn">import</span> <span class="nn">yaml</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.common.properties</span> <span class="kn">import</span> <span class="n">AnsibleProperties</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>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<span class="n">GLOBAL_TYPE</span> <span class="o">=</span> <span class="s1">&#39;global&#39;</span>
<span class="n">GROUP_TYPE</span> <span class="o">=</span> <span class="s1">&#39;group&#39;</span>
<span class="n">HOST_TYPE</span> <span class="o">=</span> <span class="s1">&#39;host&#39;</span>
<span class="n">PROP_TYPES</span> <span class="o">=</span> <span class="p">[</span><span class="n">GLOBAL_TYPE</span><span class="p">,</span> <span class="n">GROUP_TYPE</span><span class="p">,</span> <span class="n">HOST_TYPE</span><span class="p">]</span>
<div class="viewcode-block" id="PropertyApi"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.properties.PropertyApi">[docs]</a><span class="k">class</span> <span class="nc">PropertyApi</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="PropertyApi.property_set"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.properties.PropertyApi.property_set">[docs]</a> <span class="k">def</span> <span class="nf">property_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_dict</span><span class="p">,</span>
<span class="n">property_type</span><span class="o">=</span><span class="n">GLOBAL_TYPE</span><span class="p">,</span> <span class="n">change_set</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="c1"># type: (Dict[str,str], str, List[str]) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Set a property</span>
<span class="sd"> :param property_dict: property dictionary containing key / values</span>
<span class="sd"> :type property_dict: dictionary</span>
<span class="sd"> :param property_type: one of &#39;global&#39;, &#39;group&#39; or &#39;host&#39;</span>
<span class="sd"> :type property_type: string</span>
<span class="sd"> :param change_set: for group or host sets this is the list of groups</span>
<span class="sd"> or hosts to set the property for</span>
<span class="sd"> :type change_set: list of strings</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">ansible_properties</span> <span class="o">=</span> <span class="n">AnsibleProperties</span><span class="p">()</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">property_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">key</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;Property Key&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">)</span>
<span class="n">current_property</span> <span class="o">=</span> <span class="n">ansible_properties</span><span class="o">.</span><span class="n">get_property</span><span class="p">(</span><span class="n">key</span><span class="p">)</span>
<span class="k">if</span> <span class="n">current_property</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">current_property_type</span> <span class="o">=</span> <span class="n">current_property</span><span class="o">.</span><span class="n">value_type</span>
<span class="k">if</span> <span class="n">current_property_type</span> <span class="ow">is</span> <span class="ow">not</span> <span class="nb">str</span><span class="p">:</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_load</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="k">if</span> <span class="n">current_property</span><span class="o">.</span><span class="n">value</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">current_property_type</span> <span class="o">=</span> <span class="bp">None</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">value</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;Property Value&#39;</span><span class="p">),</span>
<span class="n">current_property_type</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">property_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">value</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;Property Value&#39;</span><span class="p">),</span> <span class="nb">str</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="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">str</span> <span class="ow">and</span> <span class="s1">&#39;&quot;&#39;</span> <span class="ow">in</span> <span class="n">value</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;Cannot use double quotes in &#39;</span>
<span class="s1">&#39;a property value.&#39;</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_check_type</span><span class="p">(</span><span class="n">property_type</span><span class="p">)</span>
<span class="k">if</span> <span class="n">property_type</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">GLOBAL_TYPE</span><span class="p">:</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">change_set</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;Change Set&#39;</span><span class="p">),</span> <span class="nb">list</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">change_set</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">change_set</span><span class="p">)</span>
<span class="k">if</span> <span class="n">property_type</span> <span class="o">==</span> <span class="n">GLOBAL_TYPE</span><span class="p">:</span>
<span class="n">ansible_properties</span><span class="o">.</span><span class="n">set_property</span><span class="p">(</span><span class="n">property_dict</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">property_type</span> <span class="o">==</span> <span class="n">GROUP_TYPE</span><span class="p">:</span>
<span class="n">ansible_properties</span><span class="o">.</span><span class="n">set_group_property</span><span class="p">(</span><span class="n">property_dict</span><span class="p">,</span> <span class="n">change_set</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">ansible_properties</span><span class="o">.</span><span class="n">set_host_property</span><span class="p">(</span><span class="n">property_dict</span><span class="p">,</span> <span class="n">change_set</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="PropertyApi.property_clear"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.properties.PropertyApi.property_clear">[docs]</a> <span class="k">def</span> <span class="nf">property_clear</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_list</span><span class="p">,</span> <span class="n">property_type</span><span class="o">=</span><span class="n">GLOBAL_TYPE</span><span class="p">,</span>
<span class="n">change_set</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="c1"># type: (List[str], str, List[str]) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;Clear a property</span>
<span class="sd"> :param property_list: property list</span>
<span class="sd"> :type property_list: list</span>
<span class="sd"> :param property_type: one of &#39;global&#39;, &#39;group&#39; or &#39;host&#39;</span>
<span class="sd"> :type property_type: string</span>
<span class="sd"> :param change_set: for group or host clears this is the list of</span>
<span class="sd"> groups or hosts to clear the property for</span>
<span class="sd"> :type change_set: list of strings</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">property_list</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;Property List&#39;</span><span class="p">),</span> <span class="nb">list</span><span class="p">)</span>
<span class="n">property_list</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">property_list</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_check_type</span><span class="p">(</span><span class="n">property_type</span><span class="p">)</span>
<span class="k">if</span> <span class="n">property_type</span> <span class="ow">is</span> <span class="ow">not</span> <span class="n">GLOBAL_TYPE</span><span class="p">:</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">change_set</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;Change Set&#39;</span><span class="p">),</span> <span class="nb">list</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">change_set</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">change_set</span><span class="p">)</span>
<span class="n">ansible_properties</span> <span class="o">=</span> <span class="n">AnsibleProperties</span><span class="p">()</span>
<span class="k">if</span> <span class="n">property_type</span> <span class="o">==</span> <span class="n">GLOBAL_TYPE</span><span class="p">:</span>
<span class="n">ansible_properties</span><span class="o">.</span><span class="n">clear_property</span><span class="p">(</span><span class="n">property_list</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">property_type</span> <span class="o">==</span> <span class="n">GROUP_TYPE</span><span class="p">:</span>
<span class="n">ansible_properties</span><span class="o">.</span><span class="n">clear_group_property</span><span class="p">(</span><span class="n">property_list</span><span class="p">,</span> <span class="n">change_set</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">ansible_properties</span><span class="o">.</span><span class="n">clear_host_property</span><span class="p">(</span><span class="n">property_list</span><span class="p">,</span> <span class="n">change_set</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="PropertyApi.property_get"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.properties.PropertyApi.property_get">[docs]</a> <span class="k">def</span> <span class="nf">property_get</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_type</span><span class="o">=</span><span class="n">GLOBAL_TYPE</span><span class="p">,</span> <span class="n">get_set</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="c1"># type: (str, List[str]) -&gt; List[Property]</span>
<span class="sd">&quot;&quot;&quot;Returns a list of Property objects</span>
<span class="sd"> :param property_type: one of &#39;global&#39;, &#39;group&#39;, or &#39;host&#39;</span>
<span class="sd"> :type property_type: string</span>
<span class="sd"> :param get_set: optional list of hosts or groups to be used when</span>
<span class="sd"> getting group or host related property lists</span>
<span class="sd"> :type get_set: list of strings</span>
<span class="sd"> :return: properties</span>
<span class="sd"> :rtype: list of Property objects</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_check_type</span><span class="p">(</span><span class="n">property_type</span><span class="p">)</span>
<span class="n">get_set</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">get_set</span><span class="p">)</span>
<span class="n">ansible_properties</span> <span class="o">=</span> <span class="n">AnsibleProperties</span><span class="p">()</span>
<span class="n">result_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">property_type</span> <span class="o">==</span> <span class="n">GLOBAL_TYPE</span><span class="p">:</span>
<span class="n">property_list</span> <span class="o">=</span> <span class="n">ansible_properties</span><span class="o">.</span><span class="n">get_all_unique</span><span class="p">()</span>
<span class="k">elif</span> <span class="n">property_type</span> <span class="o">==</span> <span class="n">GROUP_TYPE</span><span class="p">:</span>
<span class="n">property_list</span> <span class="o">=</span> <span class="n">ansible_properties</span><span class="o">.</span><span class="n">get_group_list</span><span class="p">(</span><span class="n">get_set</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">property_list</span> <span class="o">=</span> <span class="n">ansible_properties</span><span class="o">.</span><span class="n">get_host_list</span><span class="p">(</span><span class="n">get_set</span><span class="p">)</span>
<span class="n">override_flags</span> <span class="o">=</span> <span class="n">ansible_properties</span><span class="o">.</span><span class="n">get_all_override_flags</span><span class="p">()</span>
<span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">property_list</span><span class="p">:</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">Property</span><span class="p">(</span><span class="n">prop</span><span class="p">,</span> <span class="n">override_flags</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">prop</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">None</span><span class="p">))</span>
<span class="n">result_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
<span class="k">return</span> <span class="n">result_list</span>
</div>
<span class="k">def</span> <span class="nf">_check_type</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_type</span><span class="p">):</span>
<span class="k">if</span> <span class="n">property_type</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">or</span> <span class="n">property_type</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">PROP_TYPES</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;Property Type ({value} is not one of &#39;</span>
<span class="s1">&#39;global, group or host&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">value</span><span class="o">=</span><span class="n">property_type</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="Property"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.properties.Property">[docs]</a><span class="k">class</span> <span class="nc">Property</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Property</span>
<span class="sd"> Members:</span>
<span class="sd"> - name (str): key</span>
<span class="sd"> - value (Any): value</span>
<span class="sd"> - file_name (str): name of file property is from</span>
<span class="sd"> - overrides (bool): does the property override some other value</span>
<span class="sd"> - orig_value (str): the value which is overridden or None</span>
<span class="sd"> - target (str): group or host name for group or host properties</span>
<span class="sd"> - prop_type (str): one of &#39;global&#39;, &#39;group&#39; or &#39;host&#39;</span>
<span class="sd"> - ovr_global (bool): true if property is overridden at global level</span>
<span class="sd"> - ovr_group (bool): true if property is overridden at group level</span>
<span class="sd"> - ovr_host (bool): true if property is overridden at host level</span>
<span class="sd"> - value_type (type): the python type of the value</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ansible_property</span><span class="p">,</span> <span class="n">override_flags</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">ansible_property</span><span class="o">.</span><span class="n">name</span>
<span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">ansible_property</span><span class="o">.</span><span class="n">value</span>
<span class="bp">self</span><span class="o">.</span><span class="n">file_name</span> <span class="o">=</span> <span class="n">ansible_property</span><span class="o">.</span><span class="n">file_name</span>
<span class="bp">self</span><span class="o">.</span><span class="n">overrides</span> <span class="o">=</span> <span class="n">ansible_property</span><span class="o">.</span><span class="n">overrides</span>
<span class="bp">self</span><span class="o">.</span><span class="n">orig_value</span> <span class="o">=</span> <span class="n">ansible_property</span><span class="o">.</span><span class="n">orig_value</span>
<span class="bp">self</span><span class="o">.</span><span class="n">target</span> <span class="o">=</span> <span class="n">ansible_property</span><span class="o">.</span><span class="n">target</span>
<span class="bp">self</span><span class="o">.</span><span class="n">prop_type</span> <span class="o">=</span> <span class="n">ansible_property</span><span class="o">.</span><span class="n">prop_type</span>
<span class="bp">self</span><span class="o">.</span><span class="n">value_type</span> <span class="o">=</span> <span class="n">ansible_property</span><span class="o">.</span><span class="n">value_type</span>
<span class="k">if</span> <span class="n">override_flags</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">ovr_global</span> <span class="o">=</span> <span class="n">override_flags</span><span class="o">.</span><span class="n">ovr_global</span>
<span class="bp">self</span><span class="o">.</span><span class="n">ovr_group</span> <span class="o">=</span> <span class="n">override_flags</span><span class="o">.</span><span class="n">ovr_group</span>
<span class="bp">self</span><span class="o">.</span><span class="n">ovr_host</span> <span class="o">=</span> <span class="n">override_flags</span><span class="o">.</span><span class="n">ovr_host</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">ovr_global</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">ovr_group</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">ovr_host</span> <span class="o">=</span> <span class="bp">False</span></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 4.0.1.dev498 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>

View File

@ -1,231 +0,0 @@
<!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.service &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.service</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">from</span> <span class="nn">copy</span> <span class="kn">import</span> <span class="n">copy</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.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="ServiceApi"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.service.ServiceApi">[docs]</a><span class="k">class</span> <span class="nc">ServiceApi</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="ServiceApi.service_get_all"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.service.ServiceApi.service_get_all">[docs]</a> <span class="k">def</span> <span class="nf">service_get_all</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; List[Service]</span>
<span class="sd">&quot;&quot;&quot;Get all services in the inventory</span>
<span class="sd"> :return: services</span>
<span class="sd"> :rtype: List of Service objects</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_services</span><span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="n">get_all</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="ServiceApi.service_get"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.service.ServiceApi.service_get">[docs]</a> <span class="k">def</span> <span class="nf">service_get</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">servicenames</span><span class="p">):</span>
<span class="c1"># type: (List[str]) -&gt; List[Service]</span>
<span class="sd">&quot;&quot;&quot;Get selected services in the inventory</span>
<span class="sd"> :param servicenames: names of services to be read</span>
<span class="sd"> :type servicenames: list of strings</span>
<span class="sd"> :return: services</span>
<span class="sd"> :rtype: list of Service objects</span>
<span class="sd"> &quot;&quot;&quot;</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">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="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_services</span><span class="p">(</span><span class="n">servicenames</span><span class="p">)</span>
</div>
<span class="k">def</span> <span class="nf">_get_services</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">servicenames</span><span class="p">,</span> <span class="n">get_all</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="c1"># type: (List[str], bool) -&gt; List[Service]</span>
<span class="n">services</span> <span class="o">=</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="k">if</span> <span class="n">get_all</span><span class="p">:</span>
<span class="n">inv_services</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_services</span><span class="p">(</span><span class="n">client_filter</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="k">for</span> <span class="n">inv_service</span> <span class="ow">in</span> <span class="n">inv_services</span><span class="p">:</span>
<span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">(</span><span class="n">inv_service</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
<span class="n">inv_service</span><span class="o">.</span><span class="n">get_parentnames</span><span class="p">(),</span>
<span class="n">inv_service</span><span class="o">.</span><span class="n">get_childnames</span><span class="p">(),</span>
<span class="n">inv_service</span><span class="o">.</span><span class="n">get_groupnames</span><span class="p">())</span>
<span class="n">services</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">service</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">validate_servicenames</span><span class="p">(</span><span class="n">servicenames</span><span class="p">,</span> <span class="n">client_filter</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="k">for</span> <span class="n">servicename</span> <span class="ow">in</span> <span class="n">servicenames</span><span class="p">:</span>
<span class="n">inv_service</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_service</span><span class="p">(</span><span class="n">servicename</span><span class="p">,</span>
<span class="n">client_filter</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="k">if</span> <span class="n">inv_service</span><span class="p">:</span>
<span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">(</span><span class="n">inv_service</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
<span class="n">inv_service</span><span class="o">.</span><span class="n">get_parentnames</span><span class="p">(),</span>
<span class="n">inv_service</span><span class="o">.</span><span class="n">get_childnames</span><span class="p">(),</span>
<span class="n">inv_service</span><span class="o">.</span><span class="n">get_groupnames</span><span class="p">())</span>
<span class="n">services</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">service</span><span class="p">)</span>
<span class="k">return</span> <span class="n">services</span>
</div>
<div class="viewcode-block" id="Service"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.service.Service">[docs]</a><span class="k">class</span> <span class="nc">Service</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Service</span>
<span class="sd"> A service is one of the services available in openstack-kolla-ansible.</span>
<span class="sd"> For example, this would be how the murano services would be</span>
<span class="sd"> represented:</span>
<span class="sd"> - murano</span>
<span class="sd"> - parentnames: []</span>
<span class="sd"> - childnames: [murano-api, murano-engine]</span>
<span class="sd"> - murano-api</span>
<span class="sd"> - parentnames: [murano]</span>
<span class="sd"> - childnames: []</span>
<span class="sd"> - murano-engine</span>
<span class="sd"> - parentnames: [murano]</span>
<span class="sd"> - childnames: []</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">servicename</span><span class="p">,</span> <span class="n">parentnames</span><span class="o">=</span><span class="p">[],</span>
<span class="n">childnames</span><span class="o">=</span><span class="p">[],</span> <span class="n">groupnames</span><span class="o">=</span><span class="p">[]):</span>
<span class="c1"># type: (str, str, List[str], List[str]) -&gt; None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">servicename</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_parentnames</span> <span class="o">=</span> <span class="n">parentnames</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_childnames</span> <span class="o">=</span> <span class="n">childnames</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_groupnames</span> <span class="o">=</span> <span class="n">groupnames</span>
<div class="viewcode-block" id="Service.get_name"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.service.Service.get_name">[docs]</a> <span class="k">def</span> <span class="nf">get_name</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; str</span>
<span class="sd">&quot;&quot;&quot;Get name</span>
<span class="sd"> :return: service name</span>
<span class="sd"> :rtype: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
</div>
<div class="viewcode-block" id="Service.get_parents"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.service.Service.get_parents">[docs]</a> <span class="k">def</span> <span class="nf">get_parents</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; str</span>
<span class="sd">&quot;&quot;&quot;Get name of parent services</span>
<span class="sd"> :return: parent service names</span>
<span class="sd"> :rtype: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">copy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parentnames</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Service.get_children"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.service.Service.get_children">[docs]</a> <span class="k">def</span> <span class="nf">get_children</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; List[str]</span>
<span class="sd">&quot;&quot;&quot;Get names of the child services</span>
<span class="sd"> :return: child names</span>
<span class="sd"> :rtype: list of strings</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">copy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_childnames</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Service.get_groups"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.service.Service.get_groups">[docs]</a> <span class="k">def</span> <span class="nf">get_groups</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># type: () -&gt; List[str]</span>
<span class="sd">&quot;&quot;&quot;Get names of the groups</span>
<span class="sd"> :return: group names</span>
<span class="sd"> :rtype: list of strings</span>
<span class="sd"> Note: If the groups associated with this service change after this</span>
<span class="sd"> service is fetched, the service must be re-fetched to reflect those</span>
<span class="sd"> changes.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="n">copy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_groupnames</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 4.0.1.dev498 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>

View File

@ -1,167 +0,0 @@
<!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.support &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.support</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">import</span> <span class="nn">os</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.common.support</span> <span class="kn">import</span> <span class="n">dump</span>
<span class="kn">from</span> <span class="nn">kollacli.common.support</span> <span class="kn">import</span> <span class="n">get_logs</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="SupportApi"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.support.SupportApi">[docs]</a><span class="k">class</span> <span class="nc">SupportApi</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<div class="viewcode-block" id="SupportApi.support_dump"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.support.SupportApi.support_dump">[docs]</a> <span class="k">def</span> <span class="nf">support_dump</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dirpath</span><span class="p">):</span>
<span class="c1"># type: (str) -&gt; str</span>
<span class="sd">&quot;&quot;&quot;Dumps configuration data for debugging.</span>
<span class="sd"> Dumps most files in /etc/kolla and /usr/share/kolla into a</span>
<span class="sd"> tar file so be given to support / development to help with</span>
<span class="sd"> debugging problems.</span>
<span class="sd"> :param dirpath: path to directory where dump will be placed</span>
<span class="sd"> :type dirpath: string</span>
<span class="sd"> :return: path to dump file</span>
<span class="sd"> :rtype: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">dirpath</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;Directory path&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">)</span>
<span class="n">dirpath</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">dirpath</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">dirpath</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;Directory path: {path} does not exist&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">dirpath</span><span class="p">))</span>
<span class="n">dumpfile_path</span> <span class="o">=</span> <span class="n">dump</span><span class="p">(</span><span class="n">dirpath</span><span class="p">)</span>
<span class="k">return</span> <span class="n">dumpfile_path</span>
</div>
<div class="viewcode-block" id="SupportApi.support_get_logs"><a class="viewcode-back" href="../../../kollacli.api.html#kollacli.api.support.SupportApi.support_get_logs">[docs]</a> <span class="k">def</span> <span class="nf">support_get_logs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">servicenames</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">dirpath</span><span class="p">):</span>
<span class="c1"># type: (List[str], str, str) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;get container logs</span>
<span class="sd"> Fetch the container log files of services from the specified hosts.</span>
<span class="sd"> The log files will be placed in the named directory. All the containers</span>
<span class="sd"> for the host will be placed in a directory named hostname. The file</span>
<span class="sd"> names for each log will be servicename_id.log.</span>
<span class="sd"> :param servicenames: names of services (ie nova, glance, etc)</span>
<span class="sd"> :type servicenames: list of strings</span>
<span class="sd"> :param hostname: name of host to look for logs on</span>
<span class="sd"> :type hostname: string</span>
<span class="sd"> :param dirpath: path of directory where log files will be written</span>
<span class="sd"> :type dirpath: string</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">check_arg</span><span class="p">(</span><span class="n">dirpath</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;Directory path&#39;</span><span class="p">),</span> <span class="nb">str</span><span class="p">)</span>
<span class="n">dirpath</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">dirpath</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">dirpath</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;Directory path: {path} does not exist&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">dirpath</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">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">check_arg</span><span class="p">(</span><span class="n">hostname</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">str</span><span class="p">)</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="n">get_logs</span><span class="p">(</span><span class="n">servicenames</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">dirpath</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 4.0.1.dev498 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>

View File

@ -1,231 +0,0 @@
<!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.commands.deploy &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.commands.deploy</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">logging</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">traceback</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.client</span> <span class="kn">import</span> <span class="n">ClientApi</span>
<span class="kn">from</span> <span class="nn">kollacli.commands.exceptions</span> <span class="kn">import</span> <span class="n">CommandError</span>
<span class="kn">from</span> <span class="nn">cliff.command</span> <span class="kn">import</span> <span class="n">Command</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<span class="n">CLIENT</span> <span class="o">=</span> <span class="n">ClientApi</span><span class="p">()</span>
<div class="viewcode-block" id="Deploy"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.deploy.Deploy">[docs]</a><span class="k">class</span> <span class="nc">Deploy</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Deploy containers to hosts.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="Deploy.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.deploy.Deploy.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">Deploy</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--hosts&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;?&#39;</span><span class="p">,</span>
<span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;host_list&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Deployment host list&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--serial&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Deploy serially&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--timeout&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;timeout&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;timeout (in minutes)&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="Deploy.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.deploy.Deploy.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="n">hosts</span> <span class="o">=</span> <span class="bp">None</span>
<span class="n">serial_flag</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">verbose_level</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">app</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">verbose_level</span>
<span class="n">timeout_target</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hosts</span><span class="p">:</span>
<span class="n">host_list</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hosts</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">hosts</span> <span class="o">=</span> <span class="n">host_list</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">serial</span><span class="p">:</span>
<span class="n">serial_flag</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">timeout</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">timeout</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">parsed_args</span><span class="o">.</span><span class="n">timeout</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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;Timeout value is not a number.&#39;</span><span class="p">))</span>
<span class="n">timeout_target</span> <span class="o">=</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">+</span> <span class="p">(</span><span class="mi">60</span> <span class="o">*</span> <span class="n">timeout</span><span class="p">)</span>
<span class="c1"># if we are doing a targeted host deploy make sure we are doing it</span>
<span class="c1"># to only compute nodes</span>
<span class="k">if</span> <span class="n">hosts</span><span class="p">:</span>
<span class="n">invalid_host_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">compute_group</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">group_get</span><span class="p">([</span><span class="s1">&#39;compute&#39;</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">compute_hosts</span> <span class="o">=</span> <span class="n">compute_group</span><span class="o">.</span><span class="n">get_hosts</span><span class="p">()</span>
<span class="k">for</span> <span class="n">host</span> <span class="ow">in</span> <span class="n">hosts</span><span class="p">:</span>
<span class="k">if</span> <span class="n">host</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">compute_hosts</span><span class="p">:</span>
<span class="n">invalid_host_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">host</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">invalid_host_list</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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 hosts for host targeted deploy. &#39;</span>
<span class="s1">&#39;Hosts must be in the compute group only.&#39;</span>
<span class="s1">&#39;Invalid hosts: {hosts}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">hosts</span><span class="o">=</span><span class="n">invalid_host_list</span><span class="p">))</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">deploy</span><span class="p">(</span><span class="n">hosts</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="c1"># wait for job to complete</span>
<span class="n">status</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">while</span> <span class="n">status</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">if</span> <span class="n">timeout_target</span> <span class="ow">and</span> <span class="n">time</span><span class="o">.</span><span class="n">time</span><span class="p">()</span> <span class="o">&gt;</span> <span class="n">timeout_target</span><span class="p">:</span>
<span class="n">job</span><span class="o">.</span><span class="n">kill</span><span class="p">()</span>
<span class="k">raise</span> <span class="n">CommandError</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;Job timed out and was killed.&#39;</span><span class="p">))</span>
<span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">get_status</span><span class="p">()</span>
<span class="c1"># job is done</span>
<span class="k">if</span> <span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">2</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="mi">80</span> <span class="o">*</span> <span class="s1">&#39;=&#39;</span><span class="p">)</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</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;DEBUG command output:</span><span class="se">\n</span><span class="s1">{out}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">out</span><span class="o">=</span><span class="n">job</span><span class="o">.</span><span class="n">get_console_output</span><span class="p">()))</span>
<span class="k">if</span> <span class="n">status</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">if</span> <span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="c1"># log any ansible warnings</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">get_error_message</span><span class="p">()</span>
<span class="k">if</span> <span class="n">msg</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</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;Success&#39;</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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;Job failed:</span><span class="se">\n</span><span class="s1">{msg}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="o">=</span><span class="n">job</span><span class="o">.</span><span class="n">get_error_message</span><span class="p">()))</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="Setdeploy"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.deploy.Setdeploy">[docs]</a><span class="k">class</span> <span class="nc">Setdeploy</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Set deploy mode.</span>
<span class="sd"> Set deploy mode to either local or remote. Local indicates</span>
<span class="sd"> that the openstack deployment will be to the local host.</span>
<span class="sd"> Remote means that the deployment is on remote hosts.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<div class="viewcode-block" id="Setdeploy.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.deploy.Setdeploy.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">Setdeploy</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;mode&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;mode&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;mode=&lt;local, remote&gt;&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="Setdeploy.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.deploy.Setdeploy.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">mode</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">remote_flag</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">&#39;local&#39;</span><span class="p">:</span>
<span class="n">remote_flag</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</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;Please note that local mode is not supported &#39;</span>
<span class="s1">&#39;and should never be used in production &#39;</span>
<span class="s1">&#39;environments.&#39;</span><span class="p">))</span>
<span class="k">elif</span> <span class="n">mode</span> <span class="o">!=</span> <span class="s1">&#39;remote&#39;</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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 deploy mode. Mode must be &#39;</span>
<span class="s1">&#39;either &quot;local&quot; or &quot;remote&quot;.&#39;</span><span class="p">))</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">set_deploy_mode</span><span class="p">(</span><span class="n">remote_flag</span><span class="p">)</span>
<span class="k">except</span> <span class="n">CommandError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">e</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</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 4.0.1.dev498 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>

View File

@ -1,116 +0,0 @@
<!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.commands.exceptions &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.commands.exceptions</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="sd">&quot;&quot;&quot;Exception definitions.&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">kollacli.i18n</span> <span class="kn">as</span> <span class="nn">u</span>
<div class="viewcode-block" id="CommandError"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.exceptions.CommandError">[docs]</a><span class="k">class</span> <span class="nc">CommandError</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;CLI command error&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
<span class="n">prefix</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;ERROR: &#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">message</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">prefix</span><span class="p">):</span>
<span class="n">message</span> <span class="o">=</span> <span class="n">prefix</span> <span class="o">+</span> <span class="n">message</span>
<span class="nb">super</span><span class="p">(</span><span class="n">CommandError</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span></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 4.0.1.dev498 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>

View File

@ -1,296 +0,0 @@
<!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.commands.group &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.commands.group</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">traceback</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.client</span> <span class="kn">import</span> <span class="n">ClientApi</span>
<span class="kn">from</span> <span class="nn">kollacli.api.exceptions</span> <span class="kn">import</span> <span class="n">ClientException</span>
<span class="kn">from</span> <span class="nn">kollacli.commands.exceptions</span> <span class="kn">import</span> <span class="n">CommandError</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">convert_lists_to_string</span>
<span class="kn">from</span> <span class="nn">cliff.command</span> <span class="kn">import</span> <span class="n">Command</span>
<span class="kn">from</span> <span class="nn">cliff.lister</span> <span class="kn">import</span> <span class="n">Lister</span>
<span class="n">CLIENT</span> <span class="o">=</span> <span class="n">ClientApi</span><span class="p">()</span>
<div class="viewcode-block" id="GroupAdd"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupAdd">[docs]</a><span class="k">class</span> <span class="nc">GroupAdd</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Add group to openstack-kolla.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="GroupAdd.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupAdd.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">GroupAdd</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;groupname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;groupname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Group name&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="GroupAdd.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupAdd.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">groupname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groupname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">group_add</span><span class="p">([</span><span class="n">groupname</span><span class="p">])</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="GroupRemove"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupRemove">[docs]</a><span class="k">class</span> <span class="nc">GroupRemove</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Remove group from openstack-kolla.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="GroupRemove.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupRemove.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">GroupRemove</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;groupname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;groupname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Group name&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="GroupRemove.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupRemove.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">groupname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groupname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">group_remove</span><span class="p">([</span><span class="n">groupname</span><span class="p">])</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="GroupAddhost"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupAddhost">[docs]</a><span class="k">class</span> <span class="nc">GroupAddhost</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Add host to group.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="GroupAddhost.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupAddhost.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">GroupAddhost</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;groupname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;groupname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Group name&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;hostname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;hostname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host name&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="GroupAddhost.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupAddhost.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">groupname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groupname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">group</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">group_get</span><span class="p">([</span><span class="n">groupname</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">group</span><span class="o">.</span><span class="n">add_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="GroupRemovehost"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupRemovehost">[docs]</a><span class="k">class</span> <span class="nc">GroupRemovehost</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Remove host group from group.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="GroupRemovehost.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupRemovehost.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">GroupRemovehost</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;groupname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;groupname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Group name&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;hostname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;hostname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host name&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="GroupRemovehost.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupRemovehost.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">groupname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groupname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">group</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">group_get</span><span class="p">([</span><span class="n">groupname</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">group</span><span class="o">.</span><span class="n">remove_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="GroupListhosts"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupListhosts">[docs]</a><span class="k">class</span> <span class="nc">GroupListhosts</span><span class="p">(</span><span class="n">Lister</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;List all groups and their hosts.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="GroupListhosts.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupListhosts.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)]</span>
<span class="n">groups</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">group_get_all</span><span class="p">()</span>
<span class="k">if</span> <span class="n">groups</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="n">groups</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">group</span><span class="o">.</span><span class="n">get_name</span><span class="p">(),</span>
<span class="nb">sorted</span><span class="p">(</span><span class="n">group</span><span class="o">.</span><span class="n">get_hosts</span><span class="p">())))</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">convert_lists_to_string</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">)</span>
<span class="k">return</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&#39;</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;Hosts&#39;</span><span class="p">)),</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="GroupAddservice"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupAddservice">[docs]</a><span class="k">class</span> <span class="nc">GroupAddservice</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Add service to group.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="GroupAddservice.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupAddservice.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">GroupAddservice</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;groupname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;groupname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Group name&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;servicename&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;servicename&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Service name&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="GroupAddservice.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupAddservice.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">groupname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groupname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">servicename</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">servicename</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">group</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">group_get</span><span class="p">([</span><span class="n">groupname</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">group</span><span class="o">.</span><span class="n">add_service</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="GroupRemoveservice"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupRemoveservice">[docs]</a><span class="k">class</span> <span class="nc">GroupRemoveservice</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Remove service group from group.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="GroupRemoveservice.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupRemoveservice.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">GroupRemoveservice</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;groupname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;groupname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Group name&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;servicename&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;servicename&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Service name&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="GroupRemoveservice.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupRemoveservice.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">groupname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groupname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">servicename</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">servicename</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">group</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">group_get</span><span class="p">([</span><span class="n">groupname</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">group</span><span class="o">.</span><span class="n">remove_service</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="GroupListservices"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupListservices">[docs]</a><span class="k">class</span> <span class="nc">GroupListservices</span><span class="p">(</span><span class="n">Lister</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;List all groups and their services.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="GroupListservices.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.group.GroupListservices.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)]</span>
<span class="n">groups</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">group_get_all</span><span class="p">()</span>
<span class="k">if</span> <span class="n">groups</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="n">groups</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">group</span><span class="o">.</span><span class="n">get_name</span><span class="p">(),</span>
<span class="nb">sorted</span><span class="p">(</span><span class="n">group</span><span class="o">.</span><span class="n">get_services</span><span class="p">())))</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">convert_lists_to_string</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">)</span>
<span class="k">return</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&#39;</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;Services&#39;</span><span class="p">)),</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</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 4.0.1.dev498 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>

View File

@ -1,453 +0,0 @@
<!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.commands.host &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.commands.host</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">argparse</span>
<span class="kn">import</span> <span class="nn">getpass</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">traceback</span>
<span class="kn">import</span> <span class="nn">yaml</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.client</span> <span class="kn">import</span> <span class="n">ClientApi</span>
<span class="kn">from</span> <span class="nn">kollacli.api.exceptions</span> <span class="kn">import</span> <span class="n">ClientException</span>
<span class="kn">from</span> <span class="nn">kollacli.commands.exceptions</span> <span class="kn">import</span> <span class="n">CommandError</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">convert_lists_to_string</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_setup_user</span>
<span class="kn">from</span> <span class="nn">cliff.command</span> <span class="kn">import</span> <span class="n">Command</span>
<span class="kn">from</span> <span class="nn">cliff.lister</span> <span class="kn">import</span> <span class="n">Lister</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<span class="n">CLIENT</span> <span class="o">=</span> <span class="n">ClientApi</span><span class="p">()</span>
<div class="viewcode-block" id="HostAdd"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostAdd">[docs]</a><span class="k">class</span> <span class="nc">HostAdd</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Add host to openstack-kolla.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="HostAdd.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostAdd.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">HostAdd</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;hostname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;hostname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host name or ip address&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="HostAdd.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostAdd.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">host_add</span><span class="p">([</span><span class="n">hostname</span><span class="p">])</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="HostDestroy"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostDestroy">[docs]</a><span class="k">class</span> <span class="nc">HostDestroy</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Destroy all kolla containers on host(s).</span>
<span class="sd"> Stops and removes all kolla related docker containers on either the</span>
<span class="sd"> specified host or all hosts if the hostname all is used.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<div class="viewcode-block" id="HostDestroy.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostDestroy.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">HostDestroy</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;hostname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;hostname | all&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host name or ip address or &quot;all&quot;&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--stop&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Stop rather than kill&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--includedata&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Destroy data containers&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--removeimages&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Remove docker images&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="HostDestroy.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostDestroy.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="p">[</span><span class="n">hostname</span><span class="p">]</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span><span class="p">:</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="n">_get_all_hostnames</span><span class="p">()</span>
<span class="n">destroy_type</span> <span class="o">=</span> <span class="s1">&#39;kill&#39;</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">stop</span><span class="p">:</span>
<span class="n">destroy_type</span> <span class="o">=</span> <span class="s1">&#39;stop&#39;</span>
<span class="n">include_data</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">includedata</span><span class="p">:</span>
<span class="n">include_data</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">remove_images</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">removeimages</span><span class="p">:</span>
<span class="n">remove_images</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">include_data</span><span class="p">:</span>
<span class="n">question</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;This will delete all containers and data&#39;</span>
<span class="s1">&#39;, are you sure? (y/n)&#39;</span><span class="p">)</span>
<span class="n">answer</span> <span class="o">=</span> <span class="nb">raw_input</span><span class="p">(</span><span class="n">question</span><span class="p">)</span>
<span class="k">while</span> <span class="n">answer</span> <span class="o">!=</span> <span class="s1">&#39;y&#39;</span> <span class="ow">and</span> <span class="n">answer</span> <span class="o">!=</span> <span class="s1">&#39;n&#39;</span><span class="p">:</span>
<span class="n">answer</span> <span class="o">=</span> <span class="nb">raw_input</span><span class="p">(</span><span class="n">question</span><span class="p">)</span>
<span class="k">if</span> <span class="n">answer</span> <span class="ow">is</span> <span class="s1">&#39;n&#39;</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;Aborting destroy&#39;</span><span class="p">)</span>
<span class="k">return</span>
<span class="n">verbose_level</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">app</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">verbose_level</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">host_destroy</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="n">remove_images</span><span class="p">)</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span>
<span class="k">if</span> <span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">2</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="mi">80</span> <span class="o">*</span> <span class="s1">&#39;=&#39;</span><span class="p">)</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</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;DEBUG command output:</span><span class="se">\n</span><span class="s1">{out}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">out</span><span class="o">=</span><span class="n">job</span><span class="o">.</span><span class="n">get_console_output</span><span class="p">()))</span>
<span class="k">if</span> <span class="n">status</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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;Job failed:</span><span class="se">\n</span><span class="s1">{msg}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="o">=</span><span class="n">job</span><span class="o">.</span><span class="n">get_error_message</span><span class="p">()))</span>
<span class="k">elif</span> <span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="c1"># log any ansible warnings</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">get_error_message</span><span class="p">()</span>
<span class="k">if</span> <span class="n">msg</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="HostRemove"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostRemove">[docs]</a><span class="k">class</span> <span class="nc">HostRemove</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Remove host from openstack-kolla.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="HostRemove.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostRemove.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">HostRemove</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;hostname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;hostname | all&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host name or &quot;all&quot;&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="HostRemove.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostRemove.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="p">[</span><span class="n">hostname</span><span class="p">]</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span><span class="p">:</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="n">_get_all_hostnames</span><span class="p">()</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">host_remove</span><span class="p">(</span><span class="n">hostnames</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="HostList"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostList">[docs]</a><span class="k">class</span> <span class="nc">HostList</span><span class="p">(</span><span class="n">Lister</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;List hosts and their groups.</span>
<span class="sd"> If a hostname is provided, only list information about that host.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<div class="viewcode-block" id="HostList.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostList.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">HostList</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;hostname&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;?&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;[hostname]&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host name&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="HostList.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostList.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span><span class="p">:</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">hosts</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">hostname</span><span class="p">:</span>
<span class="n">hosts</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">host_get</span><span class="p">([</span><span class="n">hostname</span><span class="p">])</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">hosts</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">host_get_all</span><span class="p">()</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">hosts</span><span class="p">:</span>
<span class="k">for</span> <span class="n">host</span> <span class="ow">in</span> <span class="n">hosts</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">host</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">host</span><span class="o">.</span><span class="n">get_groups</span><span class="p">()))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">))</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">convert_lists_to_string</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">)</span>
<span class="k">return</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&#39;</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;Groups&#39;</span><span class="p">)),</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="HostCheck"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostCheck">[docs]</a><span class="k">class</span> <span class="nc">HostCheck</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Check configuration of host(s).&quot;&quot;&quot;</span>
<div class="viewcode-block" id="HostCheck.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostCheck.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">HostCheck</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;hostname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;hostname | all&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host name or &quot;all&quot;&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--predeploy&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Run pre-deploy host checks.&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="HostCheck.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostCheck.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="p">[</span><span class="n">hostname</span><span class="p">]</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span><span class="p">:</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="n">_get_all_hostnames</span><span class="p">()</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">predeploy</span><span class="p">:</span>
<span class="c1"># run pre-deploy checks</span>
<span class="n">verbose_level</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">app</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">verbose_level</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">host_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="n">status</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span>
<span class="k">if</span> <span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">2</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="mi">80</span> <span class="o">*</span> <span class="s1">&#39;=&#39;</span><span class="p">)</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</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;DEBUG command output:</span><span class="se">\n</span><span class="s1">{out}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">out</span><span class="o">=</span><span class="n">job</span><span class="o">.</span><span class="n">get_console_output</span><span class="p">()))</span>
<span class="k">if</span> <span class="n">status</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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;Job failed:</span><span class="se">\n</span><span class="s1">{msg}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="o">=</span><span class="n">job</span><span class="o">.</span><span class="n">get_error_message</span><span class="p">()))</span>
<span class="k">elif</span> <span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="c1"># log any ansible warnings</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">get_error_message</span><span class="p">()</span>
<span class="k">if</span> <span class="n">msg</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># just do an ssh check</span>
<span class="n">summary</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">host_ssh_check</span><span class="p">(</span><span class="n">hostnames</span><span class="p">)</span>
<span class="n">all_ok</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">for</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">info</span> <span class="ow">in</span> <span class="n">summary</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;success&#39;</span><span class="p">)</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">info</span><span class="p">[</span><span class="s1">&#39;success&#39;</span><span class="p">]:</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;failed- &#39;</span><span class="p">)</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">info</span><span class="p">[</span><span class="s1">&#39;msg&#39;</span><span class="p">]</span>
<span class="n">all_ok</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</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 {host}: {sts} {msg}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="n">hostname</span><span class="p">,</span> <span class="n">sts</span><span class="o">=</span><span class="n">status</span><span class="p">,</span> <span class="n">msg</span><span class="o">=</span><span class="n">msg</span><span class="p">))</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">all_ok</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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 check failed.&#39;</span><span class="p">))</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="HostSetup"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostSetup">[docs]</a><span class="k">class</span> <span class="nc">HostSetup</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Setup openstack-kollacli on host.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="HostSetup.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostSetup.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">HostSetup</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;hostname&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;?&#39;</span><span class="p">,</span>
<span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;hostname&gt;&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host name&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--insecure&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;?&#39;</span><span class="p">,</span> <span class="n">help</span><span class="o">=</span><span class="n">argparse</span><span class="o">.</span><span class="n">SUPPRESS</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--file&#39;</span><span class="p">,</span> <span class="s1">&#39;-f&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;?&#39;</span><span class="p">,</span>
<span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;hosts_info_file&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Absolute path to hosts info file &#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="HostSetup.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostSetup.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">file</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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 name or hosts info file path is required.&#39;</span><span class="p">))</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span> <span class="ow">and</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">file</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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 name and hosts info file path &#39;</span>
<span class="s1">&#39;cannot both be present.&#39;</span><span class="p">))</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">file</span><span class="p">:</span>
<span class="c1"># multi-host setup via xml file</span>
<span class="n">hosts_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_yml_data</span><span class="p">(</span><span class="n">parsed_args</span><span class="o">.</span><span class="n">file</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">host_setup</span><span class="p">(</span><span class="n">hosts_data</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># single host setup</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">summary</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">host_ssh_check</span><span class="p">([</span><span class="n">hostname</span><span class="p">])</span>
<span class="k">if</span> <span class="n">summary</span><span class="p">[</span><span class="n">hostname</span><span class="p">][</span><span class="s1">&#39;success&#39;</span><span class="p">]:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span>
<span class="n">u</span><span class="o">.</span><span class="n">_LI</span><span class="p">(</span><span class="s1">&#39;Skipping setup of host ({host}) as &#39;</span>
<span class="s1">&#39;ssh check is ok.&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="n">hostname</span><span class="p">))</span>
<span class="k">return</span> <span class="bp">True</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">insecure</span><span class="p">:</span>
<span class="n">password</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">insecure</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">password</span> <span class="o">=</span> <span class="n">getpass</span><span class="o">.</span><span class="n">getpass</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;{name} password for {host}: &#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">get_setup_user</span><span class="p">(),</span> <span class="n">host</span><span class="o">=</span><span class="n">hostname</span><span class="p">))</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">host_setup</span><span class="p">({</span><span class="n">hostname</span><span class="p">:</span> <span class="p">{</span><span class="s1">&#39;password&#39;</span><span class="p">:</span> <span class="n">password</span><span class="p">}})</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div>
<span class="k">def</span> <span class="nf">_get_yml_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">yml_path</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">yml_path</span><span class="p">):</span>
<span class="k">raise</span> <span class="n">CommandError</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;No file exists at {path}. An absolute file path is &#39;</span>
<span class="s1">&#39;required.&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">yml_path</span><span class="p">))</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">yml_path</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">hosts_file</span><span class="p">:</span>
<span class="n">file_data</span> <span class="o">=</span> <span class="n">hosts_file</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="n">hosts_info</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_load</span><span class="p">(</span><span class="n">file_data</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">hosts_info</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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;{path} is empty.&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">yml_path</span><span class="p">))</span>
<span class="k">return</span> <span class="n">hosts_info</span>
</div>
<div class="viewcode-block" id="HostStop"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostStop">[docs]</a><span class="k">class</span> <span class="nc">HostStop</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Stop all kolla containers on host(s).</span>
<span class="sd"> Stops all kolla related docker containers on either the</span>
<span class="sd"> specified host or all hosts if the hostname all is used.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<div class="viewcode-block" id="HostStop.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostStop.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">HostStop</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;hostname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;hostname | all&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host name or ip address or &quot;all&quot;&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="HostStop.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.host.HostStop.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hostname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="p">[</span><span class="n">hostname</span><span class="p">]</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="o">==</span> <span class="s1">&#39;all&#39;</span><span class="p">:</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="n">_get_all_hostnames</span><span class="p">()</span>
<span class="n">verbose_level</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">app</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">verbose_level</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">host_stop</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="n">status</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span>
<span class="k">if</span> <span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">2</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="mi">80</span> <span class="o">*</span> <span class="s1">&#39;=&#39;</span><span class="p">)</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</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;DEBUG command output:</span><span class="se">\n</span><span class="s1">{out}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">out</span><span class="o">=</span><span class="n">job</span><span class="o">.</span><span class="n">get_console_output</span><span class="p">()))</span>
<span class="k">if</span> <span class="n">status</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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;Job failed:</span><span class="se">\n</span><span class="s1">{msg}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="o">=</span><span class="n">job</span><span class="o">.</span><span class="n">get_error_message</span><span class="p">()))</span>
<span class="k">elif</span> <span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="c1"># log any ansible warnings</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">get_error_message</span><span class="p">()</span>
<span class="k">if</span> <span class="n">msg</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<span class="k">def</span> <span class="nf">_get_all_hostnames</span><span class="p">():</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">hosts</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">host_get_all</span><span class="p">()</span>
<span class="k">for</span> <span class="n">host</span> <span class="ow">in</span> <span class="n">hosts</span><span class="p">:</span>
<span class="n">hostnames</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">host</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="k">return</span> <span class="n">hostnames</span>
</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 4.0.1.dev498 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>

View File

@ -1,234 +0,0 @@
<!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.commands.password &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.commands.password</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">argparse</span>
<span class="kn">import</span> <span class="nn">getpass</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">traceback</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">cliff.command</span> <span class="kn">import</span> <span class="n">Command</span>
<span class="kn">from</span> <span class="nn">cliff.lister</span> <span class="kn">import</span> <span class="n">Lister</span>
<span class="kn">from</span> <span class="nn">kollacli.api.client</span> <span class="kn">import</span> <span class="n">ClientApi</span>
<span class="kn">from</span> <span class="nn">kollacli.commands.exceptions</span> <span class="kn">import</span> <span class="n">CommandError</span>
<span class="n">CLIENT</span> <span class="o">=</span> <span class="n">ClientApi</span><span class="p">()</span>
<div class="viewcode-block" id="PasswordSet"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordSet">[docs]</a><span class="k">class</span> <span class="nc">PasswordSet</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="s2">&quot;Password Set&quot;</span>
<div class="viewcode-block" id="PasswordSet.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordSet.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">PasswordSet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;passwordname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;passwordname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Password name&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--insecure&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;?&#39;</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">argparse</span><span class="o">.</span><span class="n">SUPPRESS</span><span class="p">)</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="PasswordSet.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordSet.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">password_name</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">passwordname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">insecure</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">False</span><span class="p">:</span>
<span class="c1"># --insecure flag is present</span>
<span class="n">password</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span> <span class="c1"># nosec</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">insecure</span><span class="p">:</span>
<span class="n">password</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">insecure</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">password</span> <span class="o">=</span> <span class="n">getpass</span><span class="o">.</span><span class="n">getpass</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;Password: &#39;</span><span class="p">))</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">passtwo</span> <span class="o">=</span> <span class="n">getpass</span><span class="o">.</span><span class="n">getpass</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;Retype Password: &#39;</span><span class="p">))</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="k">if</span> <span class="n">password</span> <span class="o">!=</span> <span class="n">passtwo</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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;Passwords do not match&#39;</span><span class="p">))</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">password_set</span><span class="p">(</span><span class="n">password_name</span><span class="p">,</span> <span class="n">password</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="PasswordSetKey"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordSetKey">[docs]</a><span class="k">class</span> <span class="nc">PasswordSetKey</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="s2">&quot;Password Set SSH Key&quot;</span>
<div class="viewcode-block" id="PasswordSetKey.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordSetKey.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">PasswordSetKey</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;passwordname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;passwordname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Password name&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;privatekeypath&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;privatekeypath&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Path to private key file&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;publickeypath&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;publickeypath&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Path to public key file&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="PasswordSetKey.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordSetKey.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">password_name</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">passwordname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">private_keypath</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">privatekeypath</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">private_keypath</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">private_keypath</span><span class="p">)</span>
<span class="n">public_keypath</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">publickeypath</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">public_keypath</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="n">public_keypath</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">private_keypath</span><span class="p">):</span>
<span class="k">raise</span><span class="p">(</span><span class="n">CommandError</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;Private key file not found: {path}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">private_keypath</span><span class="p">)))</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">public_keypath</span><span class="p">):</span>
<span class="k">raise</span><span class="p">(</span><span class="n">CommandError</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;Public key file not found: {path}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">public_keypath</span><span class="p">)))</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">private_keypath</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="n">private_key</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">public_keypath</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="n">public_key</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">password_set_sshkey</span><span class="p">(</span><span class="n">password_name</span><span class="p">,</span> <span class="n">private_key</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span>
<span class="n">public_key</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="PasswordClear"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordClear">[docs]</a><span class="k">class</span> <span class="nc">PasswordClear</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="s2">&quot;Password Clear&quot;</span>
<div class="viewcode-block" id="PasswordClear.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordClear.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">PasswordClear</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;passwordname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;passwordname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Password name&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="PasswordClear.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordClear.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">password_name</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">passwordname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">password_clear</span><span class="p">(</span><span class="n">password_name</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="PasswordList"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordList">[docs]</a><span class="k">class</span> <span class="nc">PasswordList</span><span class="p">(</span><span class="n">Lister</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;List all password names.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="PasswordList.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordList.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">password_names</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">password_get_names</span><span class="p">()</span>
<span class="n">password_names</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">password_names</span><span class="p">)</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">password_name</span> <span class="ow">in</span> <span class="n">password_names</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">password_name</span><span class="p">,</span> <span class="s1">&#39;-&#39;</span><span class="p">))</span>
<span class="k">return</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;Password Name&#39;</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;Password&#39;</span><span class="p">)),</span> <span class="n">data</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="PasswordInit"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordInit">[docs]</a><span class="k">class</span> <span class="nc">PasswordInit</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Init all empty passwords and ssh keys.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="PasswordInit.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.password.PasswordInit.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">password_init</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</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 4.0.1.dev498 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>

View File

@ -1,358 +0,0 @@
<!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.commands.property &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.commands.property</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">traceback</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.client</span> <span class="kn">import</span> <span class="n">ClientApi</span>
<span class="kn">from</span> <span class="nn">kollacli.commands.exceptions</span> <span class="kn">import</span> <span class="n">CommandError</span>
<span class="kn">from</span> <span class="nn">kollacli.common</span> <span class="kn">import</span> <span class="n">utils</span>
<span class="kn">from</span> <span class="nn">cliff.command</span> <span class="kn">import</span> <span class="n">Command</span>
<span class="kn">from</span> <span class="nn">cliff.lister</span> <span class="kn">import</span> <span class="n">Lister</span>
<span class="n">CLIENT</span> <span class="o">=</span> <span class="n">ClientApi</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">_get_names</span><span class="p">(</span><span class="n">args_list</span><span class="p">):</span>
<span class="n">csv_list</span> <span class="o">=</span> <span class="n">args_list</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">names</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">convert_to_unicode</span><span class="p">(</span><span class="n">csv_list</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="s1">&#39;all&#39;</span> <span class="ow">in</span> <span class="n">names</span><span class="p">:</span>
<span class="n">names</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">return</span> <span class="n">names</span>
<div class="viewcode-block" id="PropertySet"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.property.PropertySet">[docs]</a><span class="k">class</span> <span class="nc">PropertySet</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="s2">&quot;Property Set&quot;</span>
<div class="viewcode-block" id="PropertySet.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.property.PropertySet.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">PropertySet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;propertyname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;propertyname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Property name&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;propertyvalue&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;propertyvalue&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Property value&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--hosts&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;host_list&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Property host list&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--groups&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;group_list&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Property group list&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="PropertySet.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.property.PropertySet.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">property_name</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">propertyname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">property_value</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">propertyvalue</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">property_dict</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">property_dict</span><span class="p">[</span><span class="n">property_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">property_value</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hosts</span><span class="p">:</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groups</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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 to use both hosts and groups arguments &#39;</span>
<span class="s1">&#39;together.&#39;</span><span class="p">))</span>
<span class="n">host_names</span> <span class="o">=</span> <span class="n">_get_names</span><span class="p">(</span><span class="n">parsed_args</span><span class="o">.</span><span class="n">hosts</span><span class="p">)</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">property_set</span><span class="p">(</span><span class="n">property_dict</span><span class="p">,</span>
<span class="s1">&#39;host&#39;</span><span class="p">,</span> <span class="n">host_names</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groups</span><span class="p">:</span>
<span class="n">group_names</span> <span class="o">=</span> <span class="n">_get_names</span><span class="p">(</span><span class="n">parsed_args</span><span class="o">.</span><span class="n">groups</span><span class="p">)</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">property_set</span><span class="p">(</span><span class="n">property_dict</span><span class="p">,</span>
<span class="s1">&#39;group&#39;</span><span class="p">,</span> <span class="n">group_names</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">property_set</span><span class="p">(</span><span class="n">property_dict</span><span class="p">,</span>
<span class="s1">&#39;global&#39;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="PropertyClear"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.property.PropertyClear">[docs]</a><span class="k">class</span> <span class="nc">PropertyClear</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="s2">&quot;Property Clear&quot;</span>
<div class="viewcode-block" id="PropertyClear.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.property.PropertyClear.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">PropertyClear</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;propertyname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;propertyname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Property name&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--hosts&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;host_list&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Property host list&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--groups&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;group_list&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Property group list&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="PropertyClear.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.property.PropertyClear.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">property_name</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">propertyname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">property_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">property_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">property_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hosts</span><span class="p">:</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groups</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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 to use both hosts and groups arguments &#39;</span>
<span class="s1">&#39;together.&#39;</span><span class="p">))</span>
<span class="n">host_names</span> <span class="o">=</span> <span class="n">_get_names</span><span class="p">(</span><span class="n">parsed_args</span><span class="o">.</span><span class="n">hosts</span><span class="p">)</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">property_clear</span><span class="p">(</span><span class="n">property_list</span><span class="p">,</span> <span class="s1">&#39;host&#39;</span><span class="p">,</span>
<span class="n">host_names</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groups</span><span class="p">:</span>
<span class="n">group_names</span> <span class="o">=</span> <span class="n">_get_names</span><span class="p">(</span><span class="n">parsed_args</span><span class="o">.</span><span class="n">groups</span><span class="p">)</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">property_clear</span><span class="p">(</span><span class="n">property_list</span><span class="p">,</span> <span class="s1">&#39;group&#39;</span><span class="p">,</span>
<span class="n">group_names</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">CLIENT</span><span class="o">.</span><span class="n">property_clear</span><span class="p">(</span><span class="n">property_list</span><span class="p">,</span> <span class="s1">&#39;global&#39;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="PropertyList"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.property.PropertyList">[docs]</a><span class="k">class</span> <span class="nc">PropertyList</span><span class="p">(</span><span class="n">Lister</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;List all properties.&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">app</span><span class="p">,</span> <span class="n">app_args</span><span class="p">,</span> <span class="n">cmd_name</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="nb">super</span><span class="p">(</span><span class="n">Lister</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">app</span><span class="p">,</span> <span class="n">app_args</span><span class="p">,</span>
<span class="n">cmd_name</span><span class="o">=</span><span class="n">cmd_name</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">is_global</span> <span class="o">=</span> <span class="bp">True</span>
<span class="bp">self</span><span class="o">.</span><span class="n">is_all_flag</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">is_long_flag</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">list_type</span> <span class="o">=</span> <span class="bp">None</span>
<div class="viewcode-block" id="PropertyList.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.property.PropertyList.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">PropertyList</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--all&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;List all properties&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--long&#39;</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s1">&#39;store_true&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Show all property attributes&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--hosts&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;host_list&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Property host list&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--groups&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
<span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;group_list&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Property group list&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="PropertyList.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.property.PropertyList.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">all</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">is_all_flag</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">long</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">is_long_flag</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">hosts</span><span class="p">:</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groups</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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 to use both hosts and groups arguments &#39;</span>
<span class="s1">&#39;together.&#39;</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">is_global</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">list_type</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Host&#39;</span><span class="p">)</span>
<span class="n">host_names</span> <span class="o">=</span> <span class="n">_get_names</span><span class="p">(</span><span class="n">parsed_args</span><span class="o">.</span><span class="n">hosts</span><span class="p">)</span>
<span class="n">property_list</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">property_get</span><span class="p">(</span><span class="s1">&#39;host&#39;</span><span class="p">,</span>
<span class="n">host_names</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groups</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">is_global</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">list_type</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Group&#39;</span><span class="p">)</span>
<span class="n">group_names</span> <span class="o">=</span> <span class="n">_get_names</span><span class="p">(</span><span class="n">parsed_args</span><span class="o">.</span><span class="n">groups</span><span class="p">)</span>
<span class="n">property_list</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">property_get</span><span class="p">(</span><span class="s1">&#39;group&#39;</span><span class="p">,</span>
<span class="n">group_names</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">property_list</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">property_get</span><span class="p">(</span><span class="s1">&#39;global&#39;</span><span class="p">)</span>
<span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_list_data</span><span class="p">(</span><span class="n">property_list</span><span class="p">)</span>
<span class="n">header</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_list_header</span><span class="p">()</span>
<span class="k">return</span> <span class="p">(</span><span class="n">header</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div>
<span class="k">def</span> <span class="nf">_get_list_header</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">header</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_long_flag</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_global</span><span class="p">:</span>
<span class="n">header</span> <span class="o">=</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;OVR&#39;</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;Property Name&#39;</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;Property Value&#39;</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;Original Value&#39;</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">header</span> <span class="o">=</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;OVR&#39;</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;Property Name&#39;</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;Property Value&#39;</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;Original Value&#39;</span><span class="p">),</span>
<span class="bp">self</span><span class="o">.</span><span class="n">list_type</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_global</span><span class="p">:</span>
<span class="n">header</span> <span class="o">=</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;OVR&#39;</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;Property Name&#39;</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;Property Value&#39;</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">header</span> <span class="o">=</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;OVR&#39;</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;Property Name&#39;</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;Property Value&#39;</span><span class="p">),</span>
<span class="bp">self</span><span class="o">.</span><span class="n">list_type</span><span class="p">)</span>
<span class="k">return</span> <span class="n">header</span>
<span class="k">def</span> <span class="nf">_get_list_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_list</span><span class="p">):</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">property_list</span><span class="p">:</span>
<span class="n">property_length</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_property_list_length</span><span class="p">()</span>
<span class="k">for</span> <span class="n">prop</span> <span class="ow">in</span> <span class="n">property_list</span><span class="p">:</span>
<span class="n">include_prop</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">if</span> <span class="p">(</span><span class="n">prop</span><span class="o">.</span><span class="n">value</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span>
<span class="nb">len</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">prop</span><span class="o">.</span><span class="n">value</span><span class="p">))</span> <span class="o">&gt;</span> <span class="n">property_length</span><span class="p">):</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_all_flag</span><span class="p">:</span>
<span class="n">include_prop</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">include_prop</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">include_prop</span><span class="p">:</span>
<span class="k">continue</span>
<span class="n">ovr_global</span> <span class="o">=</span> <span class="s1">&#39;-&#39;</span>
<span class="n">ovr_group</span> <span class="o">=</span> <span class="s1">&#39;-&#39;</span>
<span class="n">ovr_host</span> <span class="o">=</span> <span class="s1">&#39;-&#39;</span>
<span class="k">if</span> <span class="n">prop</span><span class="o">.</span><span class="n">ovr_global</span><span class="p">:</span>
<span class="n">ovr_global</span> <span class="o">=</span> <span class="s1">&#39;*&#39;</span>
<span class="k">if</span> <span class="n">prop</span><span class="o">.</span><span class="n">ovr_group</span><span class="p">:</span>
<span class="n">ovr_group</span> <span class="o">=</span> <span class="s1">&#39;G&#39;</span>
<span class="k">if</span> <span class="n">prop</span><span class="o">.</span><span class="n">ovr_host</span><span class="p">:</span>
<span class="n">ovr_host</span> <span class="o">=</span> <span class="s1">&#39;H&#39;</span>
<span class="n">prop_ovr</span> <span class="o">=</span> <span class="n">ovr_global</span> <span class="o">+</span> <span class="n">ovr_group</span> <span class="o">+</span> <span class="n">ovr_host</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_long_flag</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_global</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">prop_ovr</span><span class="p">,</span> <span class="n">prop</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">prop</span><span class="o">.</span><span class="n">value</span><span class="p">,</span>
<span class="n">prop</span><span class="o">.</span><span class="n">orig_value</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">prop_ovr</span><span class="p">,</span> <span class="n">prop</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">prop</span><span class="o">.</span><span class="n">value</span><span class="p">,</span>
<span class="n">prop</span><span class="o">.</span><span class="n">orig_value</span><span class="p">,</span> <span class="n">prop</span><span class="o">.</span><span class="n">target</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_global</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">prop_ovr</span><span class="p">,</span> <span class="n">prop</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">prop</span><span class="o">.</span><span class="n">value</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">prop_ovr</span><span class="p">,</span> <span class="n">prop</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">prop</span><span class="o">.</span><span class="n">value</span><span class="p">,</span>
<span class="n">prop</span><span class="o">.</span><span class="n">target</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_long_flag</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_global</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_global</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">data</span></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 4.0.1.dev498 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>

View File

@ -1,214 +0,0 @@
<!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.commands.service &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.commands.service</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">traceback</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.client</span> <span class="kn">import</span> <span class="n">ClientApi</span>
<span class="kn">from</span> <span class="nn">kollacli.api.exceptions</span> <span class="kn">import</span> <span class="n">ClientException</span>
<span class="kn">from</span> <span class="nn">kollacli.commands.exceptions</span> <span class="kn">import</span> <span class="n">CommandError</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">convert_lists_to_string</span>
<span class="kn">from</span> <span class="nn">cliff.command</span> <span class="kn">import</span> <span class="n">Command</span>
<span class="kn">from</span> <span class="nn">cliff.lister</span> <span class="kn">import</span> <span class="n">Lister</span>
<span class="n">CLIENT</span> <span class="o">=</span> <span class="n">ClientApi</span><span class="p">()</span>
<div class="viewcode-block" id="ServiceAddGroup"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.service.ServiceAddGroup">[docs]</a><span class="k">class</span> <span class="nc">ServiceAddGroup</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Add group to service.</span>
<span class="sd"> Associated the service to a group. If this is a sub-service,</span>
<span class="sd"> the inherit flag will be cleared.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<div class="viewcode-block" id="ServiceAddGroup.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.service.ServiceAddGroup.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">ServiceAddGroup</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;servicename&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;servicename&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Service name&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;groupname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;groupname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Group name&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="ServiceAddGroup.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.service.ServiceAddGroup.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">groupname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groupname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">servicename</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">servicename</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">group</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">group_get</span><span class="p">([</span><span class="n">groupname</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">group</span><span class="o">.</span><span class="n">add_service</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="ServiceRemoveGroup"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.service.ServiceRemoveGroup">[docs]</a><span class="k">class</span> <span class="nc">ServiceRemoveGroup</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Remove group from service.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="ServiceRemoveGroup.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.service.ServiceRemoveGroup.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">ServiceRemoveGroup</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;servicename&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;servicename&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Service name&#39;</span><span class="p">))</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;groupname&#39;</span><span class="p">,</span> <span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;groupname&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Group name&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="ServiceRemoveGroup.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.service.ServiceRemoveGroup.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">groupname</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">groupname</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">servicename</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">servicename</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">group</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">group_get</span><span class="p">([</span><span class="n">groupname</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">group</span><span class="o">.</span><span class="n">remove_service</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="ServiceListGroups"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.service.ServiceListGroups">[docs]</a><span class="k">class</span> <span class="nc">ServiceListGroups</span><span class="p">(</span><span class="n">Lister</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;List services and their groups.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="ServiceListGroups.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.service.ServiceListGroups.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)]</span>
<span class="n">services</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">service_get_all</span><span class="p">()</span>
<span class="k">if</span> <span class="n">services</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">service</span> <span class="ow">in</span> <span class="n">services</span><span class="p">:</span>
<span class="n">groupnames</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">service</span><span class="o">.</span><span class="n">get_groups</span><span class="p">())</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">service</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">groupnames</span><span class="p">))</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">convert_lists_to_string</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">)</span>
<span class="k">return</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&#39;</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;Groups&#39;</span><span class="p">)),</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div></div>
<div class="viewcode-block" id="ServiceList"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.service.ServiceList">[docs]</a><span class="k">class</span> <span class="nc">ServiceList</span><span class="p">(</span><span class="n">Lister</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;List services and their sub-services.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="ServiceList.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.service.ServiceList.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[(</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)]</span>
<span class="n">services</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">service_get_all</span><span class="p">()</span>
<span class="k">if</span> <span class="n">services</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">service</span> <span class="ow">in</span> <span class="n">services</span><span class="p">:</span>
<span class="n">data</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">service</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">service</span><span class="o">.</span><span class="n">get_children</span><span class="p">()))</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">convert_lists_to_string</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">)</span>
<span class="k">return</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&#39;</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;Children&#39;</span><span class="p">)),</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
<span class="k">except</span> <span class="n">ClientException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</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 4.0.1.dev498 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>

View File

@ -1,131 +0,0 @@
<!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.commands.support &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.commands.support</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">from</span> <span class="nn">cliff.command</span> <span class="kn">import</span> <span class="n">Command</span>
<span class="kn">from</span> <span class="nn">kollacli.api.client</span> <span class="kn">import</span> <span class="n">ClientApi</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">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">tempfile</span>
<span class="kn">import</span> <span class="nn">traceback</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<span class="n">CLIENT</span> <span class="o">=</span> <span class="n">ClientApi</span><span class="p">()</span>
<div class="viewcode-block" id="Dump"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.support.Dump">[docs]</a><span class="k">class</span> <span class="nc">Dump</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Dumps configuration data for debugging.</span>
<span class="sd"> Dumps most files in /etc/kolla and /usr/share/kolla into a</span>
<span class="sd"> tar file so be given to support / development to help with</span>
<span class="sd"> debugging problems.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<div class="viewcode-block" id="Dump.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.support.Dump.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">dump_path</span> <span class="o">=</span> <span class="n">CLIENT</span><span class="o">.</span><span class="n">support_dump</span><span class="p">(</span><span class="n">tempfile</span><span class="o">.</span><span class="n">gettempdir</span><span class="p">())</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</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;Dump successful to {path}&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">dump_path</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</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;Dump failed: {reason}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">reason</span><span class="o">=</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">()))</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">msg</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 4.0.1.dev498 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>

View File

@ -1,151 +0,0 @@
<!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.commands.upgrade &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.commands.upgrade</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">logging</span>
<span class="kn">import</span> <span class="nn">traceback</span>
<span class="kn">from</span> <span class="nn">cliff.command</span> <span class="kn">import</span> <span class="n">Command</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.client</span> <span class="kn">import</span> <span class="n">ClientApi</span>
<span class="kn">from</span> <span class="nn">kollacli.commands.exceptions</span> <span class="kn">import</span> <span class="n">CommandError</span>
<span class="n">CLIENT</span> <span class="o">=</span> <span class="n">ClientApi</span><span class="p">()</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<div class="viewcode-block" id="Upgrade"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.upgrade.Upgrade">[docs]</a><span class="k">class</span> <span class="nc">Upgrade</span><span class="p">(</span><span class="n">Command</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Upgrade.&quot;&quot;&quot;</span>
<div class="viewcode-block" id="Upgrade.get_parser"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.upgrade.Upgrade.get_parser">[docs]</a> <span class="k">def</span> <span class="nf">get_parser</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">prog_name</span><span class="p">):</span>
<span class="n">parser</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">Upgrade</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">get_parser</span><span class="p">(</span><span class="n">prog_name</span><span class="p">)</span>
<span class="n">parser</span><span class="o">.</span><span class="n">add_argument</span><span class="p">(</span><span class="s1">&#39;--services&#39;</span><span class="p">,</span> <span class="n">nargs</span><span class="o">=</span><span class="s1">&#39;?&#39;</span><span class="p">,</span>
<span class="n">metavar</span><span class="o">=</span><span class="s1">&#39;&lt;service_list&gt;&#39;</span><span class="p">,</span>
<span class="n">help</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Upgrade service list&#39;</span><span class="p">))</span>
<span class="k">return</span> <span class="n">parser</span>
</div>
<div class="viewcode-block" id="Upgrade.take_action"><a class="viewcode-back" href="../../../kollacli.commands.html#kollacli.commands.upgrade.Upgrade.take_action">[docs]</a> <span class="k">def</span> <span class="nf">take_action</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="n">services</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">services</span><span class="p">:</span>
<span class="n">service_list</span> <span class="o">=</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">services</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">services</span> <span class="o">=</span> <span class="n">service_list</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
<span class="n">verbose_level</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">app</span><span class="o">.</span><span class="n">options</span><span class="o">.</span><span class="n">verbose_level</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">CLIENT</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="n">services</span><span class="p">)</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">job</span><span class="o">.</span><span class="n">wait</span><span class="p">()</span>
<span class="k">if</span> <span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">2</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="mi">80</span> <span class="o">*</span> <span class="s1">&#39;=&#39;</span><span class="p">)</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</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;DEBUG command output:</span><span class="se">\n</span><span class="s1">{out}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">out</span><span class="o">=</span><span class="n">job</span><span class="o">.</span><span class="n">get_console_output</span><span class="p">()))</span>
<span class="k">if</span> <span class="n">status</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</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;Success&#39;</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">CommandError</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;Job failed:</span><span class="se">\n</span><span class="s1">{msg}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">msg</span><span class="o">=</span><span class="n">job</span><span class="o">.</span><span class="n">get_error_message</span><span class="p">()))</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</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 4.0.1.dev498 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>

View File

@ -1,337 +0,0 @@
<!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.common.ansible.actions &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.common.ansible.actions</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">logging</span>
<span class="kn">import</span> <span class="nn">os</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.exceptions</span> <span class="kn">import</span> <span class="n">InvalidConfiguration</span>
<span class="kn">from</span> <span class="nn">kollacli.api.exceptions</span> <span class="kn">import</span> <span class="n">NotInInventory</span>
<span class="kn">from</span> <span class="nn">kollacli.common.ansible.playbook</span> <span class="kn">import</span> <span class="n">AnsiblePlaybook</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.passwords</span> <span class="kn">import</span> <span class="n">get_empty_password_values</span>
<span class="kn">from</span> <span class="nn">kollacli.common.properties</span> <span class="kn">import</span> <span class="n">AnsibleProperties</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_etc</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_ansible_home</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">is_string_true</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<div class="viewcode-block" id="destroy_hosts"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.actions.destroy_hosts">[docs]</a><span class="k">def</span> <span class="nf">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="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="n">remove_images</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="sd">&#39;&#39;&#39;destroy containers on a set of hosts.</span>
<span class="sd"> The containers on the specified hosts will be stopped</span>
<span class="sd"> or killed.</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">playbook</span> <span class="o">=</span> <span class="n">AnsiblePlaybook</span><span class="p">()</span>
<span class="n">playbook_name</span> <span class="o">=</span> <span class="s1">&#39;destroy.yml&#39;</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">_LI</span><span class="p">(</span><span class="s1">&#39;Please be patient as this may take a while.&#39;</span><span class="p">))</span>
<span class="n">kolla_home</span> <span class="o">=</span> <span class="n">get_kolla_ansible_home</span><span class="p">()</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">playbook_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kolla_home</span><span class="p">,</span>
<span class="s1">&#39;ansible/&#39;</span> <span class="o">+</span> <span class="n">playbook_name</span><span class="p">)</span>
<span class="c1"># &#39;hosts&#39; is defined as &#39;all&#39; in the playbook yml code, but inventory</span>
<span class="c1"># filtering will subset that down to the hosts in playbook.hosts.</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">hosts</span> <span class="o">=</span> <span class="n">hostnames</span>
<span class="k">if</span> <span class="n">remove_images</span><span class="p">:</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">extra_vars</span> <span class="o">=</span> <span class="s1">&#39;destroy_include_images=yes&#39;</span>
<span class="k">if</span> <span class="n">verbose_level</span> <span class="o">&lt;=</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">print_output</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">verbose_level</span> <span class="o">=</span> <span class="n">verbose_level</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">playbook</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">return</span> <span class="n">job</span>
</div>
<div class="viewcode-block" id="deploy"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.actions.deploy">[docs]</a><span class="k">def</span> <span class="nf">deploy</span><span class="p">(</span><span class="n">hostnames</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="n">servicenames</span><span class="o">=</span><span class="p">[]):</span>
<span class="n">playbook</span> <span class="o">=</span> <span class="n">AnsiblePlaybook</span><span class="p">()</span>
<span class="n">kolla_home</span> <span class="o">=</span> <span class="n">get_kolla_ansible_home</span><span class="p">()</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">playbook_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kolla_home</span><span class="p">,</span>
<span class="s1">&#39;ansible/site.yml&#39;</span><span class="p">)</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">extra_vars</span> <span class="o">=</span> <span class="s1">&#39;action=deploy&#39;</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">hosts</span> <span class="o">=</span> <span class="n">hostnames</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">serial</span> <span class="o">=</span> <span class="n">serial_flag</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">verbose_level</span> <span class="o">=</span> <span class="n">verbose_level</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">services</span> <span class="o">=</span> <span class="n">servicenames</span>
<span class="n">_run_deploy_rules</span><span class="p">(</span><span class="n">playbook</span><span class="p">)</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">playbook</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">return</span> <span class="n">job</span>
</div>
<div class="viewcode-block" id="precheck"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.actions.precheck">[docs]</a><span class="k">def</span> <span class="nf">precheck</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">&#39;&#39;&#39;run check playbooks on a set of hosts&#39;&#39;&#39;</span>
<span class="n">playbook_name</span> <span class="o">=</span> <span class="s1">&#39;prechecks_preinstall.yml&#39;</span>
<span class="n">kolla_home</span> <span class="o">=</span> <span class="n">get_kolla_ansible_home</span><span class="p">()</span>
<span class="n">playbook</span> <span class="o">=</span> <span class="n">AnsiblePlaybook</span><span class="p">()</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">playbook_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kolla_home</span><span class="p">,</span>
<span class="s1">&#39;ansible/&#39;</span> <span class="o">+</span> <span class="n">playbook_name</span><span class="p">)</span>
<span class="c1"># define &#39;hosts&#39; to be all, but inventory filtering will subset</span>
<span class="c1"># that down to the hosts in playbook.hosts.</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">extra_vars</span> <span class="o">=</span> <span class="s1">&#39;hosts=all&#39;</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">hosts</span> <span class="o">=</span> <span class="n">hostnames</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">print_output</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">verbose_level</span> <span class="o">=</span> <span class="n">verbose_level</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">playbook</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">return</span> <span class="n">job</span>
</div>
<div class="viewcode-block" id="pull"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.actions.pull">[docs]</a><span class="k">def</span> <span class="nf">pull</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">&#39;&#39;&#39;run pull action against all hosts&#39;&#39;&#39;</span>
<span class="n">playbook</span> <span class="o">=</span> <span class="n">AnsiblePlaybook</span><span class="p">()</span>
<span class="n">kolla_home</span> <span class="o">=</span> <span class="n">get_kolla_ansible_home</span><span class="p">()</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">playbook_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kolla_home</span><span class="p">,</span>
<span class="s1">&#39;ansible/site.yml&#39;</span><span class="p">)</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">extra_vars</span> <span class="o">=</span> <span class="s1">&#39;action=pull&#39;</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">verbose_level</span> <span class="o">=</span> <span class="n">verbose_level</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">playbook</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">return</span> <span class="n">job</span>
</div>
<div class="viewcode-block" id="stop_hosts"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.actions.stop_hosts">[docs]</a><span class="k">def</span> <span class="nf">stop_hosts</span><span class="p">(</span><span class="n">hostnames</span><span class="o">=</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">&#39;&#39;&#39;stop containers on a set of hosts.</span>
<span class="sd"> The containers on the specified hosts will be stopped</span>
<span class="sd"> or killed if the stop takes over 20 seconds.</span>
<span class="sd"> &#39;&#39;&#39;</span>
<span class="n">playbook</span> <span class="o">=</span> <span class="n">AnsiblePlaybook</span><span class="p">()</span>
<span class="n">playbook_name</span> <span class="o">=</span> <span class="s1">&#39;stop.yml&#39;</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">_LI</span><span class="p">(</span><span class="s1">&#39;Please be patient as this may take a while.&#39;</span><span class="p">))</span>
<span class="n">kolla_home</span> <span class="o">=</span> <span class="n">get_kolla_ansible_home</span><span class="p">()</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">playbook_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kolla_home</span><span class="p">,</span>
<span class="s1">&#39;ansible/&#39;</span> <span class="o">+</span> <span class="n">playbook_name</span><span class="p">)</span>
<span class="c1"># &#39;hosts&#39; is defined as &#39;all&#39; in the playbook yml code, but inventory</span>
<span class="c1"># filtering will subset that down to the hosts in playbook.hosts.</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">hosts</span> <span class="o">=</span> <span class="n">hostnames</span>
<span class="k">if</span> <span class="n">verbose_level</span> <span class="o">&lt;=</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">print_output</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">verbose_level</span> <span class="o">=</span> <span class="n">verbose_level</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">playbook</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">return</span> <span class="n">job</span>
</div>
<div class="viewcode-block" id="reconfigure"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.actions.reconfigure">[docs]</a><span class="k">def</span> <span class="nf">reconfigure</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">playbook</span> <span class="o">=</span> <span class="n">AnsiblePlaybook</span><span class="p">()</span>
<span class="n">kolla_home</span> <span class="o">=</span> <span class="n">get_kolla_ansible_home</span><span class="p">()</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">playbook_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kolla_home</span><span class="p">,</span>
<span class="s1">&#39;ansible/site.yml&#39;</span><span class="p">)</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">extra_vars</span> <span class="o">=</span> <span class="s1">&#39;action=reconfigure&#39;</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">verbose_level</span> <span class="o">=</span> <span class="n">verbose_level</span>
<span class="n">_run_deploy_rules</span><span class="p">(</span><span class="n">playbook</span><span class="p">)</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">playbook</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">return</span> <span class="n">job</span>
</div>
<div class="viewcode-block" id="upgrade"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.actions.upgrade">[docs]</a><span class="k">def</span> <span class="nf">upgrade</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">servicenames</span><span class="o">=</span><span class="p">[]):</span>
<span class="n">playbook</span> <span class="o">=</span> <span class="n">AnsiblePlaybook</span><span class="p">()</span>
<span class="n">kolla_home</span> <span class="o">=</span> <span class="n">get_kolla_ansible_home</span><span class="p">()</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">playbook_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kolla_home</span><span class="p">,</span>
<span class="s1">&#39;ansible/site.yml&#39;</span><span class="p">)</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">extra_vars</span> <span class="o">=</span> <span class="s1">&#39;action=upgrade&#39;</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">print_output</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">verbose_level</span> <span class="o">=</span> <span class="n">verbose_level</span>
<span class="n">playbook</span><span class="o">.</span><span class="n">services</span> <span class="o">=</span> <span class="n">servicenames</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">playbook</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">return</span> <span class="n">job</span>
</div>
<span class="k">def</span> <span class="nf">_run_deploy_rules</span><span class="p">(</span><span class="n">playbook</span><span class="p">):</span>
<span class="n">properties</span> <span class="o">=</span> <span class="n">AnsibleProperties</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="c1"># check that password file has no empty password values</span>
<span class="n">empty_keys</span> <span class="o">=</span> <span class="n">get_empty_password_values</span><span class="p">()</span>
<span class="k">if</span> <span class="n">empty_keys</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">InvalidConfiguration</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;Deploy failed. There are empty password values &#39;</span>
<span class="s1">&#39;in {etc}passwords.yml. &#39;</span>
<span class="s1">&#39;Please run kollacli password init or &#39;</span>
<span class="s1">&#39;kollacli password set(key) to correct them. &#39;</span>
<span class="s1">&#39;</span><span class="se">\n</span><span class="s1">Empty passwords: &#39;</span>
<span class="s1">&#39;{keys}&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">etc</span><span class="o">=</span><span class="n">get_kolla_etc</span><span class="p">(),</span> <span class="n">keys</span><span class="o">=</span><span class="n">empty_keys</span><span class="p">))</span>
<span class="c1"># cannot have both groups and hosts</span>
<span class="k">if</span> <span class="n">playbook</span><span class="o">.</span><span class="n">hosts</span> <span class="ow">and</span> <span class="n">playbook</span><span class="o">.</span><span class="n">groups</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;Hosts and Groups arguments cannot &#39;</span>
<span class="s1">&#39;both be present at the same time.&#39;</span><span class="p">))</span>
<span class="c1"># verify that all services exists</span>
<span class="k">if</span> <span class="n">playbook</span><span class="o">.</span><span class="n">services</span><span class="p">:</span>
<span class="k">for</span> <span class="n">service</span> <span class="ow">in</span> <span class="n">playbook</span><span class="o">.</span><span class="n">services</span><span class="p">:</span>
<span class="n">valid_service</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_service</span><span class="p">(</span><span class="n">service</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">valid_service</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">service</span><span class="p">)</span>
<span class="c1"># check that every group with enabled services</span>
<span class="c1"># has hosts associated to it</span>
<span class="n">group_services</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_group_services</span><span class="p">()</span>
<span class="n">failed_groups</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">failed_services</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">group_services</span><span class="p">:</span>
<span class="k">for</span> <span class="p">(</span><span class="n">groupname</span><span class="p">,</span> <span class="n">servicenames</span><span class="p">)</span> <span class="ow">in</span> <span class="n">group_services</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">group</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_group</span><span class="p">(</span><span class="n">groupname</span><span class="p">)</span>
<span class="n">hosts</span> <span class="o">=</span> <span class="n">group</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">()</span>
<span class="n">group_needs_host</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">hosts</span><span class="p">:</span>
<span class="k">for</span> <span class="n">servicename</span> <span class="ow">in</span> <span class="n">servicenames</span><span class="p">:</span>
<span class="k">if</span> <span class="n">_is_service_enabled</span><span class="p">(</span><span class="n">servicename</span><span class="p">,</span> <span class="n">inventory</span><span class="p">,</span> <span class="n">properties</span><span class="p">):</span>
<span class="n">group_needs_host</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">failed_services</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="k">if</span> <span class="n">group_needs_host</span><span class="p">:</span>
<span class="n">failed_groups</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">groupname</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">failed_groups</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">InvalidConfiguration</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;Deploy failed. &#39;</span>
<span class="s1">&#39;Groups: {groups} with enabled &#39;</span>
<span class="s1">&#39;services : {services} &#39;</span>
<span class="s1">&#39;have no associated hosts&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">groups</span><span class="o">=</span><span class="n">failed_groups</span><span class="p">,</span> <span class="n">services</span><span class="o">=</span><span class="n">failed_services</span><span class="p">))</span>
<span class="c1"># check that ring files are in /etc/kolla/config/swift if</span>
<span class="c1"># swift is enabled</span>
<span class="n">expected_files</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;account.ring.gz&#39;</span><span class="p">,</span>
<span class="s1">&#39;container.ring.gz&#39;</span><span class="p">,</span>
<span class="s1">&#39;object.ring.gz&#39;</span><span class="p">]</span>
<span class="n">is_swift_enabled</span> <span class="o">=</span> <span class="n">_is_service_enabled</span><span class="p">(</span><span class="s1">&#39;swift&#39;</span><span class="p">,</span> <span class="n">inventory</span><span class="p">,</span> <span class="n">properties</span><span class="p">)</span>
<span class="k">if</span> <span class="n">is_swift_enabled</span><span class="p">:</span>
<span class="n">path_pre</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_etc</span><span class="p">(),</span> <span class="s1">&#39;config&#39;</span><span class="p">,</span> <span class="s1">&#39;swift&#39;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">expected_file</span> <span class="ow">in</span> <span class="n">expected_files</span><span class="p">:</span>
<span class="n">path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path_pre</span><span class="p">,</span> <span class="n">expected_file</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span>
<span class="s1">&#39;Deploy failed. &#39;</span>
<span class="s1">&#39;Swift is enabled but ring buffers have &#39;</span>
<span class="s1">&#39;not yet been set up. Please see the &#39;</span>
<span class="s1">&#39;documentation for swift configuration &#39;</span>
<span class="s1">&#39;instructions.&#39;</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">InvalidConfiguration</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">_is_service_enabled</span><span class="p">(</span><span class="n">servicename</span><span class="p">,</span> <span class="n">inventory</span><span class="p">,</span> <span class="n">properties</span><span class="p">):</span>
<span class="n">service</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">get_service</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="k">if</span> <span class="n">service</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">enabled_property</span> <span class="o">=</span> <span class="s1">&#39;enable_&#39;</span> <span class="o">+</span> <span class="n">servicename</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;-&#39;</span><span class="p">,</span> <span class="s1">&#39;_&#39;</span><span class="p">)</span>
<span class="n">is_enabled</span> <span class="o">=</span> <span class="n">properties</span><span class="o">.</span><span class="n">get_property_value</span><span class="p">(</span><span class="n">enabled_property</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">is_enabled</span><span class="p">)</span> <span class="ow">is</span> <span class="nb">str</span><span class="p">:</span>
<span class="n">is_enabled</span> <span class="o">=</span> <span class="n">is_string_true</span><span class="p">(</span><span class="n">is_enabled</span><span class="p">)</span>
<span class="k">return</span> <span class="n">is_enabled</span>
</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 4.0.1.dev498 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>

View File

@ -1,611 +0,0 @@
<!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.common.ansible.job &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.common.ansible.job</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">fcntl</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">pwd</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">subprocess</span> <span class="c1"># nosec</span>
<span class="kn">import</span> <span class="nn">tempfile</span>
<span class="kn">import</span> <span class="nn">time</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.common.inventory</span> <span class="kn">import</span> <span class="n">remove_temp_inventory</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_admin_uids</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_admin_user</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_ansible_lock_path</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_actions_path</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">Lock</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">PidManager</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">run_cmd</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">safe_decode</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<span class="n">LINE_LENGTH</span> <span class="o">=</span> <span class="mi">80</span>
<span class="n">PIPE_NAME</span> <span class="o">=</span> <span class="s1">&#39;.kolla_pipe&#39;</span>
<span class="c1"># action defs</span>
<span class="n">ACTION_PLAY_START</span> <span class="o">=</span> <span class="s1">&#39;play_start&#39;</span>
<span class="n">ACTION_TASK_START</span> <span class="o">=</span> <span class="s1">&#39;task_start&#39;</span>
<span class="n">ACTION_TASK_END</span> <span class="o">=</span> <span class="s1">&#39;task_end&#39;</span>
<span class="n">ACTION_INCLUDE_FILE</span> <span class="o">=</span> <span class="s1">&#39;includefile&#39;</span>
<span class="n">ACTION_STATS</span> <span class="o">=</span> <span class="s1">&#39;stats&#39;</span>
<span class="n">ANSIBLE_1_OR_MORE</span> <span class="o">=</span> <span class="s1">&#39;One or more items failed&#39;</span>
<div class="viewcode-block" id="AnsibleJob"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.job.AnsibleJob">[docs]</a><span class="k">class</span> <span class="nc">AnsibleJob</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;class for running ansible commands&quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cmd</span><span class="p">,</span> <span class="n">deploy_id</span><span class="p">,</span> <span class="n">print_output</span><span class="p">,</span> <span class="n">inventory_path</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_command</span> <span class="o">=</span> <span class="n">cmd</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_deploy_id</span> <span class="o">=</span> <span class="n">deploy_id</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_print_output</span> <span class="o">=</span> <span class="n">print_output</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_temp_inv_path</span> <span class="o">=</span> <span class="n">inventory_path</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_fragment</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_is_first_packet</span> <span class="o">=</span> <span class="bp">True</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_fifo_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
<span class="n">tempfile</span><span class="o">.</span><span class="n">gettempdir</span><span class="p">(),</span>
<span class="s1">&#39;kolla_</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">deploy_id</span><span class="p">,</span>
<span class="s1">&#39;</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">PIPE_NAME</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_fifo_fd</span> <span class="o">=</span> <span class="bp">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process</span> <span class="o">=</span> <span class="bp">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process_std_err</span> <span class="o">=</span> <span class="bp">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_errors</span> <span class="o">=</span> <span class="p">[]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_error_total</span> <span class="o">=</span> <span class="mi">0</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_ignore_total</span> <span class="o">=</span> <span class="mi">0</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_cmd_output</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_kill_uname</span> <span class="o">=</span> <span class="bp">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_ansible_lock</span> <span class="o">=</span> <span class="n">Lock</span><span class="p">(</span><span class="n">get_ansible_lock_path</span><span class="p">(),</span> <span class="s1">&#39;ansible_job&#39;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_ignore_error_strings</span> <span class="o">=</span> <span class="bp">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_host_ignored_error_count</span> <span class="o">=</span> <span class="p">{}</span>
<div class="viewcode-block" id="AnsibleJob.run"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.job.AnsibleJob.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">locked</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ansible_lock</span><span class="o">.</span><span class="n">wait_acquire</span><span class="p">()</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">locked</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</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;unable to get lock: {lock}, to run &#39;</span>
<span class="s1">&#39;ansible job: {cmd} &#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">lock</span><span class="o">=</span><span class="n">get_ansible_lock_path</span><span class="p">(),</span> <span class="n">cmd</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_command</span><span class="p">))</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;playbook command: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_command</span><span class="p">)</span>
<span class="c1"># ansible 2.2 and later introduced an issue where if</span>
<span class="c1"># the playbook is executed from within a directory without</span>
<span class="c1"># read / write permission (which can happen when you,</span>
<span class="c1"># for example, execute via sudo) it will fail. the</span>
<span class="c1"># workaround will be to run the ansible command from /tmp</span>
<span class="c1"># and then change back to the original directory at the end</span>
<span class="n">current_dir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getcwd</span><span class="p">()</span> <span class="c1"># nosec</span>
<span class="n">os</span><span class="o">.</span><span class="n">chdir</span><span class="p">(</span><span class="s1">&#39;/tmp&#39;</span><span class="p">)</span> <span class="c1"># nosec</span>
<span class="c1"># create and open named pipe, must be owned by kolla group</span>
<span class="n">os</span><span class="o">.</span><span class="n">mkfifo</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fifo_path</span><span class="p">)</span>
<span class="n">_</span><span class="p">,</span> <span class="n">grp_id</span> <span class="o">=</span> <span class="n">get_admin_uids</span><span class="p">()</span>
<span class="n">os</span><span class="o">.</span><span class="n">chown</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fifo_path</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">getuid</span><span class="p">(),</span> <span class="n">grp_id</span><span class="p">)</span>
<span class="n">os</span><span class="o">.</span><span class="n">chmod</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fifo_path</span><span class="p">,</span> <span class="mi">0</span><span class="n">o660</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_fifo_fd</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fifo_path</span><span class="p">,</span>
<span class="n">os</span><span class="o">.</span><span class="n">O_RDONLY</span> <span class="o">|</span> <span class="n">os</span><span class="o">.</span><span class="n">O_NONBLOCK</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_command</span><span class="p">,</span> <span class="c1"># nosec</span>
<span class="n">shell</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span>
<span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span>
<span class="n">stderr</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">)</span>
<span class="c1"># setup stdout to be read without blocking</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;process pid: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">pid</span><span class="p">)</span>
<span class="n">flags</span> <span class="o">=</span> <span class="n">fcntl</span><span class="o">.</span><span class="n">fcntl</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span> <span class="n">fcntl</span><span class="o">.</span><span class="n">F_GETFL</span><span class="p">)</span>
<span class="n">fcntl</span><span class="o">.</span><span class="n">fcntl</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">stdout</span><span class="p">,</span> <span class="n">fcntl</span><span class="o">.</span><span class="n">F_SETFL</span><span class="p">,</span>
<span class="p">(</span><span class="n">flags</span> <span class="o">|</span> <span class="n">os</span><span class="o">.</span><span class="n">O_NONBLOCK</span><span class="p">))</span>
<span class="c1"># this is also part of the fix for ansible 2.2 and later</span>
<span class="n">os</span><span class="o">.</span><span class="n">chdir</span><span class="p">(</span><span class="n">current_dir</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_cleanup</span><span class="p">()</span>
<span class="k">raise</span> <span class="n">e</span>
</div>
<div class="viewcode-block" id="AnsibleJob.wait"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.job.AnsibleJob.wait">[docs]</a> <span class="k">def</span> <span class="nf">wait</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;wait for job to complete</span>
<span class="sd"> return status of job (see get_status for status values)</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">while</span> <span class="bp">True</span><span class="p">:</span>
<span class="n">status</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_status</span><span class="p">()</span>
<span class="k">if</span> <span class="n">status</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">break</span>
<span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">0.2</span><span class="p">)</span>
<span class="k">return</span> <span class="n">status</span>
</div>
<div class="viewcode-block" id="AnsibleJob.get_status"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.job.AnsibleJob.get_status">[docs]</a> <span class="k">def</span> <span class="nf">get_status</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;get process status</span>
<span class="sd"> status:</span>
<span class="sd"> - None: running</span>
<span class="sd"> - 0: done, success</span>
<span class="sd"> - 1: done, error</span>
<span class="sd"> - 2: done, killed by user</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">status</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">poll</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_read_from_callback</span><span class="p">()</span>
<span class="n">out</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_read_stream</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">stdout</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_cmd_output</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">_cmd_output</span><span class="p">,</span> <span class="n">out</span><span class="p">])</span>
<span class="k">if</span> <span class="n">status</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="c1"># job has completed</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_kill_uname</span><span class="p">:</span>
<span class="n">status</span> <span class="o">=</span> <span class="mi">2</span>
<span class="n">msg</span> <span class="o">=</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;Job killed by user ({name})&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">_kill_uname</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_errors</span> <span class="o">=</span> <span class="p">[</span><span class="n">msg</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">status</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">returncode</span>
<span class="k">if</span> <span class="n">status</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
<span class="c1"># if the process ran and returned a non zero return</span>
<span class="c1"># code we want to see if we got some ansible errors</span>
<span class="c1"># and if so if we ignored all the errors. if all</span>
<span class="c1"># errors are ignored we consider the job a success</span>
<span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_error_total</span> <span class="o">&gt;</span> <span class="mi">0</span> <span class="ow">and</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_error_total</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ignore_total</span><span class="p">):</span>
<span class="n">status</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">status</span> <span class="o">=</span> <span class="mi">1</span>
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_process_std_err</span><span class="p">:</span>
<span class="c1"># read stderr from process</span>
<span class="n">std_err</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_read_stream</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">stderr</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process_std_err</span> <span class="o">=</span> <span class="n">std_err</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_cleanup</span><span class="p">()</span>
<span class="k">return</span> <span class="n">status</span>
</div>
<div class="viewcode-block" id="AnsibleJob.get_error_message"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.job.AnsibleJob.get_error_message">[docs]</a> <span class="k">def</span> <span class="nf">get_error_message</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;&quot;get error message&quot;&quot;&quot;</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">for</span> <span class="n">error</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_errors</span><span class="p">:</span>
<span class="k">if</span> <span class="n">error</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">msg</span><span class="p">,</span> <span class="n">error</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">])</span>
<span class="c1"># if no error from the callback, check the process error</span>
<span class="k">if</span> <span class="n">ANSIBLE_1_OR_MORE</span> <span class="ow">in</span> <span class="n">msg</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_msg_from_cmdout</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">msg</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_process_std_err</span>
<span class="k">return</span> <span class="n">msg</span>
</div>
<div class="viewcode-block" id="AnsibleJob.get_command_output"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.job.AnsibleJob.get_command_output">[docs]</a> <span class="k">def</span> <span class="nf">get_command_output</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;get command output</span>
<span class="sd"> get final output text from command execution</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cmd_output</span>
</div>
<div class="viewcode-block" id="AnsibleJob.kill"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.job.AnsibleJob.kill">[docs]</a> <span class="k">def</span> <span class="nf">kill</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;kill job in progress</span>
<span class="sd"> The process pid is owned by root, so</span>
<span class="sd"> that is not killable. Need to kill all its children.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># the kill must be run as the kolla user so the</span>
<span class="c1"># kolla_actions program must be used.</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">actions_path</span> <span class="o">=</span> <span class="n">get_kolla_actions_path</span><span class="p">()</span>
<span class="n">kolla_user</span> <span class="o">=</span> <span class="n">get_admin_user</span><span class="p">()</span>
<span class="n">cmd_prefix</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;/usr/bin/sudo -u </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> job -t -p &#39;</span>
<span class="o">%</span> <span class="p">(</span><span class="n">kolla_user</span><span class="p">,</span> <span class="n">actions_path</span><span class="p">))</span>
<span class="c1"># kill the children from largest to smallest pids.</span>
<span class="n">child_pids</span> <span class="o">=</span> <span class="n">PidManager</span><span class="o">.</span><span class="n">get_child_pids</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">pid</span><span class="p">)</span>
<span class="k">for</span> <span class="n">child_pid</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">child_pids</span><span class="p">,</span> <span class="n">reverse</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">cmd_prefix</span><span class="p">,</span> <span class="n">child_pid</span><span class="p">])</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">run_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">print_output</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="k">if</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;kill failed: </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;kill succeeded: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">child_pid</span><span class="p">)</span>
<span class="c1"># record the name of user who killed the job</span>
<span class="n">cur_uid</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">getuid</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_kill_uname</span> <span class="o">=</span> <span class="n">pwd</span><span class="o">.</span><span class="n">getpwuid</span><span class="p">(</span><span class="n">cur_uid</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
<span class="k">finally</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_cleanup</span><span class="p">()</span>
</div>
<span class="k">def</span> <span class="nf">_get_msg_from_cmdout</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">msg</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;get message from command output</span>
<span class="sd"> Not very pretty, but the only way to get the error detail out of</span>
<span class="sd"> ansible when the callback gives you &#39;One or more items failed&#39;.</span>
<span class="sd"> This is where the error message is in cmd out-</span>
<span class="sd"> \nfailed: [ol7-c5] (item=[u&#39;/etc/kolla/config/aodh.conf&#39;,</span>
<span class="sd"> u&#39;/usr/share/kolla/templates/aodh/aodh.conf_augment&#39;]) =&gt;</span>
<span class="sd"> {&quot;failed&quot;: true, &quot;invocation&quot;: {&quot;module_args&quot;: {&quot;dest&quot;:</span>
<span class="sd"> &quot;/usr/share/kolla/templates/aodh/aodh.conf_augment&quot;,</span>
<span class="sd"> &quot;src&quot;: &quot;/etc/kolla/config/aodh.conf&quot;}, &quot;module_name&quot;: &quot;template&quot;},</span>
<span class="sd"> &quot;item&quot;: [&quot;/etc/kolla/config/aodh.conf&quot;,</span>
<span class="sd"> &quot;/usr/share/kolla/templates/aodh/aodh.conf_augment&quot;],</span>
<span class="sd"> &quot;msg&quot;: &quot;IOError: [Errno 2] No such file or directory:</span>
<span class="sd"> u&#39;/etc/kolla/config/aodh.conf&#39;&quot;}\n</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">fail_key</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">failed: &#39;</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">fail_key</span> <span class="o">+</span> <span class="s1">&#39;\[(.+?)]&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cmd_output</span><span class="p">)</span>
<span class="n">msgs</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">fail_key</span> <span class="o">+</span> <span class="s1">&#39;.+ =&gt; (.+?)</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_cmd_output</span><span class="p">)</span>
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">min</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">hostnames</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="n">msgs</span><span class="p">))):</span>
<span class="n">err</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="n">hostnames</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
<span class="n">ans_dict_str</span> <span class="o">=</span> <span class="n">msgs</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">ans_dict</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">ans_dict_str</span><span class="p">)</span>
<span class="n">err</span> <span class="o">=</span> <span class="n">ans_dict</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;msg&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s1">&#39;Exception reading cmd_out ansible dictionary: </span><span class="si">%s</span><span class="s1">&#39;</span>
<span class="o">%</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">msg</span><span class="p">,</span> <span class="s1">&#39;Host: &#39;</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="s1">&#39;, &#39;</span><span class="p">,</span> <span class="n">err</span><span class="p">,</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">])</span>
<span class="k">return</span> <span class="n">msg</span>
<span class="k">def</span> <span class="nf">_read_stream</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stream</span><span class="p">):</span>
<span class="n">out</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">if</span> <span class="n">stream</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">stream</span><span class="o">.</span><span class="n">closed</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">out</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">stream</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
<span class="k">except</span> <span class="ne">IOError</span><span class="p">:</span> <span class="c1"># nosec</span>
<span class="c1"># error can happen if stream is empty</span>
<span class="k">pass</span>
<span class="k">if</span> <span class="n">out</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">out</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">return</span> <span class="n">out</span>
<span class="k">def</span> <span class="nf">_log_lines</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lines</span><span class="p">):</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_print_output</span><span class="p">:</span>
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">_cleanup</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;cleanup job</span>
<span class="sd"> - delete temp inventory</span>
<span class="sd"> - close stdout and stderr</span>
<span class="sd"> - close and delete named pipe (fifo)</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="c1"># try to clear the ansible lock</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_ansible_lock</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
<span class="c1"># close the process&#39;s stdout and stderr streams</span>
<span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_process</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">stdout</span> <span class="ow">and</span> <span class="ow">not</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">closed</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_process</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">stderr</span> <span class="ow">and</span> <span class="ow">not</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">stderr</span><span class="o">.</span><span class="n">closed</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_process</span><span class="o">.</span><span class="n">stderr</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="c1"># close and delete the named pipe (fifo)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fifo_fd</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">os</span><span class="o">.</span><span class="n">close</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fifo_fd</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">OSError</span><span class="p">:</span> <span class="c1"># nosec</span>
<span class="c1"># fifo already closed</span>
<span class="k">pass</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fifo_path</span> <span class="ow">and</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fifo_path</span><span class="p">):</span>
<span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fifo_path</span><span class="p">)</span>
<span class="c1"># delete temp inventory file</span>
<span class="n">remove_temp_inventory</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_temp_inv_path</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">_read_from_callback</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;read lines from callback in real-time&quot;&quot;&quot;</span>
<span class="n">data</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fifo_fd</span><span class="p">,</span> <span class="mi">10000000</span><span class="p">)</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">OSError</span><span class="p">:</span> <span class="c1"># nosec</span>
<span class="c1"># error can happen if fifo is empty</span>
<span class="k">pass</span>
<span class="k">if</span> <span class="n">data</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;callback packets: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">data</span><span class="p">)</span>
<span class="n">packets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_deserialize_packets</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="k">for</span> <span class="n">packet</span> <span class="ow">in</span> <span class="n">packets</span><span class="p">:</span>
<span class="n">formatted_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format_packet</span><span class="p">(</span><span class="n">packet</span><span class="p">)</span>
<span class="n">lines</span> <span class="o">=</span> <span class="n">formatted_data</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_log_lines</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span>
<span class="k">def</span> <span class="nf">_format_packet</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">packet</span><span class="p">):</span>
<span class="n">action</span> <span class="o">=</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;action&#39;</span><span class="p">]</span>
<span class="k">if</span> <span class="n">action</span> <span class="o">==</span> <span class="n">ACTION_INCLUDE_FILE</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format_include_file</span><span class="p">(</span><span class="n">packet</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">action</span> <span class="o">==</span> <span class="n">ACTION_PLAY_START</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format_play_start</span><span class="p">(</span><span class="n">packet</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">action</span> <span class="o">==</span> <span class="n">ACTION_STATS</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format_stats</span><span class="p">(</span><span class="n">packet</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">action</span> <span class="o">==</span> <span class="n">ACTION_TASK_END</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format_task_end</span><span class="p">(</span><span class="n">packet</span><span class="p">)</span>
<span class="k">elif</span> <span class="n">action</span> <span class="o">==</span> <span class="n">ACTION_TASK_START</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format_task_start</span><span class="p">(</span><span class="n">packet</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</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 action [{action}] from callback&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">action</span><span class="o">=</span><span class="n">action</span><span class="p">))</span>
<span class="k">def</span> <span class="nf">_format_include_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">packet</span><span class="p">):</span>
<span class="k">return</span> <span class="s1">&#39;included: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;filename&#39;</span><span class="p">]</span>
<span class="k">def</span> <span class="nf">_format_play_start</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">packet</span><span class="p">):</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_filler</span><span class="p">(</span><span class="s1">&#39;PLAY &#39;</span><span class="p">,</span> <span class="n">LINE_LENGTH</span><span class="p">,</span> <span class="s1">&#39;*&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_first_packet</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">Playbook: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;playbook&#39;</span><span class="p">]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_is_first_packet</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">return</span> <span class="n">msg</span>
<span class="k">def</span> <span class="nf">_format_stats</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">packet</span><span class="p">):</span>
<span class="c1"># each element is a dictionary with host as key</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_filler</span><span class="p">(</span><span class="s1">&#39;PLAY RECAP &#39;</span><span class="p">,</span> <span class="n">LINE_LENGTH</span><span class="p">,</span> <span class="s1">&#39;*&#39;</span><span class="p">)</span>
<span class="n">processed</span> <span class="o">=</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;processed&#39;</span><span class="p">]</span>
<span class="n">ok</span> <span class="o">=</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;ok&#39;</span><span class="p">]</span>
<span class="n">changed</span> <span class="o">=</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;changed&#39;</span><span class="p">]</span>
<span class="n">unreachable</span> <span class="o">=</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;unreachable&#39;</span><span class="p">]</span>
<span class="n">failures</span> <span class="o">=</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;failures&#39;</span><span class="p">]</span>
<span class="k">for</span> <span class="n">host</span> <span class="ow">in</span> <span class="n">processed</span><span class="p">:</span>
<span class="n">hostline</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_filler</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="mi">28</span><span class="p">,</span> <span class="s1">&#39; &#39;</span><span class="p">)</span>
<span class="n">hostline</span> <span class="o">+=</span> <span class="p">(</span><span class="s1">&#39;: ok=</span><span class="si">%s</span><span class="s1">&#39;</span>
<span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_filler</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">ok</span><span class="p">[</span><span class="n">host</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="s1">&#39; &#39;</span><span class="p">))</span>
<span class="n">hostline</span> <span class="o">+=</span> <span class="p">(</span><span class="s1">&#39;changed=</span><span class="si">%s</span><span class="s1">&#39;</span>
<span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_filler</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">changed</span><span class="p">[</span><span class="n">host</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="s1">&#39; &#39;</span><span class="p">))</span>
<span class="n">hostline</span> <span class="o">+=</span> <span class="p">(</span><span class="s1">&#39;unreachable=</span><span class="si">%s</span><span class="s1">&#39;</span>
<span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_filler</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">unreachable</span><span class="p">[</span><span class="n">host</span><span class="p">],</span> <span class="mi">5</span><span class="p">,</span> <span class="s1">&#39; &#39;</span><span class="p">))</span>
<span class="n">failure_count</span> <span class="o">=</span> <span class="n">failures</span><span class="p">[</span><span class="n">host</span><span class="p">]</span>
<span class="n">ignores</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_host_ignored_error_count</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
<span class="c1"># track the total numbers of failures and ignored failures to help</span>
<span class="c1"># determine job success</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_error_total</span> <span class="o">+=</span> <span class="n">failure_count</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_ignore_total</span> <span class="o">+=</span> <span class="n">ignores</span>
<span class="n">failure_count</span> <span class="o">-=</span> <span class="n">ignores</span>
<span class="n">hostline</span> <span class="o">+=</span> <span class="p">(</span><span class="s1">&#39;failed=</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_add_filler</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">failure_count</span><span class="p">,</span> <span class="mi">5</span><span class="p">,</span> <span class="s1">&#39; &#39;</span><span class="p">))</span>
<span class="n">hostline</span> <span class="o">+=</span> <span class="s1">&#39;ignored=</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">ignores</span>
<span class="n">msg</span> <span class="o">+=</span> <span class="n">hostline</span>
<span class="k">return</span> <span class="n">msg</span>
<span class="k">def</span> <span class="nf">_format_task_end</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">packet</span><span class="p">):</span>
<span class="n">host</span> <span class="o">=</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;host&#39;</span><span class="p">]</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;status&#39;</span><span class="p">]</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1">: [</span><span class="si">%s</span><span class="s1">]&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">status</span><span class="p">,</span> <span class="n">host</span><span class="p">)</span>
<span class="k">if</span> <span class="n">status</span> <span class="o">==</span> <span class="s1">&#39;failed&#39;</span> <span class="ow">or</span> <span class="n">status</span> <span class="o">==</span> <span class="s1">&#39;unreachable&#39;</span><span class="p">:</span>
<span class="n">results_dict</span> <span class="o">=</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;results&#39;</span><span class="p">]</span>
<span class="n">taskname</span> <span class="o">=</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;task&#39;</span><span class="p">][</span><span class="s1">&#39;name&#39;</span><span class="p">]</span>
<span class="c1"># update saved error messages. if the error message should be</span>
<span class="c1"># hidden then do not add it to _errors and add to the ignored</span>
<span class="c1"># error count for the host</span>
<span class="n">formatted_error</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format_error</span><span class="p">(</span><span class="n">taskname</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span>
<span class="n">status</span><span class="p">,</span> <span class="n">results_dict</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hide_ignored_errors</span><span class="p">(</span><span class="n">formatted_error</span><span class="p">):</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;Ignored Error: &#39;</span> <span class="o">+</span> <span class="n">formatted_error</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_host_ignored_error_count</span><span class="p">[</span><span class="n">host</span><span class="p">]</span> <span class="o">=</span> \
<span class="bp">self</span><span class="o">.</span><span class="n">_host_ignored_error_count</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_errors</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">formatted_error</span><span class="p">)</span>
<span class="c1"># format log message</span>
<span class="n">results</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">results_dict</span><span class="p">)</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;fatal: [</span><span class="si">%s</span><span class="s1">]: </span><span class="si">%s</span><span class="s1">! =&gt; </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> \
<span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">status</span><span class="o">.</span><span class="n">upper</span><span class="p">(),</span> <span class="n">results</span><span class="p">)</span>
<span class="k">return</span> <span class="n">msg</span>
<span class="k">def</span> <span class="nf">_format_task_start</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">packet</span><span class="p">):</span>
<span class="n">taskname</span> <span class="o">=</span> <span class="n">packet</span><span class="p">[</span><span class="s1">&#39;name&#39;</span><span class="p">]</span>
<span class="n">task_line</span> <span class="o">=</span> <span class="s1">&#39;TASK [</span><span class="si">%s</span><span class="s1">] &#39;</span> <span class="o">%</span> <span class="n">taskname</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_add_filler</span><span class="p">(</span><span class="n">task_line</span><span class="p">,</span> <span class="n">LINE_LENGTH</span><span class="p">,</span> <span class="s1">&#39;*&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">msg</span>
<span class="k">def</span> <span class="nf">_format_error</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">taskname</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">status</span><span class="p">,</span> <span class="n">results</span><span class="p">):</span>
<span class="c1"># get the primary error message</span>
<span class="n">err_msg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_safe_get</span><span class="p">(</span><span class="n">results</span><span class="p">,</span> <span class="s1">&#39;msg&#39;</span><span class="p">)</span>
<span class="c1"># there may be more detailed error msgs under results</span>
<span class="n">sub_results</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_safe_get</span><span class="p">(</span><span class="n">results</span><span class="p">,</span> <span class="s1">&#39;results&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">sub_results</span><span class="p">:</span>
<span class="n">sub_errs</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">comma</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">for</span> <span class="n">invocation</span> <span class="ow">in</span> <span class="n">sub_results</span><span class="p">:</span>
<span class="n">is_failed</span> <span class="o">=</span> <span class="n">invocation</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;failed&#39;</span><span class="p">,</span> <span class="bp">False</span><span class="p">)</span>
<span class="k">if</span> <span class="n">is_failed</span> <span class="ow">is</span> <span class="bp">True</span><span class="p">:</span>
<span class="n">sub_msg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_safe_get</span><span class="p">(</span><span class="n">invocation</span><span class="p">,</span> <span class="s1">&#39;msg&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">sub_msg</span><span class="p">:</span>
<span class="n">sub_msg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_safe_get</span><span class="p">(</span><span class="n">invocation</span><span class="p">,</span> <span class="s1">&#39;stderr&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">sub_msg</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_safe_get</span><span class="p">(</span><span class="n">invocation</span><span class="p">,</span> <span class="s1">&#39;stdout&#39;</span><span class="p">)</span>
<span class="n">sub_errs</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">sub_errs</span><span class="p">,</span> <span class="n">comma</span><span class="p">,</span> <span class="n">sub_msg</span><span class="p">])</span>
<span class="k">if</span> <span class="n">sub_msg</span><span class="p">:</span>
<span class="n">comma</span> <span class="o">=</span> <span class="s1">&#39;, &#39;</span>
<span class="k">if</span> <span class="n">sub_errs</span><span class="p">:</span>
<span class="n">err_msg</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="n">err_msg</span><span class="p">,</span> <span class="s1">&#39; [&#39;</span><span class="p">,</span> <span class="n">sub_errs</span><span class="p">,</span> <span class="s1">&#39;]&#39;</span><span class="p">])</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">err_msg</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">err_msg</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span>
<span class="c1"># sometimes the error message is in std_out</span>
<span class="c1"># eg- &quot;stdout&quot;: &#39;localhost | FAILED! =&gt; {&quot;changed&quot;: false,</span>
<span class="c1"># &quot;failed&quot;: true, &quot;msg&quot;: &quot;...msg...&quot;}&#39;</span>
<span class="n">stdout</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_safe_get</span><span class="p">(</span><span class="n">results</span><span class="p">,</span> <span class="s1">&#39;stdout&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="s1">&#39;&quot;msg&quot;: &quot;&#39;</span> <span class="ow">in</span> <span class="n">stdout</span><span class="p">:</span>
<span class="n">err_msg</span> <span class="o">=</span> <span class="n">stdout</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;&quot;msg&quot;: &quot;&#39;</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
<span class="n">err_msg</span> <span class="o">=</span> <span class="n">err_msg</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;&quot;&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="n">err_msg</span> <span class="o">=</span> <span class="n">stdout</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">err_msg</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">err_msg</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span>
<span class="c1"># if still no err_msg, provide entire result</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">err_msg</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">results</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;unable to convert results to string&#39;</span> <span class="o">%</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="n">msg</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;Host: </span><span class="si">%s</span><span class="s1">, Task: </span><span class="si">%s</span><span class="s1">, Status: </span><span class="si">%s</span><span class="s1">, Message: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span>
<span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="n">taskname</span><span class="p">,</span> <span class="n">status</span><span class="p">,</span> <span class="n">err_msg</span><span class="p">))</span>
<span class="k">return</span> <span class="n">msg</span>
<span class="k">def</span> <span class="nf">_safe_get</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dictionary</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;get value, never return None&quot;&quot;&quot;</span>
<span class="n">val</span> <span class="o">=</span> <span class="n">dictionary</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">val</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">val</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">return</span> <span class="n">val</span>
<span class="k">def</span> <span class="nf">_add_filler</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">msg</span><span class="p">,</span> <span class="n">length</span><span class="p">,</span> <span class="n">filler</span><span class="p">):</span>
<span class="n">num_stars</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">length</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">msg</span><span class="p">),</span> <span class="mi">0</span><span class="p">)</span>
<span class="n">stars</span> <span class="o">=</span> <span class="n">num_stars</span> <span class="o">*</span> <span class="n">filler</span>
<span class="k">return</span> <span class="n">msg</span> <span class="o">+</span> <span class="n">stars</span>
<span class="k">def</span> <span class="nf">_deserialize_packets</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;get json packets from callback</span>
<span class="sd"> Packets are delimited by \n&#39;s. It&#39;s possible that a packet</span>
<span class="sd"> is cut in the middle, creating 2 fragments. Need to handle that.</span>
<span class="sd"> return list of dictionaries</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">packets</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">has_fragment</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">endswith</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">):</span>
<span class="n">has_fragment</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;fragment found: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">data</span><span class="p">)</span>
<span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">lines</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">num_lines</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">lines</span><span class="p">)</span>
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span><span class="p">:</span>
<span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
<span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
<span class="c1"># first line</span>
<span class="n">line</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fragment</span> <span class="o">+</span> <span class="n">line</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_fragment</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="n">num_lines</span> <span class="ow">and</span> <span class="n">has_fragment</span><span class="p">:</span>
<span class="c1"># last line is incomplete, save as fragment</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_fragment</span> <span class="o">=</span> <span class="n">line</span>
<span class="k">break</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">line</span><span class="p">:</span>
<span class="c1"># ignore empty string lines</span>
<span class="k">continue</span>
<span class="n">info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">json_load</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
<span class="k">if</span> <span class="n">info</span><span class="p">:</span>
<span class="n">packets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">info</span><span class="p">)</span>
<span class="k">return</span> <span class="n">packets</span>
<div class="viewcode-block" id="AnsibleJob.json_load"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.job.AnsibleJob.json_load">[docs]</a> <span class="k">def</span> <span class="nf">json_load</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">string_var</span><span class="p">,</span> <span class="n">raise_on_err</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="n">retval</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">retval</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">string_var</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s1">&#39;invalid string for json encoding: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">string_var</span><span class="p">)</span>
<span class="k">if</span> <span class="n">raise_on_err</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">e</span>
<span class="k">return</span> <span class="n">retval</span>
</div>
<span class="k">def</span> <span class="nf">_hide_ignored_errors</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">error_string</span><span class="p">):</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ignore_error_strings</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">for</span> <span class="n">ignore_string</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ignore_error_strings</span><span class="p">:</span>
<span class="n">pattern</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">compile</span><span class="p">(</span><span class="n">ignore_string</span><span class="p">)</span>
<span class="n">match</span> <span class="o">=</span> <span class="n">pattern</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="n">error_string</span><span class="p">)</span>
<span class="k">if</span> <span class="n">match</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">True</span>
<span class="k">return</span> <span class="bp">False</span></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 4.0.1.dev498 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>

View File

@ -1,266 +0,0 @@
<!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.common.ansible.playbook &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.common.ansible.playbook</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">logging</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">traceback</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.common.ansible.job</span> <span class="kn">import</span> <span class="n">AnsibleJob</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_admin_user</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_ansible_command</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_ansible_plugin_dir</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_etc</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_ansible_home</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="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<div class="viewcode-block" id="AnsiblePlaybook"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.playbook.AnsiblePlaybook">[docs]</a><span class="k">class</span> <span class="nc">AnsiblePlaybook</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="n">playbook_path</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">extra_vars</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">include_passwords</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">flush_cache</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">print_output</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">verbose_level</span> <span class="o">=</span> <span class="mi">0</span>
<span class="n">hosts</span> <span class="o">=</span> <span class="bp">None</span> <span class="c1"># type: List[str]</span>
<span class="n">groups</span> <span class="o">=</span> <span class="bp">None</span> <span class="c1"># type: List[str]</span>
<span class="n">services</span> <span class="o">=</span> <span class="bp">None</span> <span class="c1"># type: List[str]</span>
<span class="n">ignore_error_strings</span> <span class="o">=</span> <span class="bp">None</span> <span class="c1"># type: List[str]</span>
<span class="n">serial</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">deploy_id</span> <span class="o">=</span> <span class="bp">None</span> <span class="c1"># type: str</span>
<span class="n">inventory</span> <span class="o">=</span> <span class="bp">None</span> <span class="c1"># type: Inventory</span>
<div class="viewcode-block" id="AnsiblePlaybook.run"><a class="viewcode-back" href="../../../../kollacli.common.ansible.html#kollacli.common.ansible.playbook.AnsiblePlaybook.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_check_for_plugin</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</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_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_make_temp_inventory</span><span class="p">()</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_playbook_cmd</span><span class="p">(</span><span class="n">inventory_path</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_log_ansible_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">inventory_path</span><span class="p">)</span>
<span class="c1"># create and run the job</span>
<span class="n">job</span> <span class="o">=</span> <span class="n">AnsibleJob</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">deploy_id</span><span class="p">,</span>
<span class="bp">self</span><span class="o">.</span><span class="n">print_output</span><span class="p">,</span> <span class="n">inventory_path</span><span class="p">)</span>
<span class="n">job</span><span class="o">.</span><span class="n">_ignore_error_strings</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ignore_error_strings</span>
<span class="n">job</span><span class="o">.</span><span class="n">run</span><span class="p">()</span>
<span class="k">return</span> <span class="n">job</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div>
<span class="k">def</span> <span class="nf">_check_for_plugin</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;check that plug-in is properly installed&quot;&quot;&quot;</span>
<span class="n">pi_dir</span> <span class="o">=</span> <span class="n">get_ansible_plugin_dir</span><span class="p">()</span>
<span class="n">pi_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">pi_dir</span><span class="p">,</span> <span class="s1">&#39;kolla_callback.py&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">pi_path</span><span class="p">):</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">warning</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;WARNING: kolla callback plug-in is missing. &#39;</span>
<span class="s1">&#39;Should be here: {path}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">pi_path</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">ansible_cfg_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span>
<span class="n">get_kolla_ansible_home</span><span class="p">(),</span> <span class="s1">&#39;.ansible.cfg&#39;</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">ansible_cfg_path</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">cfg</span><span class="p">:</span>
<span class="n">whitelist_ok</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">cfg</span><span class="p">:</span>
<span class="k">if</span> <span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;callback_whitelist&#39;</span><span class="p">)</span> <span class="ow">and</span>
<span class="s1">&#39;kolla_callback&#39;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">):</span>
<span class="n">whitelist_ok</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">break</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">whitelist_ok</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">warning</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;WARNING: kolla callback plug-in is not &#39;</span>
<span class="s1">&#39;whitelisted &#39;</span>
<span class="s1">&#39;in {path}</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">ansible_cfg_path</span><span class="p">))</span>
<span class="k">def</span> <span class="nf">_get_playbook_cmd</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inventory_path</span><span class="p">):</span>
<span class="n">flag</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="c1"># verbose levels: 1=not verbose, 2=more verbose</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">flag</span> <span class="o">=</span> <span class="s1">&#39;-&#39;</span>
<span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">verbose_level</span><span class="p">):</span>
<span class="n">flag</span> <span class="o">+=</span> <span class="s1">&#39;v&#39;</span>
<span class="n">ansible_cmd</span> <span class="o">=</span> <span class="n">get_ansible_command</span><span class="p">(</span><span class="n">playbook</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">admin_user</span> <span class="o">=</span> <span class="n">get_admin_user</span><span class="p">()</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;/usr/bin/sudo -u </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">admin_user</span><span class="p">,</span> <span class="n">ansible_cmd</span><span class="p">,</span> <span class="n">flag</span><span class="p">)</span>
<span class="n">cmd</span> <span class="o">+=</span> <span class="s1">&#39; -i </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">inventory_path</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">include_passwords</span><span class="p">:</span>
<span class="n">cmd</span> <span class="o">+=</span> <span class="s1">&#39; </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_password_path</span><span class="p">()</span>
<span class="n">cmd</span> <span class="o">+=</span> <span class="s1">&#39; </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">playbook_path</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">extra_vars</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">serial</span><span class="p">:</span>
<span class="n">extra_vars</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">extra_vars</span><span class="p">:</span>
<span class="n">extra_vars</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">extra_vars</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">serial</span><span class="p">:</span>
<span class="n">extra_vars</span> <span class="o">+=</span> <span class="s1">&#39; &#39;</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">serial</span><span class="p">:</span>
<span class="n">extra_vars</span> <span class="o">+=</span> <span class="s1">&#39;serial_var=1&#39;</span>
<span class="n">cmd</span> <span class="o">+=</span> <span class="s1">&#39; --extra-vars </span><span class="se">\&quot;</span><span class="si">%s</span><span class="se">\&quot;</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">extra_vars</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">services</span><span class="p">:</span>
<span class="n">service_string</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">first</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">for</span> <span class="n">service</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">services</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">first</span><span class="p">:</span>
<span class="n">service_string</span> <span class="o">+=</span> <span class="s1">&#39;,&#39;</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">first</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">service_string</span> <span class="o">=</span> <span class="n">service_string</span> <span class="o">+</span> <span class="n">service</span>
<span class="n">cmd</span> <span class="o">+=</span> <span class="s1">&#39; --tags </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">service_string</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">hosts</span><span class="p">:</span>
<span class="n">host_string</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">first</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">for</span> <span class="n">host</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">hosts</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">first</span><span class="p">:</span>
<span class="n">host_string</span> <span class="o">+=</span> <span class="s1">&#39;,&#39;</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">first</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">host_string</span> <span class="o">=</span> <span class="n">host_string</span> <span class="o">+</span> <span class="n">host</span>
<span class="n">cmd</span> <span class="o">+=</span> <span class="s1">&#39; --limit </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">host_string</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">flush_cache</span><span class="p">:</span>
<span class="n">cmd</span> <span class="o">+=</span> <span class="s1">&#39; --flush-cache&#39;</span>
<span class="k">return</span> <span class="n">cmd</span>
<span class="k">def</span> <span class="nf">_make_temp_inventory</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Create temporary inventory file</span>
<span class="sd"> A temporary inventory is created so that a</span>
<span class="sd"> unique id can be assigned to the deployment. That</span>
<span class="sd"> id will used by the ansible callback to tag messages</span>
<span class="sd"> and status from deployments back to the kolla code.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">inventory_filter</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">inventory_path</span> <span class="o">=</span> \
<span class="bp">self</span><span class="o">.</span><span class="n">inventory</span><span class="o">.</span><span class="n">create_json_gen_file</span><span class="p">(</span><span class="n">inventory_filter</span><span class="p">)</span>
<span class="c1"># inv path = /tmp/kolla_UUID/temp_inventory.py</span>
<span class="n">deploy_id</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">inventory_path</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">deploy_id</span> <span class="o">=</span> <span class="n">deploy_id</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;kolla_&#39;</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
<span class="k">return</span> <span class="n">inventory_path</span>
<span class="k">def</span> <span class="nf">_get_password_path</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">kolla_etc</span> <span class="o">=</span> <span class="n">get_kolla_etc</span><span class="p">()</span>
<span class="k">return</span> <span class="p">(</span><span class="s1">&#39;-e @&#39;</span> <span class="o">+</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kolla_etc</span><span class="p">,</span> <span class="s1">&#39;passwords.yml &#39;</span><span class="p">))</span>
<span class="k">def</span> <span class="nf">_log_ansible_cmd</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cmd</span><span class="p">,</span> <span class="n">inventory_path</span><span class="p">):</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">2</span><span class="p">:</span>
<span class="c1"># log the ansible command</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;cmd:</span><span class="se">\n</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">cmd</span><span class="p">)</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">verbose_level</span> <span class="o">&gt;</span> <span class="mi">3</span><span class="p">:</span>
<span class="c1"># log the inventory</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">inventory_path</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">inv_file</span><span class="p">:</span>
<span class="n">inv</span> <span class="o">=</span> <span class="n">inv_file</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">inventory: </span><span class="se">\n</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">inv</span><span class="p">)</span></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 4.0.1.dev498 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>

View File

@ -1,768 +0,0 @@
<!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.common.inventory &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.common.inventory</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">from</span> <span class="nn">copy</span> <span class="kn">import</span> <span class="n">copy</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">jsonpickle</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">tempfile</span>
<span class="kn">import</span> <span class="nn">traceback</span>
<span class="kn">import</span> <span class="nn">uuid</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">FailedOperation</span>
<span class="kn">from</span> <span class="nn">kollacli.api.exceptions</span> <span class="kn">import</span> <span class="n">HostError</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.exceptions</span> <span class="kn">import</span> <span class="n">InvalidConfiguration</span>
<span class="kn">from</span> <span class="nn">kollacli.api.exceptions</span> <span class="kn">import</span> <span class="n">MissingArgument</span>
<span class="kn">from</span> <span class="nn">kollacli.api.exceptions</span> <span class="kn">import</span> <span class="n">NotInInventory</span>
<span class="kn">from</span> <span class="nn">kollacli.common.allinone</span> <span class="kn">import</span> <span class="n">AllInOne</span>
<span class="kn">from</span> <span class="nn">kollacli.common.host</span> <span class="kn">import</span> <span class="n">Host</span>
<span class="kn">from</span> <span class="nn">kollacli.common.host_group</span> <span class="kn">import</span> <span class="n">HostGroup</span>
<span class="kn">from</span> <span class="nn">kollacli.common.service</span> <span class="kn">import</span> <span class="n">Service</span>
<span class="kn">from</span> <span class="nn">kollacli.common.sshutils</span> <span class="kn">import</span> <span class="n">ssh_setup_host</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_admin_uids</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_admin_user</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_ansible_command</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_group_vars_dir</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_host_vars_dir</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_cli_etc</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">run_cmd</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">sync_read_file</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">sync_write_file</span>
<span class="n">ANSIBLE_SSH_USER</span> <span class="o">=</span> <span class="s1">&#39;ansible_ssh_user&#39;</span>
<span class="n">ANSIBLE_CONNECTION</span> <span class="o">=</span> <span class="s1">&#39;ansible_connection&#39;</span>
<span class="n">ANSIBLE_BECOME</span> <span class="o">=</span> <span class="s1">&#39;ansible_become&#39;</span>
<span class="n">INVENTORY_PATH</span> <span class="o">=</span> <span class="s1">&#39;ansible/inventory.json&#39;</span>
<span class="n">COMPUTE_GRP_NAME</span> <span class="o">=</span> <span class="s1">&#39;compute&#39;</span>
<span class="c1"># these groups cannot be deleted, they are required by kolla</span>
<span class="n">PROTECTED_GROUPS</span> <span class="o">=</span> <span class="p">[</span><span class="n">COMPUTE_GRP_NAME</span><span class="p">]</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<div class="viewcode-block" id="remove_temp_inventory"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.remove_temp_inventory">[docs]</a><span class="k">def</span> <span class="nf">remove_temp_inventory</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
<span class="c1"># type: (str) -&gt; None</span>
<span class="sd">&quot;&quot;&quot;remove temp inventory file and its parent directory&quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">path</span><span class="p">:</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
<span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="n">dirpath</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">dirpath</span><span class="p">):</span>
<span class="n">os</span><span class="o">.</span><span class="n">rmdir</span><span class="p">(</span><span class="n">dirpath</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Inventory"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory">[docs]</a><span class="k">class</span> <span class="nc">Inventory</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="n">class_version</span> <span class="o">=</span> <span class="mi">4</span>
<span class="sd">&quot;&quot;&quot;class version history</span>
<span class="sd"> 4: (v4.0.1):</span>
<span class="sd"> - removed concept of sub-services (not backward compatible)</span>
<span class="sd"> 3: (v3.0.1):</span>
<span class="sd"> - added aodh, ceph</span>
<span class="sd"> - fix to ensure all sub-services have service as parent</span>
<span class="sd"> 2: (v2.1.1) added ceilometer</span>
<span class="sd"> 1: (v2.0.1) initial release</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_groups</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># kv = name:object</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># kv = name:object</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_services</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># kv = name:object</span>
<span class="bp">self</span><span class="o">.</span><span class="n">vars</span> <span class="o">=</span> <span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">version</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="n">class_version</span>
<span class="bp">self</span><span class="o">.</span><span class="n">remote_mode</span> <span class="o">=</span> <span class="bp">True</span>
<span class="c1"># initialize the inventory to its defaults</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_create_default_inventory</span><span class="p">()</span>
<div class="viewcode-block" id="Inventory.upgrade"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.upgrade">[docs]</a> <span class="k">def</span> <span class="nf">upgrade</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="c1"># check for new services or subservices in the all-in-one file</span>
<span class="c1"># leaving in this hook but no upgrade from &lt;4 to 4 is supported</span>
<span class="c1"># so yanking out all upgrade logic</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_upgrade_services</span><span class="p">()</span>
<span class="c1"># update the version and save upgraded inventory file</span>
<span class="bp">self</span><span class="o">.</span><span class="n">version</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="n">class_version</span>
<span class="n">Inventory</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
</div>
<span class="k">def</span> <span class="nf">_upgrade_services</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">allinone</span> <span class="o">=</span> <span class="n">AllInOne</span><span class="p">()</span>
<span class="c1"># add new services</span>
<span class="k">for</span> <span class="n">servicename</span><span class="p">,</span> <span class="n">service</span> <span class="ow">in</span> <span class="n">allinone</span><span class="o">.</span><span class="n">services</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="k">if</span> <span class="n">servicename</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">[</span><span class="n">servicename</span><span class="p">]</span> <span class="o">=</span> <span class="n">service</span>
<span class="c1"># remove obsolete services</span>
<span class="k">for</span> <span class="n">servicename</span> <span class="ow">in</span> <span class="n">copy</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">)</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
<span class="k">if</span> <span class="n">servicename</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">allinone</span><span class="o">.</span><span class="n">services</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">delete_service</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="Inventory.load"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.load">[docs]</a> <span class="k">def</span> <span class="nf">load</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;load the inventory from a pickle file&quot;&quot;&quot;</span>
<span class="n">inventory_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_cli_etc</span><span class="p">(),</span> <span class="n">INVENTORY_PATH</span><span class="p">)</span>
<span class="n">data</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">inventory_path</span><span class="p">):</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">sync_read_file</span><span class="p">(</span><span class="n">inventory_path</span><span class="p">)</span>
<span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">strip</span><span class="p">():</span>
<span class="n">inventory</span> <span class="o">=</span> <span class="n">jsonpickle</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="c1"># upgrade version handling</span>
<span class="k">if</span> <span class="n">inventory</span><span class="o">.</span><span class="n">version</span> <span class="o">!=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">class_version</span><span class="p">:</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">upgrade</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">inventory</span> <span class="o">=</span> <span class="n">Inventory</span><span class="p">()</span>
<span class="n">Inventory</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">inventory</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">FailedOperation</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;Loading inventory failed. : {error}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">error</span><span class="o">=</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">()))</span>
<span class="k">return</span> <span class="n">inventory</span>
</div>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="Inventory.save"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.save">[docs]</a> <span class="k">def</span> <span class="nf">save</span><span class="p">(</span><span class="n">inventory</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Save the inventory in a pickle file&quot;&quot;&quot;</span>
<span class="n">inventory_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_cli_etc</span><span class="p">(),</span> <span class="n">INVENTORY_PATH</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="c1"># multiple trips thru json to render a readable inventory file</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">jsonpickle</span><span class="o">.</span><span class="n">encode</span><span class="p">(</span><span class="n">inventory</span><span class="p">)</span>
<span class="n">data_str</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="n">pretty_data</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">data_str</span><span class="p">,</span> <span class="n">indent</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span>
<span class="n">sync_write_file</span><span class="p">(</span><span class="n">inventory_path</span><span class="p">,</span> <span class="n">pretty_data</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">FailedOperation</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;Saving inventory failed. : {error}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">error</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">)))</span>
</div>
<div class="viewcode-block" id="Inventory.get_hosts"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_hosts">[docs]</a> <span class="k">def</span> <span class="nf">get_hosts</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="o">.</span><span class="n">values</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="Inventory.get_hostnames"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_hostnames">[docs]</a> <span class="k">def</span> <span class="nf">get_hostnames</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
</div>
<div class="viewcode-block" id="Inventory.get_host"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_host">[docs]</a> <span class="k">def</span> <span class="nf">get_host</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostname</span><span class="p">):</span>
<span class="n">host</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="p">:</span>
<span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="p">[</span><span class="n">hostname</span><span class="p">]</span>
<span class="k">return</span> <span class="n">host</span>
</div>
<div class="viewcode-block" id="Inventory.add_host"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.add_host">[docs]</a> <span class="k">def</span> <span class="nf">add_host</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">groupname</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;add host</span>
<span class="sd"> if groupname is none, create a new host</span>
<span class="sd"> if group name is not none, add host to group</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">groupname</span> <span class="ow">and</span> <span class="n">groupname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">groupname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">groupname</span> <span class="ow">and</span> <span class="n">hostname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="p">:</span>
<span class="c1"># if a groupname is specified, the host must already exist</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">groupname</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">remote_mode</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">1</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">InvalidConfiguration</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;Cannot have more than one host when in local deploy &#39;</span>
<span class="s1">&#39;mode.&#39;</span><span class="p">))</span>
<span class="n">changed</span> <span class="o">=</span> <span class="bp">False</span>
<span class="c1"># create new host if it doesn&#39;t exist</span>
<span class="n">host</span> <span class="o">=</span> <span class="n">Host</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">():</span>
<span class="c1"># a new host is being added to the inventory</span>
<span class="n">changed</span> <span class="o">=</span> <span class="bp">True</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="p">[</span><span class="n">hostname</span><span class="p">]</span> <span class="o">=</span> <span class="n">host</span>
<span class="c1"># a host is to be added to an existing group</span>
<span class="k">elif</span> <span class="n">groupname</span><span class="p">:</span>
<span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">[</span><span class="n">groupname</span><span class="p">]</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">group</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">():</span>
<span class="n">changed</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">group</span><span class="o">.</span><span class="n">add_host</span><span class="p">(</span><span class="n">host</span><span class="p">)</span>
<span class="k">return</span> <span class="n">changed</span>
</div>
<div class="viewcode-block" id="Inventory.remove_all_hosts"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.remove_all_hosts">[docs]</a> <span class="k">def</span> <span class="nf">remove_all_hosts</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;remove all hosts.&quot;&quot;&quot;</span>
<span class="n">hostnamess</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">()</span>
<span class="k">for</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="n">hostnamess</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">remove_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Inventory.remove_host"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.remove_host">[docs]</a> <span class="k">def</span> <span class="nf">remove_host</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">groupname</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;remove host</span>
<span class="sd"> if groupname is none, delete host</span>
<span class="sd"> if group name is not none, remove host from group</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">changed</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">if</span> <span class="n">groupname</span> <span class="ow">and</span> <span class="n">groupname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">groupname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="p">:</span>
<span class="k">return</span> <span class="n">changed</span>
<span class="n">changed</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="p">[</span><span class="n">hostname</span><span class="p">]</span>
<span class="n">groups</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_groups</span><span class="p">(</span><span class="n">host</span><span class="p">)</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="n">groups</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">groupname</span> <span class="ow">or</span> <span class="n">groupname</span> <span class="o">==</span> <span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
<span class="n">group</span><span class="o">.</span><span class="n">remove_host</span><span class="p">(</span><span class="n">host</span><span class="p">)</span>
<span class="n">host_vars</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_host_vars_dir</span><span class="p">(),</span> <span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">host_vars</span><span class="p">):</span>
<span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">host_vars</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">groupname</span><span class="p">:</span>
<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="p">[</span><span class="n">hostname</span><span class="p">]</span>
<span class="k">return</span> <span class="n">changed</span>
</div>
<div class="viewcode-block" id="Inventory.setup_hosts"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.setup_hosts">[docs]</a> <span class="k">def</span> <span class="nf">setup_hosts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hosts_info</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;setup multiple hosts</span>
<span class="sd"> hosts_info is a dict of format:</span>
<span class="sd"> {&#39;hostname1&#39;: {</span>
<span class="sd"> &#39;password&#39;: password</span>
<span class="sd"> &#39;uname&#39;: user_name</span>
<span class="sd"> }</span>
<span class="sd"> }</span>
<span class="sd"> The uname entry is optional.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">failed_hosts</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">host_info</span> <span class="ow">in</span> <span class="n">hosts_info</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">host</span><span class="p">:</span>
<span class="n">failed_hosts</span><span class="p">[</span><span class="n">hostname</span><span class="p">]</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s2">&quot;Host doesn&#39;t exist.&quot;</span><span class="p">)</span>
<span class="k">continue</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">host_info</span> <span class="ow">or</span> <span class="s1">&#39;password&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">host_info</span><span class="p">:</span>
<span class="n">failed_hosts</span><span class="p">[</span><span class="n">hostname</span><span class="p">]</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;No password in yml file.&#39;</span><span class="p">)</span>
<span class="k">continue</span>
<span class="n">passwd</span> <span class="o">=</span> <span class="n">host_info</span><span class="p">[</span><span class="s1">&#39;password&#39;</span><span class="p">]</span>
<span class="n">uname</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="s1">&#39;uname&#39;</span> <span class="ow">in</span> <span class="n">host_info</span><span class="p">:</span>
<span class="n">uname</span> <span class="o">=</span> <span class="n">host_info</span><span class="p">[</span><span class="s1">&#39;uname&#39;</span><span class="p">]</span>
<span class="k">try</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">setup_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">uname</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="n">failed_hosts</span><span class="p">[</span><span class="n">hostname</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">e</span>
<span class="k">if</span> <span class="n">failed_hosts</span><span class="p">:</span>
<span class="n">summary</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
<span class="k">for</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">err</span> <span class="ow">in</span> <span class="n">failed_hosts</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">summary</span> <span class="o">=</span> <span class="n">summary</span> <span class="o">+</span> <span class="s1">&#39;- </span><span class="si">%s</span><span class="s1">: </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">err</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">HostError</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;Not all hosts were set up. : {reasons}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">reasons</span><span class="o">=</span><span class="n">summary</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">_LI</span><span class="p">(</span><span class="s1">&#39;All hosts were successfully set up.&#39;</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="Inventory.setup_host"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.setup_host">[docs]</a> <span class="k">def</span> <span class="nf">setup_host</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">password</span><span class="p">,</span> <span class="n">uname</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span>
<span class="n">u</span><span class="o">.</span><span class="n">_LI</span><span class="p">(</span><span class="s1">&#39;Starting setup of host ({host}).&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="n">hostname</span><span class="p">))</span>
<span class="n">check_ok</span><span class="p">,</span> <span class="n">_</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ssh_check_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">check_ok</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">_LI</span><span class="p">(</span><span class="s1">&#39;Host ({host}) is already setup.&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="n">hostname</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># host needs setup</span>
<span class="n">ssh_setup_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">password</span><span class="p">,</span> <span class="n">uname</span><span class="p">)</span>
<span class="n">check_ok</span><span class="p">,</span> <span class="n">msg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ssh_check_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">check_ok</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</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;Post-setup ssh check failed. {err}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">err</span><span class="o">=</span><span class="n">msg</span><span class="p">))</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">_LI</span><span class="p">(</span><span class="s1">&#39;Host ({host}) setup succeeded.&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="n">hostname</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">HostError</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 ({host}) setup failed : {error}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="n">hostname</span><span class="p">,</span> <span class="n">error</span><span class="o">=</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">)))</span>
<span class="k">return</span> <span class="bp">True</span>
</div>
<div class="viewcode-block" id="Inventory.ssh_check_hosts"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.ssh_check_hosts">[docs]</a> <span class="k">def</span> <span class="nf">ssh_check_hosts</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="sd">&quot;&quot;&quot;ssh check for hosts</span>
<span class="sd"> return {hostname: {&#39;success&#39;: True|False,</span>
<span class="sd"> &#39;msg&#39;: message}}</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">summary</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="n">hostnames</span><span class="p">:</span>
<span class="n">is_ok</span><span class="p">,</span> <span class="n">msg</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">ssh_check_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="n">summary</span><span class="p">[</span><span class="n">hostname</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">summary</span><span class="p">[</span><span class="n">hostname</span><span class="p">][</span><span class="s1">&#39;success&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">is_ok</span>
<span class="n">summary</span><span class="p">[</span><span class="n">hostname</span><span class="p">][</span><span class="s1">&#39;msg&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">msg</span>
<span class="k">return</span> <span class="n">summary</span>
</div>
<div class="viewcode-block" id="Inventory.ssh_check_host"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.ssh_check_host">[docs]</a> <span class="k">def</span> <span class="nf">ssh_check_host</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostname</span><span class="p">):</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">run_ansible_command</span><span class="p">(</span><span class="s1">&#39;-m ping&#39;</span><span class="p">,</span> <span class="n">hostname</span><span class="p">)</span>
<span class="n">is_ok</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">if</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="n">is_ok</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">msg</span> <span class="o">=</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 ({host}) ssh check failed. : {error} {message}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="n">hostname</span><span class="p">,</span> <span class="n">error</span><span class="o">=</span><span class="n">err_msg</span><span class="p">,</span> <span class="n">message</span><span class="o">=</span><span class="n">output</span><span class="p">))</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="p">(</span><span class="n">u</span><span class="o">.</span><span class="n">_LI</span><span class="p">(</span><span class="s1">&#39;Host ({host}) ssh check succeeded.&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">host</span><span class="o">=</span><span class="n">hostname</span><span class="p">))</span>
<span class="k">return</span> <span class="n">is_ok</span><span class="p">,</span> <span class="n">msg</span>
</div>
<div class="viewcode-block" id="Inventory.run_ansible_command"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.run_ansible_command">[docs]</a> <span class="k">def</span> <span class="nf">run_ansible_command</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ansible_command</span><span class="p">,</span> <span class="n">hostname</span><span class="p">):</span>
<span class="n">output</span> <span class="o">=</span> <span class="bp">None</span>
<span class="n">command_string</span> <span class="o">=</span> <span class="s1">&#39;/usr/bin/sudo -u </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> -vvv&#39;</span> <span class="o">%</span> \
<span class="p">(</span><span class="n">get_admin_user</span><span class="p">(),</span> <span class="n">get_ansible_command</span><span class="p">())</span>
<span class="n">gen_file_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">create_json_gen_file</span><span class="p">()</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> -i </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">command_string</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">gen_file_path</span><span class="p">,</span>
<span class="n">ansible_command</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">run_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="bp">False</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="n">err_msg</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">)</span>
<span class="k">finally</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">remove_json_gen_file</span><span class="p">(</span><span class="n">gen_file_path</span><span class="p">)</span>
<span class="k">return</span> <span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span>
</div>
<div class="viewcode-block" id="Inventory.add_group"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.add_group">[docs]</a> <span class="k">def</span> <span class="nf">add_group</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">groupname</span><span class="p">):</span>
<span class="c1"># Group names cannot overlap with service names:</span>
<span class="k">if</span> <span class="n">groupname</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</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 group name. A service name &#39;</span>
<span class="s1">&#39;cannot be used for a group name.&#39;</span><span class="p">))</span>
<span class="k">if</span> <span class="n">groupname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">[</span><span class="n">groupname</span><span class="p">]</span> <span class="o">=</span> <span class="n">HostGroup</span><span class="p">(</span><span class="n">groupname</span><span class="p">)</span>
<span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">[</span><span class="n">groupname</span><span class="p">]</span>
<span class="n">group</span><span class="o">.</span><span class="n">set_remote</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">remote_mode</span><span class="p">)</span>
<span class="k">return</span> <span class="n">group</span>
</div>
<div class="viewcode-block" id="Inventory.remove_group"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.remove_group">[docs]</a> <span class="k">def</span> <span class="nf">remove_group</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">groupname</span><span class="p">):</span>
<span class="k">if</span> <span class="n">groupname</span> <span class="ow">in</span> <span class="n">PROTECTED_GROUPS</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;Cannot remove {group} group. It is required by kolla.&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">group</span><span class="o">=</span><span class="n">groupname</span><span class="p">))</span>
<span class="c1"># remove group from services</span>
<span class="k">for</span> <span class="n">service</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
<span class="n">service</span><span class="o">.</span><span class="n">remove_groupname</span><span class="p">(</span><span class="n">groupname</span><span class="p">)</span>
<span class="n">group_vars</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_group_vars_dir</span><span class="p">(),</span> <span class="n">groupname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">group_vars</span><span class="p">)</span> <span class="ow">and</span> <span class="n">groupname</span> <span class="o">!=</span> <span class="s1">&#39;__GLOBAL__&#39;</span><span class="p">:</span>
<span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">group_vars</span><span class="p">)</span>
<span class="k">if</span> <span class="n">groupname</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">:</span>
<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">[</span><span class="n">groupname</span><span class="p">]</span>
</div>
<div class="viewcode-block" id="Inventory.get_group"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_group">[docs]</a> <span class="k">def</span> <span class="nf">get_group</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">groupname</span><span class="p">):</span>
<span class="n">group</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="n">groupname</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">:</span>
<span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">[</span><span class="n">groupname</span><span class="p">]</span>
<span class="k">return</span> <span class="n">group</span>
</div>
<div class="viewcode-block" id="Inventory.get_groupnames"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_groupnames">[docs]</a> <span class="k">def</span> <span class="nf">get_groupnames</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">return</span> <span class="nb">list</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
</div>
<div class="viewcode-block" id="Inventory.get_groups"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_groups">[docs]</a> <span class="k">def</span> <span class="nf">get_groups</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">host</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;return all groups containing host</span>
<span class="sd"> if hosts is none, return all groups in inventory</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">groups</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">host</span><span class="p">:</span>
<span class="n">groups</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="o">.</span><span class="n">values</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
<span class="k">if</span> <span class="n">host</span><span class="o">.</span><span class="n">name</span> <span class="ow">in</span> <span class="n">group</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">():</span>
<span class="n">groups</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">group</span><span class="p">)</span>
<span class="k">return</span> <span class="n">groups</span>
</div>
<div class="viewcode-block" id="Inventory.get_host_groups"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_host_groups">[docs]</a> <span class="k">def</span> <span class="nf">get_host_groups</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;return { hostname : [groupnames] }&quot;&quot;&quot;</span>
<span class="n">host_groups</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">host</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
<span class="n">host_groups</span><span class="p">[</span><span class="n">host</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">groups</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_groups</span><span class="p">(</span><span class="n">host</span><span class="p">)</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="n">groups</span><span class="p">:</span>
<span class="n">host_groups</span><span class="p">[</span><span class="n">host</span><span class="o">.</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="k">return</span> <span class="n">host_groups</span>
</div>
<div class="viewcode-block" id="Inventory.get_group_services"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_group_services">[docs]</a> <span class="k">def</span> <span class="nf">get_group_services</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;get groups and their services</span>
<span class="sd"> return { groupname: [servicenames] }</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">group_services</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_groups</span><span class="p">():</span>
<span class="n">group_services</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">svc</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_services</span><span class="p">():</span>
<span class="k">for</span> <span class="n">groupname</span> <span class="ow">in</span> <span class="n">svc</span><span class="o">.</span><span class="n">get_groupnames</span><span class="p">():</span>
<span class="n">group_services</span><span class="p">[</span><span class="n">groupname</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">svc</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="k">return</span> <span class="n">group_services</span>
</div>
<div class="viewcode-block" id="Inventory.get_group_hosts"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_group_hosts">[docs]</a> <span class="k">def</span> <span class="nf">get_group_hosts</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;return { groupname : [hostnames] }&quot;&quot;&quot;</span>
<span class="n">group_hosts</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_groups</span><span class="p">():</span>
<span class="n">group_hosts</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="n">group</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">():</span>
<span class="n">group_hosts</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">return</span> <span class="n">group_hosts</span>
</div>
<div class="viewcode-block" id="Inventory.create_service"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.create_service">[docs]</a> <span class="k">def</span> <span class="nf">create_service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">servicename</span><span class="p">):</span>
<span class="k">if</span> <span class="n">servicename</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">:</span>
<span class="n">service</span> <span class="o">=</span> <span class="n">Service</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">[</span><span class="n">servicename</span><span class="p">]</span> <span class="o">=</span> <span class="n">service</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">[</span><span class="n">servicename</span><span class="p">]</span>
</div>
<div class="viewcode-block" id="Inventory.delete_service"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.delete_service">[docs]</a> <span class="k">def</span> <span class="nf">delete_service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">servicename</span><span class="p">):</span>
<span class="c1"># remove references to this service from all parent / child services</span>
<span class="k">if</span> <span class="n">servicename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">:</span>
<span class="n">service</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">[</span><span class="n">servicename</span><span class="p">]</span>
<span class="k">for</span> <span class="n">parentname</span> <span class="ow">in</span> <span class="n">service</span><span class="o">.</span><span class="n">get_parentnames</span><span class="p">():</span>
<span class="n">parent</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">[</span><span class="n">parentname</span><span class="p">]</span>
<span class="n">parent</span><span class="o">.</span><span class="n">remove_childname</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="k">for</span> <span class="n">childname</span> <span class="ow">in</span> <span class="n">service</span><span class="o">.</span><span class="n">get_childnames</span><span class="p">():</span>
<span class="n">child</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">[</span><span class="n">childname</span><span class="p">]</span>
<span class="n">child</span><span class="o">.</span><span class="n">remove_parentname</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="c1"># then remove the service itself</span>
<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">[</span><span class="n">servicename</span><span class="p">]</span>
</div>
<div class="viewcode-block" id="Inventory.get_services"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_services">[docs]</a> <span class="k">def</span> <span class="nf">get_services</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">client_filter</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="k">if</span> <span class="n">client_filter</span><span class="p">:</span>
<span class="n">services</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client_filtered_service_dict</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">services</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span>
<span class="k">return</span> <span class="n">services</span><span class="o">.</span><span class="n">values</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="Inventory.get_service"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_service">[docs]</a> <span class="k">def</span> <span class="nf">get_service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">servicename</span><span class="p">,</span> <span class="n">client_filter</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="n">service</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="n">client_filter</span><span class="p">:</span>
<span class="n">services</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client_filtered_service_dict</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">services</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span>
<span class="k">if</span> <span class="n">servicename</span> <span class="ow">in</span> <span class="n">services</span><span class="p">:</span>
<span class="n">service</span> <span class="o">=</span> <span class="n">services</span><span class="p">[</span><span class="n">servicename</span><span class="p">]</span>
<span class="k">return</span> <span class="n">service</span>
</div>
<div class="viewcode-block" id="Inventory.add_group_to_service"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.add_group_to_service">[docs]</a> <span class="k">def</span> <span class="nf">add_group_to_service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">groupname</span><span class="p">,</span> <span class="n">servicename</span><span class="p">):</span>
<span class="k">if</span> <span class="n">groupname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">groupname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">servicename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">:</span>
<span class="n">service</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_service</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="n">service</span><span class="o">.</span><span class="n">add_groupname</span><span class="p">(</span><span class="n">groupname</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">servicename</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Inventory.remove_group_from_service"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.remove_group_from_service">[docs]</a> <span class="k">def</span> <span class="nf">remove_group_from_service</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">groupname</span><span class="p">,</span> <span class="n">servicename</span><span class="p">):</span>
<span class="k">if</span> <span class="n">groupname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">groupname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">servicename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">:</span>
<span class="n">service</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_service</span><span class="p">(</span><span class="n">servicename</span><span class="p">)</span>
<span class="n">service</span><span class="o">.</span><span class="n">remove_groupname</span><span class="p">(</span><span class="n">groupname</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">servicename</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Inventory.set_deploy_mode"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.set_deploy_mode">[docs]</a> <span class="k">def</span> <span class="nf">set_deploy_mode</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">remote_flag</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">remote_flag</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">InvalidConfiguration</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;Cannot set local deploy mode when multiple hosts exist.&#39;</span><span class="p">))</span>
<span class="bp">self</span><span class="o">.</span><span class="n">remote_mode</span> <span class="o">=</span> <span class="n">remote_flag</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_groups</span><span class="p">():</span>
<span class="n">group</span><span class="o">.</span><span class="n">set_remote</span><span class="p">(</span><span class="n">remote_flag</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Inventory.get_ansible_json"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.get_ansible_json">[docs]</a> <span class="k">def</span> <span class="nf">get_ansible_json</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inventory_filter</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;generate json inventory for ansible</span>
<span class="sd"> The hosts and groups added to the json output for ansible will be</span>
<span class="sd"> filtered by the hostnames and groupnames in the deploy filters.</span>
<span class="sd"> This allows a more targeted deploy to a specific set of hosts or</span>
<span class="sd"> groups.</span>
<span class="sd"> typical ansible json format:</span>
<span class="sd"> {</span>
<span class="sd"> &#39;group&#39;: {</span>
<span class="sd"> &#39;hosts&#39;: [</span>
<span class="sd"> &#39;192.168.28.71&#39;,</span>
<span class="sd"> &#39;192.168.28.72&#39;</span>
<span class="sd"> ],</span>
<span class="sd"> &#39;vars&#39;: {</span>
<span class="sd"> &#39;ansible_ssh_user&#39;: &#39;johndoe&#39;,</span>
<span class="sd"> &#39;ansible_ssh_private_key_file&#39;: &#39;~/.ssh/mykey&#39;,</span>
<span class="sd"> &#39;example_variable&#39;: &#39;value&#39;</span>
<span class="sd"> }</span>
<span class="sd"> &#39;children&#39;: [ &#39;marietta&#39;, &#39;5points&#39; ]</span>
<span class="sd"> },</span>
<span class="sd"> &#39;_meta&#39;: {</span>
<span class="sd"> &#39;hostvars&#39;: {</span>
<span class="sd"> &#39;192.168.28.71&#39;: {</span>
<span class="sd"> &#39;host_specific_var&#39;: &#39;bar&#39;</span>
<span class="sd"> },</span>
<span class="sd"> &#39;192.168.28.72&#39;: {</span>
<span class="sd"> &#39;host_specific_var&#39;: &#39;foo&#39;</span>
<span class="sd"> }</span>
<span class="sd"> }</span>
<span class="sd"> }</span>
<span class="sd"> }</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">jdict</span> <span class="o">=</span> <span class="p">{}</span>
<span class="c1"># if no filter provided, use all groups, all hosts</span>
<span class="n">deploy_hostnames</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">()</span>
<span class="n">deploy_groupnames</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_groupnames</span><span class="p">()</span>
<span class="k">if</span> <span class="n">inventory_filter</span><span class="p">:</span>
<span class="k">if</span> <span class="s1">&#39;deploy_hosts&#39;</span> <span class="ow">in</span> <span class="n">inventory_filter</span><span class="p">:</span>
<span class="n">deploy_hostnames</span> <span class="o">=</span> <span class="n">inventory_filter</span><span class="p">[</span><span class="s1">&#39;deploy_hosts&#39;</span><span class="p">]</span>
<span class="k">if</span> <span class="s1">&#39;deploy_groups&#39;</span> <span class="ow">in</span> <span class="n">inventory_filter</span><span class="p">:</span>
<span class="n">deploy_groupnames</span> <span class="o">=</span> <span class="n">inventory_filter</span><span class="p">[</span><span class="s1">&#39;deploy_groups&#39;</span><span class="p">]</span>
<span class="c1"># add hostgroups</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_groups</span><span class="p">():</span>
<span class="n">jdict</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">jdict</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s1">&#39;hosts&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">group</span><span class="o">.</span><span class="n">name</span> <span class="ow">in</span> <span class="n">deploy_groupnames</span><span class="p">:</span>
<span class="n">jdict</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s1">&#39;hosts&#39;</span><span class="p">]</span> <span class="o">=</span> \
<span class="bp">self</span><span class="o">.</span><span class="n">_filter_hosts</span><span class="p">(</span><span class="n">group</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">(),</span> <span class="n">deploy_hostnames</span><span class="p">)</span>
<span class="n">jdict</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s1">&#39;children&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">jdict</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s1">&#39;vars&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">group</span><span class="o">.</span><span class="n">get_vars</span><span class="p">()</span>
<span class="c1"># add all services, what groups they are in and their parents</span>
<span class="k">for</span> <span class="n">service</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_services</span><span class="p">():</span>
<span class="n">jdict</span><span class="p">[</span><span class="n">service</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">groups_and_parents</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">groups_and_parents</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">service</span><span class="o">.</span><span class="n">get_groupnames</span><span class="p">())</span>
<span class="n">groups_and_parents</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">service</span><span class="o">.</span><span class="n">get_parentnames</span><span class="p">())</span>
<span class="n">jdict</span><span class="p">[</span><span class="n">service</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s1">&#39;children&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">groups_and_parents</span>
<span class="c1"># temporarily create group containing all hosts. this is needed for</span>
<span class="c1"># ansible commands that are performed on hosts not yet in groups.</span>
<span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">add_group</span><span class="p">(</span><span class="s1">&#39;__GLOBAL__&#39;</span><span class="p">)</span>
<span class="n">jdict</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">jdict</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s1">&#39;hosts&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">deploy_hostnames</span>
<span class="n">jdict</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">][</span><span class="s1">&#39;vars&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">group</span><span class="o">.</span><span class="n">get_vars</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">remove_group</span><span class="p">(</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="c1"># process hosts vars</span>
<span class="n">jdict</span><span class="p">[</span><span class="s1">&#39;_meta&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
<span class="n">jdict</span><span class="p">[</span><span class="s1">&#39;_meta&#39;</span><span class="p">][</span><span class="s1">&#39;hostvars&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="n">deploy_hostnames</span><span class="p">:</span>
<span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_host</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">host</span><span class="p">:</span>
<span class="n">jdict</span><span class="p">[</span><span class="s1">&#39;_meta&#39;</span><span class="p">][</span><span class="s1">&#39;hostvars&#39;</span><span class="p">][</span><span class="n">hostname</span><span class="p">]</span> <span class="o">=</span> <span class="n">host</span><span class="o">.</span><span class="n">get_vars</span><span class="p">()</span>
<span class="k">return</span> <span class="n">json</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">jdict</span><span class="p">)</span>
</div>
<span class="k">def</span> <span class="nf">_filter_hosts</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">initial_hostnames</span><span class="p">,</span> <span class="n">deploy_hostnames</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;filter out hosts not in deploy hosts</span>
<span class="sd"> Must preserve the ordering of hosts in the group.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">filtered_hostnames</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="n">initial_hostnames</span><span class="p">:</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="n">deploy_hostnames</span><span class="p">:</span>
<span class="n">filtered_hostnames</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">return</span> <span class="n">filtered_hostnames</span>
<div class="viewcode-block" id="Inventory.create_json_gen_file"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.create_json_gen_file">[docs]</a> <span class="k">def</span> <span class="nf">create_json_gen_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">inventory_filter</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;create json inventory file using filter ({})</span>
<span class="sd"> The inventory will be placed in a directory in /tmp,</span>
<span class="sd"> with the directory name of form kolla_uuid.py,</span>
<span class="sd"> where uuid is a unique deployment id.</span>
<span class="sd"> return path to filtered json generator file</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">json_out</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_ansible_json</span><span class="p">(</span><span class="n">inventory_filter</span><span class="p">)</span>
<span class="n">deploy_id</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">uuid</span><span class="o">.</span><span class="n">uuid4</span><span class="p">())</span>
<span class="n">dirname</span> <span class="o">=</span> <span class="s1">&#39;kolla_</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">deploy_id</span>
<span class="n">dirpath</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">tempfile</span><span class="o">.</span><span class="n">gettempdir</span><span class="p">(),</span> <span class="n">dirname</span><span class="p">)</span>
<span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">dirpath</span><span class="p">,</span> <span class="mi">0</span><span class="n">o775</span><span class="p">)</span>
<span class="n">_</span><span class="p">,</span> <span class="n">gid</span> <span class="o">=</span> <span class="n">get_admin_uids</span><span class="p">()</span>
<span class="n">os</span><span class="o">.</span><span class="n">chown</span><span class="p">(</span><span class="n">dirpath</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">gid</span><span class="p">)</span> <span class="c1"># nosec</span>
<span class="n">json_gen_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">dirpath</span><span class="p">,</span> <span class="s1">&#39;temp_inventory.py&#39;</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">json_gen_path</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">json_gen_file</span><span class="p">:</span>
<span class="n">json_gen_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;#!/usr/bin/env python</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="c1"># the quotes here are significant. The json_out has double quotes</span>
<span class="c1"># embedded in it so single quotes are needed to wrap it.</span>
<span class="n">json_gen_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s2">&quot;print(&#39;</span><span class="si">%s</span><span class="s2">&#39;)&quot;</span> <span class="o">%</span> <span class="n">json_out</span><span class="p">)</span>
<span class="c1"># set executable by group</span>
<span class="n">os</span><span class="o">.</span><span class="n">chmod</span><span class="p">(</span><span class="n">json_gen_path</span><span class="p">,</span> <span class="mi">0</span><span class="n">o555</span><span class="p">)</span> <span class="c1"># nosec</span>
<span class="k">return</span> <span class="n">json_gen_path</span>
</div>
<div class="viewcode-block" id="Inventory.remove_json_gen_file"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.remove_json_gen_file">[docs]</a> <span class="k">def</span> <span class="nf">remove_json_gen_file</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">path</span><span class="p">):</span>
<span class="n">remove_temp_inventory</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Inventory.validate_hostnames"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.validate_hostnames">[docs]</a> <span class="k">def</span> <span class="nf">validate_hostnames</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="k">if</span> <span class="ow">not</span> <span class="n">hostnames</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">MissingArgument</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 name(s)&#39;</span><span class="p">))</span>
<span class="n">invalid_hosts</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">hostname</span> <span class="ow">in</span> <span class="n">hostnames</span><span class="p">:</span>
<span class="k">if</span> <span class="n">hostname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span><span class="p">:</span>
<span class="n">invalid_hosts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">invalid_hosts</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">invalid_hosts</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Inventory.validate_groupnames"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.validate_groupnames">[docs]</a> <span class="k">def</span> <span class="nf">validate_groupnames</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">groupnames</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">groupnames</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">MissingArgument</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 name(s)&#39;</span><span class="p">))</span>
<span class="n">invalid_groups</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">groupname</span> <span class="ow">in</span> <span class="n">groupnames</span><span class="p">:</span>
<span class="k">if</span> <span class="n">groupname</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_groups</span><span class="p">:</span>
<span class="n">invalid_groups</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">groupname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">invalid_groups</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">invalid_groups</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Inventory.validate_servicenames"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.inventory.Inventory.validate_servicenames">[docs]</a> <span class="k">def</span> <span class="nf">validate_servicenames</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">servicenames</span><span class="p">,</span> <span class="n">client_filter</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">servicenames</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">MissingArgument</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 name(s)&#39;</span><span class="p">))</span>
<span class="n">invalid_services</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">client_filter</span><span class="p">:</span>
<span class="n">services</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_client_filtered_service_dict</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">services</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span>
<span class="k">for</span> <span class="n">service_name</span> <span class="ow">in</span> <span class="n">servicenames</span><span class="p">:</span>
<span class="k">if</span> <span class="n">service_name</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">services</span><span class="p">:</span>
<span class="n">invalid_services</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">service_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">invalid_services</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">invalid_services</span><span class="p">)</span>
</div>
<span class="k">def</span> <span class="nf">_client_filtered_service_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Filters out any unsupported services</span>
<span class="sd"> :return: filtered dictionary</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">filtered_service_dict</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">service</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
<span class="k">if</span> <span class="n">service</span><span class="o">.</span><span class="n">is_supported</span><span class="p">():</span>
<span class="n">filtered_service_dict</span><span class="p">[</span><span class="n">service</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">service</span>
<span class="k">return</span> <span class="n">filtered_service_dict</span>
<span class="k">def</span> <span class="nf">_create_default_inventory</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">allin1</span> <span class="o">=</span> <span class="n">AllInOne</span><span class="p">()</span>
<span class="k">for</span> <span class="n">groupname</span> <span class="ow">in</span> <span class="n">allin1</span><span class="o">.</span><span class="n">groups</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">add_group</span><span class="p">(</span><span class="n">groupname</span><span class="p">)</span>
<span class="k">for</span> <span class="n">servicename</span><span class="p">,</span> <span class="n">service</span> <span class="ow">in</span> <span class="n">allin1</span><span class="o">.</span><span class="n">services</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_services</span><span class="p">[</span><span class="n">servicename</span><span class="p">]</span> <span class="o">=</span> <span class="n">service</span></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 4.0.1.dev498 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>

View File

@ -1,199 +0,0 @@
<!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.common.passwords &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.common.passwords</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">os</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">FailedOperation</span>
<span class="kn">from</span> <span class="nn">kollacli.common</span> <span class="kn">import</span> <span class="n">utils</span>
<span class="n">PWDS_FILENAME</span> <span class="o">=</span> <span class="s1">&#39;passwords.yml&#39;</span>
<div class="viewcode-block" id="set_password"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.passwords.set_password">[docs]</a><span class="k">def</span> <span class="nf">set_password</span><span class="p">(</span><span class="n">pwd_key</span><span class="p">,</span> <span class="n">pwd_value</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;set a password value</span>
<span class="sd"> If the password name exists, it will be changed.</span>
<span class="sd"> If it doesn&#39;t exist, a new password will be added.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">value_switch</span> <span class="o">=</span> <span class="s1">&#39;-v&#39;</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">pwd_value</span><span class="p">:</span>
<span class="n">pwd_value</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">value_switch</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> -k </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">_get_cmd_prefix</span><span class="p">(),</span> <span class="n">pwd_key</span><span class="p">,</span> <span class="n">value_switch</span><span class="p">,</span>
<span class="n">pwd_value</span><span class="p">)</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">run_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">print_output</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="k">if</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">FailedOperation</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;Password set failed. {error} {message}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">error</span><span class="o">=</span><span class="n">err_msg</span><span class="p">,</span> <span class="n">message</span><span class="o">=</span><span class="n">output</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="set_password_sshkey"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.passwords.set_password_sshkey">[docs]</a><span class="k">def</span> <span class="nf">set_password_sshkey</span><span class="p">(</span><span class="n">pwd_key</span><span class="p">,</span> <span class="n">private_key</span><span class="p">,</span> <span class="n">public_key</span><span class="p">):</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> -k </span><span class="si">%s</span><span class="s1"> -r &quot;</span><span class="si">%s</span><span class="s1">&quot; -u &quot;</span><span class="si">%s</span><span class="s1">&quot;&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">_get_cmd_prefix</span><span class="p">(),</span> <span class="n">pwd_key</span><span class="p">,</span>
<span class="n">private_key</span><span class="p">,</span> <span class="n">public_key</span><span class="p">)</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">run_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">print_output</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="k">if</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">FailedOperation</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;Password ssh key set failed. {error} {message}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">error</span><span class="o">=</span><span class="n">err_msg</span><span class="p">,</span> <span class="n">message</span><span class="o">=</span><span class="n">output</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="clear_password"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.passwords.clear_password">[docs]</a><span class="k">def</span> <span class="nf">clear_password</span><span class="p">(</span><span class="n">pwd_key</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;clear a password</span>
<span class="sd"> if the password exists, it will be removed from the passwords file</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> -k </span><span class="si">%s</span><span class="s1"> -c&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">_get_cmd_prefix</span><span class="p">(),</span> <span class="n">pwd_key</span><span class="p">)</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">run_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">print_output</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="k">if</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">FailedOperation</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="get_password_names"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.passwords.get_password_names">[docs]</a><span class="k">def</span> <span class="nf">get_password_names</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;return a list of password names&quot;&quot;&quot;</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> -l&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">_get_cmd_prefix</span><span class="p">())</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">run_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">print_output</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="k">if</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">FailedOperation</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span><span class="p">))</span>
<span class="n">pwd_names</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">output</span> <span class="ow">and</span> <span class="s1">&#39;,&#39;</span> <span class="ow">in</span> <span class="n">output</span><span class="p">:</span>
<span class="n">pwd_names</span> <span class="o">=</span> <span class="n">output</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">pwd_names</span>
</div>
<div class="viewcode-block" id="get_empty_password_values"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.passwords.get_empty_password_values">[docs]</a><span class="k">def</span> <span class="nf">get_empty_password_values</span><span class="p">():</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> -e&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">_get_cmd_prefix</span><span class="p">())</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">run_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">print_output</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="c1"># output of this command is a comma separated string of password keys</span>
<span class="c1"># that have empty values.</span>
<span class="k">if</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">FailedOperation</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span><span class="p">))</span>
<span class="n">empty_keys</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">output</span><span class="p">:</span>
<span class="c1"># password keys exist that have no values</span>
<span class="n">empty_keys</span> <span class="o">=</span> <span class="n">output</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;,&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">empty_keys</span>
</div>
<div class="viewcode-block" id="init_passwords"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.passwords.init_passwords">[docs]</a><span class="k">def</span> <span class="nf">init_passwords</span><span class="p">():</span>
<span class="c1"># init empty passwords &amp; ssh keys to auto-gen&#39;d values</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> -i&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">_get_cmd_prefix</span><span class="p">())</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">run_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">print_output</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="k">if</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">FailedOperation</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span><span class="p">))</span>
</div>
<span class="k">def</span> <span class="nf">_get_cmd_prefix</span><span class="p">():</span>
<span class="n">actions_path</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_kolla_actions_path</span><span class="p">()</span>
<span class="n">pwd_file_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">utils</span><span class="o">.</span><span class="n">get_kolla_etc</span><span class="p">(),</span>
<span class="n">PWDS_FILENAME</span><span class="p">)</span>
<span class="n">user</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">get_admin_user</span><span class="p">()</span>
<span class="n">prefix</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;/usr/bin/sudo -u </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1"> password -p </span><span class="si">%s</span><span class="s1"> &#39;</span>
<span class="o">%</span> <span class="p">(</span><span class="n">user</span><span class="p">,</span> <span class="n">actions_path</span><span class="p">,</span> <span class="n">pwd_file_path</span><span class="p">))</span>
<span class="k">return</span> <span class="n">prefix</span>
</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 4.0.1.dev498 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>

View File

@ -1,456 +0,0 @@
<!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.common.properties &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.common.properties</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">copy</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">yaml</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">NotInInventory</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">change_property</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_group_vars_dir</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_host_vars_dir</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_ansible_home</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">sync_read_file</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<span class="n">ALLVARS_PATH</span> <span class="o">=</span> <span class="s1">&#39;ansible/group_vars/all.yml&#39;</span>
<span class="n">GLOBALS_PATH</span> <span class="o">=</span> <span class="s1">&#39;ansible/group_vars/__GLOBAL__&#39;</span>
<span class="n">ANSIBLE_ROLES_PATH</span> <span class="o">=</span> <span class="s1">&#39;ansible/roles&#39;</span>
<span class="n">ANSIBLE_DEFAULTS_PATH</span> <span class="o">=</span> <span class="s1">&#39;defaults/main.yml&#39;</span>
<div class="viewcode-block" id="AnsibleProperties"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties">[docs]</a><span class="k">class</span> <span class="nc">AnsibleProperties</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;initialize ansible property information</span>
<span class="sd"> property information is pulled from the following files</span>
<span class="sd"> (from lowest to highest priority):</span>
<span class="sd"> KOLLA_HOME/ansible/roles/&lt;service&gt;/default/main.yml</span>
<span class="sd"> KOLLA_HOME/ansible/group_vars/all.yml</span>
<span class="sd"> KOLLA_HOME/ansible/group_vars/__GLOBAL__</span>
<span class="sd"> KOLLA_HOME/ansible/group_vars/*</span>
<span class="sd"> KOLLA_HOME/ansible/host_vars/*</span>
<span class="sd"> KOLLA_ETC/passwords.yml</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">globals_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_ansible_home</span><span class="p">(),</span> <span class="n">GLOBALS_PATH</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">global_props</span> <span class="o">=</span> <span class="p">[]</span>
<span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span> <span class="o">=</span> <span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">unique_override_flags</span> <span class="o">=</span> <span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">group_props</span> <span class="o">=</span> <span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">host_props</span> <span class="o">=</span> <span class="p">{}</span>
<span class="bp">self</span><span class="o">.</span><span class="n">properties_loaded</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">def</span> <span class="nf">_load_properties</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_inventory</span><span class="p">()</span>
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">properties_loaded</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_properties_roles</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_properties_all</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_properties_global</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_properties_hostvars</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_properties_groupvars</span><span class="p">()</span>
<span class="bp">self</span><span class="o">.</span><span class="n">properties_loaded</span> <span class="o">=</span> <span class="bp">True</span>
<span class="k">def</span> <span class="nf">_load_properties_roles</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">start_dir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_ansible_home</span><span class="p">(),</span> <span class="n">ANSIBLE_ROLES_PATH</span><span class="p">)</span>
<span class="n">services</span> <span class="o">=</span> <span class="nb">next</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">walk</span><span class="p">(</span><span class="n">start_dir</span><span class="p">))[</span><span class="mi">1</span><span class="p">]</span>
<span class="k">for</span> <span class="n">service_name</span> <span class="ow">in</span> <span class="n">services</span><span class="p">:</span>
<span class="n">file_name</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">start_dir</span><span class="p">,</span> <span class="n">service_name</span><span class="p">,</span>
<span class="n">ANSIBLE_DEFAULTS_PATH</span><span class="p">)</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">file_name</span><span class="p">):</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">file_name</span><span class="p">)</span> <span class="k">as</span> <span class="n">service_file</span><span class="p">:</span>
<span class="n">service_contents</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_load</span><span class="p">(</span><span class="n">service_file</span><span class="p">)</span>
<span class="n">prop_file_name</span> <span class="o">=</span> <span class="n">service_name</span> <span class="o">+</span> <span class="s1">&#39;:main.yml&#39;</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">service_contents</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">ansible_prop</span> <span class="o">=</span> <span class="n">AnsibleProperty</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span>
<span class="n">prop_file_name</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">global_props</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ansible_prop</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">ansible_prop</span>
<span class="k">def</span> <span class="nf">_load_properties_all</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">allvars_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_ansible_home</span><span class="p">(),</span> <span class="n">ALLVARS_PATH</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">allvars_path</span><span class="p">)</span> <span class="k">as</span> <span class="n">allvars_file</span><span class="p">:</span>
<span class="n">allvars_contents</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_load</span><span class="p">(</span><span class="n">allvars_file</span><span class="p">)</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">allvars_contents</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">overrides</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">orig_value</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">:</span>
<span class="n">overrides</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">orig_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">[</span><span class="n">key</span><span class="p">]</span><span class="o">.</span><span class="n">value</span>
<span class="n">ansible_prop</span> <span class="o">=</span> <span class="n">AnsibleProperty</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span>
<span class="s1">&#39;group_vars/all.yml&#39;</span><span class="p">,</span>
<span class="n">overrides</span><span class="p">,</span> <span class="n">orig_value</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">global_props</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ansible_prop</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">ansible_prop</span>
<span class="k">def</span> <span class="nf">_load_properties_global</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">globals_data</span> <span class="o">=</span> <span class="n">sync_read_file</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">globals_path</span><span class="p">)</span>
<span class="n">globals_contents</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_load</span><span class="p">(</span><span class="n">globals_data</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">globals_contents</span><span class="p">:</span>
<span class="k">return</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">globals_contents</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">overrides</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">override_flags</span> <span class="o">=</span> <span class="n">OverrideFlags</span><span class="p">()</span>
<span class="n">orig_value</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">:</span>
<span class="n">overrides</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">override_flags</span><span class="o">.</span><span class="n">ovr_global</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">orig_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">[</span><span class="n">key</span><span class="p">]</span><span class="o">.</span><span class="n">value</span>
<span class="n">ansible_prop</span> <span class="o">=</span> <span class="n">AnsibleProperty</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span>
<span class="s1">&#39;group_vars/__GLOBAL&#39;</span><span class="p">,</span>
<span class="n">overrides</span><span class="p">,</span> <span class="n">orig_value</span><span class="p">)</span>
<span class="n">ansible_prop</span><span class="o">.</span><span class="n">override_flags</span> <span class="o">=</span> <span class="n">override_flags</span>
<span class="bp">self</span><span class="o">.</span><span class="n">global_props</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ansible_prop</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">ansible_prop</span>
<span class="bp">self</span><span class="o">.</span><span class="n">unique_override_flags</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">override_flags</span>
<span class="k">def</span> <span class="nf">_load_properties_hostvars</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">host_dir</span> <span class="o">=</span> <span class="n">get_host_vars_dir</span><span class="p">()</span>
<span class="n">hostnames</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_hostnames</span><span class="p">()</span>
<span class="k">for</span> <span class="n">hostfile</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">host_dir</span><span class="p">):</span>
<span class="k">if</span> <span class="n">hostfile</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">hostnames</span><span class="p">:</span>
<span class="c1"># skip any host files that don&#39;t match existing hosts</span>
<span class="k">continue</span>
<span class="bp">self</span><span class="o">.</span><span class="n">host_props</span><span class="p">[</span><span class="n">hostfile</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">host_dir</span><span class="p">,</span> <span class="n">hostfile</span><span class="p">))</span> <span class="k">as</span> <span class="n">host_data</span><span class="p">:</span>
<span class="n">host_contents</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_load</span><span class="p">(</span><span class="n">host_data</span><span class="p">)</span>
<span class="k">if</span> <span class="n">host_contents</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">continue</span>
<span class="n">props</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">host_contents</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">overrides</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">override_flags</span> <span class="o">=</span> <span class="n">OverrideFlags</span><span class="p">()</span>
<span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_override_flags</span><span class="p">:</span>
<span class="n">override_flags</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_override_flags</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
<span class="n">orig_value</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">:</span>
<span class="n">overrides</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">override_flags</span><span class="o">.</span><span class="n">ovr_host</span> <span class="o">=</span> <span class="bp">True</span>
<span class="bp">self</span><span class="o">.</span><span class="n">unique_override_flags</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">override_flags</span>
<span class="n">orig_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">[</span><span class="n">key</span><span class="p">]</span><span class="o">.</span><span class="n">value</span>
<span class="n">ansible_prop</span> <span class="o">=</span> <span class="n">AnsibleProperty</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span>
<span class="n">hostfile</span><span class="p">,</span>
<span class="n">overrides</span><span class="p">,</span> <span class="n">orig_value</span><span class="p">,</span>
<span class="s1">&#39;host&#39;</span><span class="p">,</span> <span class="n">hostfile</span><span class="p">)</span>
<span class="n">props</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ansible_prop</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">host_props</span><span class="p">[</span><span class="n">hostfile</span><span class="p">]</span> <span class="o">=</span> <span class="n">props</span>
<span class="k">def</span> <span class="nf">_load_properties_groupvars</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="n">group_dir</span> <span class="o">=</span> <span class="n">get_group_vars_dir</span><span class="p">()</span>
<span class="n">groupnames</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_groupnames</span><span class="p">()</span>
<span class="k">for</span> <span class="n">groupfile</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">group_dir</span><span class="p">):</span>
<span class="k">if</span> <span class="n">groupfile</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">groupnames</span><span class="p">:</span>
<span class="c1"># skip any files that don&#39;t match existing groups</span>
<span class="k">continue</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">group_dir</span><span class="p">,</span> <span class="n">groupfile</span><span class="p">))</span> <span class="k">as</span> <span class="n">group_data</span><span class="p">:</span>
<span class="n">group_contents</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_load</span><span class="p">(</span><span class="n">group_data</span><span class="p">)</span>
<span class="k">if</span> <span class="n">group_contents</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">continue</span>
<span class="n">props</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">group_contents</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">overrides</span> <span class="o">=</span> <span class="bp">False</span>
<span class="n">override_flags</span> <span class="o">=</span> <span class="n">OverrideFlags</span><span class="p">()</span>
<span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_override_flags</span><span class="p">:</span>
<span class="n">override_flags</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_override_flags</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
<span class="n">orig_value</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">:</span>
<span class="n">overrides</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">override_flags</span><span class="o">.</span><span class="n">ovr_group</span> <span class="o">=</span> <span class="bp">True</span>
<span class="bp">self</span><span class="o">.</span><span class="n">unique_override_flags</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">override_flags</span>
<span class="n">orig_value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">[</span><span class="n">key</span><span class="p">]</span><span class="o">.</span><span class="n">value</span>
<span class="n">ansible_prop</span> <span class="o">=</span> <span class="n">AnsibleProperty</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span>
<span class="n">groupfile</span><span class="p">,</span>
<span class="n">overrides</span><span class="p">,</span> <span class="n">orig_value</span><span class="p">,</span>
<span class="s1">&#39;group&#39;</span><span class="p">,</span> <span class="n">groupfile</span><span class="p">)</span>
<span class="n">props</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ansible_prop</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">group_props</span><span class="p">[</span><span class="n">groupfile</span><span class="p">]</span> <span class="o">=</span> <span class="n">props</span>
<span class="k">def</span> <span class="nf">_load_inventory</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</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="c1"># nosec</span>
<div class="viewcode-block" id="AnsibleProperties.get_host_list"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.get_host_list">[docs]</a> <span class="k">def</span> <span class="nf">get_host_list</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">host_list</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_properties</span><span class="p">()</span>
<span class="n">prop_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">host_list</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">for</span> <span class="n">host_name</span> <span class="ow">in</span> <span class="n">host_list</span><span class="p">:</span>
<span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_host</span><span class="p">(</span><span class="n">host_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">host</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">host_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">host_name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">host_props</span><span class="p">:</span>
<span class="n">prop_list</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">host_props</span><span class="p">[</span><span class="n">host_name</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">hosts</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_hosts</span><span class="p">()</span>
<span class="k">for</span> <span class="n">host</span> <span class="ow">in</span> <span class="n">hosts</span><span class="p">:</span>
<span class="k">if</span> <span class="n">host</span><span class="o">.</span><span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">host_props</span><span class="p">:</span>
<span class="n">prop_list</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">host_props</span><span class="p">[</span><span class="n">host</span><span class="o">.</span><span class="n">name</span><span class="p">]</span>
<span class="k">return</span> <span class="n">prop_list</span>
</div>
<div class="viewcode-block" id="AnsibleProperties.get_group_list"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.get_group_list">[docs]</a> <span class="k">def</span> <span class="nf">get_group_list</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">group_list</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_properties</span><span class="p">()</span>
<span class="n">prop_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">group_list</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">for</span> <span class="n">group_name</span> <span class="ow">in</span> <span class="n">group_list</span><span class="p">:</span>
<span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_group</span><span class="p">(</span><span class="n">group_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">group</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">group_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">group_name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_props</span><span class="p">:</span>
<span class="n">prop_list</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_props</span><span class="p">[</span><span class="n">group_name</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">groups</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_groups</span><span class="p">()</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="n">groups</span><span class="p">:</span>
<span class="k">if</span> <span class="n">group</span><span class="o">.</span><span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_props</span><span class="p">:</span>
<span class="n">prop_list</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">group_props</span><span class="p">[</span><span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">]</span>
<span class="k">return</span> <span class="n">prop_list</span>
</div>
<div class="viewcode-block" id="AnsibleProperties.get_property_value"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.get_property_value">[docs]</a> <span class="k">def</span> <span class="nf">get_property_value</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_name</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_properties</span><span class="p">()</span>
<span class="n">prop_val</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">if</span> <span class="n">property_name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">:</span>
<span class="n">prop</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="p">[</span><span class="n">property_name</span><span class="p">]</span>
<span class="n">prop_val</span> <span class="o">=</span> <span class="n">prop</span><span class="o">.</span><span class="n">value</span>
<span class="k">return</span> <span class="n">prop_val</span>
</div>
<div class="viewcode-block" id="AnsibleProperties.get_property"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.get_property">[docs]</a> <span class="k">def</span> <span class="nf">get_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_name</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_properties</span><span class="p">()</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">property_name</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="AnsibleProperties.get_all_unique"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.get_all_unique">[docs]</a> <span class="k">def</span> <span class="nf">get_all_unique</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_properties</span><span class="p">()</span>
<span class="n">unique_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_global_props</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">unique_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="k">return</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">unique_list</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="AnsibleProperties.get_all_override_flags"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.get_all_override_flags">[docs]</a> <span class="k">def</span> <span class="nf">get_all_override_flags</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_properties</span><span class="p">()</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">unique_override_flags</span>
</div>
<div class="viewcode-block" id="AnsibleProperties.set_property"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.set_property">[docs]</a> <span class="k">def</span> <span class="nf">set_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_dict</span><span class="p">):</span>
<span class="n">change_property</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">globals_path</span><span class="p">,</span> <span class="n">property_dict</span><span class="p">,</span>
<span class="n">clear</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="AnsibleProperties.set_host_property"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.set_host_property">[docs]</a> <span class="k">def</span> <span class="nf">set_host_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_dict</span><span class="p">,</span> <span class="n">hosts</span><span class="p">):</span>
<span class="c1"># if hosts is None set the property on all hosts</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_inventory</span><span class="p">()</span>
<span class="n">host_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">hosts</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">host_list</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_hosts</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">for</span> <span class="n">host_name</span> <span class="ow">in</span> <span class="n">hosts</span><span class="p">:</span>
<span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_host</span><span class="p">(</span><span class="n">host_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">host</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">host_name</span><span class="p">)</span>
<span class="n">host_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">host</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">for</span> <span class="n">host</span> <span class="ow">in</span> <span class="n">host_list</span><span class="p">:</span>
<span class="n">file_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_host_vars_dir</span><span class="p">(),</span> <span class="n">host</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="n">change_property</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="n">property_dict</span><span class="p">,</span>
<span class="n">clear</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">e</span>
</div>
<div class="viewcode-block" id="AnsibleProperties.set_group_property"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.set_group_property">[docs]</a> <span class="k">def</span> <span class="nf">set_group_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_dict</span><span class="p">,</span> <span class="n">groups</span><span class="p">):</span>
<span class="c1"># if groups is None set the property on all hosts</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_inventory</span><span class="p">()</span>
<span class="n">group_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">groups</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">group_list</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_groups</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">for</span> <span class="n">group_name</span> <span class="ow">in</span> <span class="n">groups</span><span class="p">:</span>
<span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_group</span><span class="p">(</span><span class="n">group_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">group</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">group_name</span><span class="p">)</span>
<span class="n">group_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">group</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="n">group_list</span><span class="p">:</span>
<span class="n">tmp_dict</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">property_dict</span><span class="p">)</span>
<span class="n">file_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_group_vars_dir</span><span class="p">(),</span> <span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="n">change_property</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="n">tmp_dict</span><span class="p">,</span>
<span class="n">clear</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">e</span>
</div>
<div class="viewcode-block" id="AnsibleProperties.clear_property"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.clear_property">[docs]</a> <span class="k">def</span> <span class="nf">clear_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_list</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">change_property</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">globals_path</span><span class="p">,</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_list_to_dict</span><span class="p">(</span><span class="n">property_list</span><span class="p">),</span>
<span class="n">clear</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">e</span>
</div>
<div class="viewcode-block" id="AnsibleProperties.clear_host_property"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.clear_host_property">[docs]</a> <span class="k">def</span> <span class="nf">clear_host_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_list</span><span class="p">,</span> <span class="n">hosts</span><span class="p">):</span>
<span class="c1"># if hosts is None set the property on all hosts</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_inventory</span><span class="p">()</span>
<span class="n">host_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">hosts</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">host_list</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_hosts</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">for</span> <span class="n">host_name</span> <span class="ow">in</span> <span class="n">hosts</span><span class="p">:</span>
<span class="n">host</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_host</span><span class="p">(</span><span class="n">host_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">host</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">host_name</span><span class="p">)</span>
<span class="n">host_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">host</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">for</span> <span class="n">host</span> <span class="ow">in</span> <span class="n">host_list</span><span class="p">:</span>
<span class="n">file_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_host_vars_dir</span><span class="p">(),</span> <span class="n">host</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="n">change_property</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_list_to_dict</span><span class="p">(</span><span class="n">property_list</span><span class="p">),</span>
<span class="n">clear</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">e</span>
</div>
<div class="viewcode-block" id="AnsibleProperties.clear_group_property"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperties.clear_group_property">[docs]</a> <span class="k">def</span> <span class="nf">clear_group_property</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_list</span><span class="p">,</span> <span class="n">groups</span><span class="p">):</span>
<span class="c1"># if hosts is None set the property on all hosts</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_load_inventory</span><span class="p">()</span>
<span class="n">group_list</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">if</span> <span class="n">groups</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">group_list</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_groups</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">for</span> <span class="n">group_name</span> <span class="ow">in</span> <span class="n">groups</span><span class="p">:</span>
<span class="n">group</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_inventory</span><span class="o">.</span><span class="n">get_group</span><span class="p">(</span><span class="n">group_name</span><span class="p">)</span>
<span class="k">if</span> <span class="n">group</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">NotInInventory</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&#39;</span><span class="p">),</span> <span class="n">group_name</span><span class="p">)</span>
<span class="n">group_list</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">group</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="n">group_list</span><span class="p">:</span>
<span class="n">file_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_group_vars_dir</span><span class="p">(),</span> <span class="n">group</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
<span class="n">change_property</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_list_to_dict</span><span class="p">(</span><span class="n">property_list</span><span class="p">),</span>
<span class="n">clear</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">e</span>
</div>
<span class="k">def</span> <span class="nf">_list_to_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">property_list</span><span class="p">):</span>
<span class="n">property_dict</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">property_list</span><span class="p">:</span>
<span class="n">property_dict</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="k">return</span> <span class="n">property_dict</span>
</div>
<div class="viewcode-block" id="AnsibleProperty"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.AnsibleProperty">[docs]</a><span class="k">class</span> <span class="nc">AnsibleProperty</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">file_name</span><span class="p">,</span> <span class="n">overrides</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
<span class="n">orig_value</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">prop_type</span><span class="o">=</span><span class="s1">&#39;global&#39;</span><span class="p">,</span> <span class="n">target</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">name</span>
<span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">value</span>
<span class="bp">self</span><span class="o">.</span><span class="n">prop_type</span> <span class="o">=</span> <span class="n">prop_type</span>
<span class="bp">self</span><span class="o">.</span><span class="n">file_name</span> <span class="o">=</span> <span class="n">file_name</span>
<span class="bp">self</span><span class="o">.</span><span class="n">overrides</span> <span class="o">=</span> <span class="n">overrides</span>
<span class="bp">self</span><span class="o">.</span><span class="n">orig_value</span> <span class="o">=</span> <span class="n">orig_value</span>
<span class="bp">self</span><span class="o">.</span><span class="n">target</span> <span class="o">=</span> <span class="n">target</span>
<span class="bp">self</span><span class="o">.</span><span class="n">value_type</span> <span class="o">=</span> <span class="nb">type</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="OverrideFlags"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.properties.OverrideFlags">[docs]</a><span class="k">class</span> <span class="nc">OverrideFlags</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">ovr_global</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">ovr_group</span> <span class="o">=</span> <span class="bp">False</span>
<span class="bp">self</span><span class="o">.</span><span class="n">ovr_host</span> <span class="o">=</span> <span class="bp">False</span></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 4.0.1.dev498 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>

View File

@ -1,187 +0,0 @@
<!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.common.sshutils &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.common.sshutils</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">logging</span>
<span class="kn">import</span> <span class="nn">os.path</span>
<span class="kn">import</span> <span class="nn">paramiko</span>
<span class="kn">import</span> <span class="nn">traceback</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_admin_user</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_cli_etc</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_setup_user</span>
<span class="kn">import</span> <span class="nn">kollacli.i18n</span> <span class="kn">as</span> <span class="nn">u</span>
<span class="n">MIN_DOCKER_VERSION</span> <span class="o">=</span> <span class="s1">&#39;1.8.1&#39;</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<div class="viewcode-block" id="ssh_connect"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.sshutils.ssh_connect">[docs]</a><span class="k">def</span> <span class="nf">ssh_connect</span><span class="p">(</span><span class="n">net_addr</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">password</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">ssh_client</span> <span class="o">=</span> <span class="n">paramiko</span><span class="o">.</span><span class="n">SSHClient</span><span class="p">()</span>
<span class="n">ssh_client</span><span class="o">.</span><span class="n">set_missing_host_key_policy</span><span class="p">(</span><span class="n">paramiko</span><span class="o">.</span><span class="n">AutoAddPolicy</span><span class="p">())</span>
<span class="n">ssh_client</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">hostname</span><span class="o">=</span><span class="n">net_addr</span><span class="p">,</span> <span class="n">username</span><span class="o">=</span><span class="n">username</span><span class="p">,</span>
<span class="n">password</span><span class="o">=</span><span class="n">password</span><span class="p">)</span>
<span class="k">return</span> <span class="n">ssh_client</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="n">_close_ssh_client</span><span class="p">(</span><span class="n">ssh_client</span><span class="p">)</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="n">traceback</span><span class="o">.</span><span class="n">format_exc</span><span class="p">())</span>
</div>
<div class="viewcode-block" id="ssh_setup_host"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.sshutils.ssh_setup_host">[docs]</a><span class="k">def</span> <span class="nf">ssh_setup_host</span><span class="p">(</span><span class="n">net_addr</span><span class="p">,</span> <span class="n">password</span><span class="p">,</span> <span class="n">setup_user</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
<span class="n">admin_user</span> <span class="o">=</span> <span class="n">get_admin_user</span><span class="p">()</span>
<span class="k">if</span> <span class="n">setup_user</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="n">setup_user</span> <span class="o">=</span> <span class="n">get_setup_user</span><span class="p">()</span>
<span class="n">public_key</span> <span class="o">=</span> <span class="n">ssh_get_public_key</span><span class="p">()</span>
<span class="n">ssh_client</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">ssh_client</span> <span class="o">=</span> <span class="n">ssh_connect</span><span class="p">(</span><span class="n">net_addr</span><span class="p">,</span> <span class="n">setup_user</span><span class="p">,</span> <span class="n">password</span><span class="p">)</span>
<span class="c1"># before modifying the host, check that it meets requirements</span>
<span class="c1"># TODO(bmace) pre / post checks should be done with ansible</span>
<span class="c1"># populate authorized keys file w/ public key</span>
<span class="n">key_dir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">expanduser</span><span class="p">(</span><span class="s1">&#39;~kolla&#39;</span><span class="p">),</span>
<span class="s1">&#39;.ssh&#39;</span><span class="p">,</span> <span class="s1">&#39;authorized_keys&#39;</span><span class="p">)</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;/usr/bin/sudo su - </span><span class="si">%s</span><span class="s1"> -c &quot;echo </span><span class="se">\&#39;</span><span class="si">%s</span><span class="se">\&#39;</span><span class="s1"> &gt;&gt; </span><span class="si">%s</span><span class="s1">&quot;&#39;</span>
<span class="o">%</span> <span class="p">(</span><span class="n">admin_user</span><span class="p">,</span> <span class="n">public_key</span><span class="p">,</span> <span class="n">key_dir</span><span class="p">))</span>
<span class="n">_exec_ssh_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">ssh_client</span><span class="p">)</span>
<span class="c1"># TODO(bmace) verify ssh connection to the new account</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">e</span>
<span class="k">finally</span><span class="p">:</span>
<span class="n">_close_ssh_client</span><span class="p">(</span><span class="n">ssh_client</span><span class="p">)</span>
</div>
<span class="k">def</span> <span class="nf">_close_ssh_client</span><span class="p">(</span><span class="n">ssh_client</span><span class="p">):</span>
<span class="k">if</span> <span class="n">ssh_client</span><span class="p">:</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">ssh_client</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span> <span class="c1"># nosec</span>
<span class="k">pass</span>
<span class="k">def</span> <span class="nf">_exec_ssh_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">ssh_client</span><span class="p">):</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="n">cmd</span><span class="p">)</span>
<span class="n">_</span><span class="p">,</span> <span class="n">stdout</span><span class="p">,</span> <span class="n">stderr</span> <span class="o">=</span> <span class="n">ssh_client</span><span class="o">.</span><span class="n">exec_command</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">get_pty</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> <span class="c1"># nosec</span>
<span class="n">msg</span> <span class="o">=</span> <span class="n">stdout</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="n">errmsg</span> <span class="o">=</span> <span class="n">stderr</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> : </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">msg</span><span class="p">,</span> <span class="n">errmsg</span><span class="p">))</span>
<span class="k">if</span> <span class="n">errmsg</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
<span class="n">u</span><span class="o">.</span><span class="n">_LW</span><span class="p">(</span><span class="s1">&#39;WARNING: command : {command})</span><span class="se">\n</span><span class="s1">message : {message}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">command</span><span class="o">=</span><span class="n">cmd</span><span class="p">,</span> <span class="n">message</span><span class="o">=</span><span class="n">errmsg</span><span class="o">.</span><span class="n">strip</span><span class="p">()))</span>
<span class="k">return</span> <span class="n">msg</span><span class="p">,</span> <span class="n">errmsg</span>
<div class="viewcode-block" id="ssh_get_public_key"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.sshutils.ssh_get_public_key">[docs]</a><span class="k">def</span> <span class="nf">ssh_get_public_key</span><span class="p">():</span>
<span class="n">keyfile_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_cli_etc</span><span class="p">(),</span> <span class="s1">&#39;id_rsa.pub&#39;</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">keyfile_path</span><span class="p">,</span> <span class="s2">&quot;r&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">public_key_file</span><span class="p">:</span>
<span class="n">public_key</span> <span class="o">=</span> <span class="n">public_key_file</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="k">return</span> <span class="n">public_key</span></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 4.0.1.dev498 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>

View File

@ -1,320 +0,0 @@
<!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.common.support &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.common.support</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">logging</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">tarfile</span>
<span class="kn">import</span> <span class="nn">tempfile</span>
<span class="kn">from</span> <span class="nn">kollacli.api.exceptions</span> <span class="kn">import</span> <span class="n">FailedOperation</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.properties</span> <span class="kn">import</span> <span class="n">AnsibleProperties</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_ansible_home</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_ansible_log_dir</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_cli_etc</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">run_cmd</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<div class="viewcode-block" id="HostLogs"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.support.HostLogs">[docs]</a><span class="k">class</span> <span class="nc">HostLogs</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">inventory</span><span class="p">,</span> <span class="n">servicenames</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">hostname</span> <span class="o">=</span> <span class="n">hostname</span>
<span class="bp">self</span><span class="o">.</span><span class="n">inventory</span> <span class="o">=</span> <span class="n">inventory</span>
<span class="bp">self</span><span class="o">.</span><span class="n">servicenames</span> <span class="o">=</span> <span class="n">servicenames</span>
<span class="bp">self</span><span class="o">.</span><span class="n">container_info</span> <span class="o">=</span> <span class="p">{}</span> <span class="c1"># container_id: container_img_name</span>
<span class="bp">self</span><span class="o">.</span><span class="n">filtered_servicenames</span> <span class="o">=</span> <span class="p">{}</span>
<div class="viewcode-block" id="HostLogs.load_container_info"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.support.HostLogs.load_container_info">[docs]</a> <span class="k">def</span> <span class="nf">load_container_info</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;get the list of containers on the host&quot;&quot;&quot;</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">hostname</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> \
<span class="bp">self</span><span class="o">.</span><span class="n">inventory</span><span class="o">.</span><span class="n">run_ansible_command</span><span class="p">(</span><span class="s1">&#39;-a &quot;docker ps -a&quot;&#39;</span><span class="p">,</span> <span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;Error accessing host </span><span class="si">%s</span><span class="s1"> : </span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">err_msg</span><span class="p">,</span>
<span class="n">output</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">FailedOperation</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">output</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;Host </span><span class="si">%s</span><span class="s1"> is not accessible.&#39;</span> <span class="o">%</span> <span class="n">hostname</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">FailedOperation</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="s1">&#39;&gt;&gt;&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">output</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;Host: </span><span class="si">%s</span><span class="s1">. Invalid ansible return data: [</span><span class="si">%s</span><span class="s1">].&#39;</span>
<span class="o">%</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">output</span><span class="p">))</span>
<span class="k">raise</span> <span class="n">FailedOperation</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">if</span> <span class="s1">&#39;NAMES&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">output</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;Host: </span><span class="si">%s</span><span class="s1">. Invalid docker ps return data: [</span><span class="si">%s</span><span class="s1">].&#39;</span>
<span class="o">%</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">output</span><span class="p">))</span>
<span class="k">raise</span> <span class="n">FailedOperation</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="n">ansible_properties</span> <span class="o">=</span> <span class="n">AnsibleProperties</span><span class="p">()</span>
<span class="n">base_distro</span> <span class="o">=</span> \
<span class="n">ansible_properties</span><span class="o">.</span><span class="n">get_property_value</span><span class="p">(</span><span class="s1">&#39;kolla_base_distro&#39;</span><span class="p">)</span>
<span class="n">install_type</span> <span class="o">=</span> \
<span class="n">ansible_properties</span><span class="o">.</span><span class="n">get_property_value</span><span class="p">(</span><span class="s1">&#39;kolla_install_type&#39;</span><span class="p">)</span>
<span class="c1"># typically this prefix will be &quot;ol-openstack-&quot;</span>
<span class="n">container_prefix</span> <span class="o">=</span> <span class="n">base_distro</span> <span class="o">+</span> <span class="s1">&#39;-&#39;</span> <span class="o">+</span> <span class="n">install_type</span> <span class="o">+</span> <span class="s1">&#39;-&#39;</span>
<span class="c1"># process ps output</span>
<span class="n">containers</span> <span class="o">=</span> <span class="p">{}</span>
<span class="c1"># the ps output is after the &#39;&gt;&gt;&#39;</span>
<span class="n">output</span> <span class="o">=</span> <span class="n">output</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;&gt;&gt;&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="s1">&#39;docker ps -a on host: </span><span class="si">%s</span><span class="s1">:</span><span class="se">\n</span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">output</span><span class="p">))</span>
<span class="n">lines</span> <span class="o">=</span> <span class="n">output</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span><span class="p">:</span>
<span class="n">tokens</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">tokens</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">2</span><span class="p">:</span>
<span class="k">continue</span>
<span class="n">cid</span> <span class="o">=</span> <span class="n">tokens</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">image</span> <span class="o">=</span> <span class="n">tokens</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="k">if</span> <span class="n">container_prefix</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">image</span><span class="p">:</span>
<span class="c1"># skip non-kolla containers</span>
<span class="k">continue</span>
<span class="n">name</span> <span class="o">=</span> <span class="n">image</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">container_prefix</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
<span class="n">name</span> <span class="o">=</span> <span class="n">name</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;:&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">containers</span><span class="p">[</span><span class="n">cid</span><span class="p">]</span> <span class="o">=</span> <span class="n">name</span>
<span class="bp">self</span><span class="o">.</span><span class="n">container_info</span> <span class="o">=</span> <span class="n">containers</span>
</div>
<div class="viewcode-block" id="HostLogs.get_log"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.support.HostLogs.get_log">[docs]</a> <span class="k">def</span> <span class="nf">get_log</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">container_id</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;read the container log&quot;&quot;&quot;</span>
<span class="n">hostname</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">hostname</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;-a &quot;docker logs </span><span class="si">%s</span><span class="s1">&quot;&#39;</span> <span class="o">%</span> <span class="n">container_id</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">inventory</span><span class="o">.</span><span class="n">run_ansible_command</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="s1">&#39;Error accessing host </span><span class="si">%s</span><span class="s1"> : </span><span class="si">%s</span><span class="s1"> &#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">err_msg</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">FailedOperation</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">output</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;Host </span><span class="si">%s</span><span class="s1"> is not accessible.&#39;</span> <span class="o">%</span> <span class="n">hostname</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">FailedOperation</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="k">if</span> <span class="s1">&#39;&gt;&gt;&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">output</span><span class="p">:</span>
<span class="n">msg</span> <span class="o">=</span> <span class="p">(</span><span class="s1">&#39;Host: </span><span class="si">%s</span><span class="s1">. Invalid ansible return data: [</span><span class="si">%s</span><span class="s1">].&#39;</span>
<span class="o">%</span> <span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">output</span><span class="p">))</span>
<span class="k">raise</span> <span class="n">FailedOperation</span><span class="p">(</span><span class="n">msg</span><span class="p">)</span>
<span class="c1"># the log info is after the &#39;&gt;&gt;&#39;</span>
<span class="n">output</span> <span class="o">=</span> <span class="n">output</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;&gt;&gt;&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
<span class="k">return</span> <span class="n">output</span>
</div>
<div class="viewcode-block" id="HostLogs.write_logs"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.support.HostLogs.write_logs">[docs]</a> <span class="k">def</span> <span class="nf">write_logs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dirname</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;write out the log files for all containers&quot;&quot;&quot;</span>
<span class="k">for</span> <span class="n">container_id</span><span class="p">,</span> <span class="n">container_name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">filtered_services</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">logdata</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_log</span><span class="p">(</span><span class="n">container_id</span><span class="p">)</span>
<span class="k">if</span> <span class="n">logdata</span><span class="p">:</span>
<span class="n">logname</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1">_</span><span class="si">%s</span><span class="s1">.log&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">container_name</span><span class="p">,</span> <span class="n">container_id</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">write_logfile</span><span class="p">(</span><span class="n">dirname</span><span class="p">,</span> <span class="n">logname</span><span class="p">,</span> <span class="n">logdata</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s1">&#39;No log data found for service </span><span class="si">%s</span><span class="s1"> on host </span><span class="si">%s</span><span class="s1">&#39;</span>
<span class="o">%</span> <span class="p">(</span><span class="n">container_name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">hostname</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="HostLogs.write_logfile"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.support.HostLogs.write_logfile">[docs]</a> <span class="k">def</span> <span class="nf">write_logfile</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">dirpath</span><span class="p">,</span> <span class="n">logname</span><span class="p">,</span> <span class="n">logdata</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;write out one log file&quot;&quot;&quot;</span>
<span class="n">hostdir</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">dirpath</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">hostname</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">hostdir</span><span class="p">):</span>
<span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">hostdir</span><span class="p">)</span>
<span class="n">fpath</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">hostdir</span><span class="p">,</span> <span class="n">logname</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">fpath</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">logfile</span><span class="p">:</span>
<span class="n">logfile</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">logdata</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="HostLogs.filter_services"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.support.HostLogs.filter_services">[docs]</a> <span class="k">def</span> <span class="nf">filter_services</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;filter services to only those of interest&quot;&quot;&quot;</span>
<span class="n">services_subset</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">host_svcid</span><span class="p">,</span> <span class="n">host_svcname</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">container_info</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="k">for</span> <span class="n">servicename</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">servicenames</span><span class="p">:</span>
<span class="k">if</span> <span class="p">(</span><span class="n">host_svcname</span> <span class="o">==</span> <span class="n">servicename</span> <span class="ow">or</span>
<span class="n">host_svcname</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="n">servicename</span> <span class="o">+</span> <span class="s1">&#39;-&#39;</span><span class="p">)):</span>
<span class="n">services_subset</span><span class="p">[</span><span class="n">host_svcid</span><span class="p">]</span> <span class="o">=</span> <span class="n">host_svcname</span>
<span class="bp">self</span><span class="o">.</span><span class="n">filtered_services</span> <span class="o">=</span> <span class="n">services_subset</span>
</div></div>
<div class="viewcode-block" id="get_logs"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.support.get_logs">[docs]</a><span class="k">def</span> <span class="nf">get_logs</span><span class="p">(</span><span class="n">servicenames</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">dirname</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">hostname</span><span class="p">])</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">validate_servicenames</span><span class="p">(</span><span class="n">servicenames</span><span class="p">,</span> <span class="n">client_filter</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="n">logs</span> <span class="o">=</span> <span class="n">HostLogs</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">inventory</span><span class="p">,</span> <span class="n">servicenames</span><span class="p">)</span>
<span class="n">logs</span><span class="o">.</span><span class="n">load_container_info</span><span class="p">()</span>
<span class="n">logs</span><span class="o">.</span><span class="n">filter_services</span><span class="p">()</span>
<span class="n">logs</span><span class="o">.</span><span class="n">write_logs</span><span class="p">(</span><span class="n">dirname</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="dump"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.support.dump">[docs]</a><span class="k">def</span> <span class="nf">dump</span><span class="p">(</span><span class="n">dirpath</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Dumps configuration data for debugging</span>
<span class="sd"> Dumps most files in /etc/kolla and /usr/share/kolla into a</span>
<span class="sd"> tar file so be given to support / development to help with</span>
<span class="sd"> debugging problems.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">kolla_home</span> <span class="o">=</span> <span class="n">get_kolla_ansible_home</span><span class="p">()</span>
<span class="n">kolla_logs</span> <span class="o">=</span> <span class="n">get_kolla_ansible_log_dir</span><span class="p">()</span>
<span class="n">kolla_ansible</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kolla_home</span><span class="p">,</span> <span class="s1">&#39;ansible&#39;</span><span class="p">)</span>
<span class="n">kollacli_etc</span> <span class="o">=</span> <span class="n">get_kolla_cli_etc</span><span class="p">()</span><span class="o">.</span><span class="n">rstrip</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">)</span>
<span class="n">ketc</span> <span class="o">=</span> <span class="s1">&#39;kolla/etc/&#39;</span>
<span class="n">kshare</span> <span class="o">=</span> <span class="s1">&#39;kolla/share/&#39;</span>
<span class="n">fd</span><span class="p">,</span> <span class="n">dump_path</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkstemp</span><span class="p">(</span><span class="nb">dir</span><span class="o">=</span><span class="n">dirpath</span><span class="p">,</span> <span class="n">prefix</span><span class="o">=</span><span class="s1">&#39;kollacli_dump_&#39;</span><span class="p">,</span>
<span class="n">suffix</span><span class="o">=</span><span class="s1">&#39;.tgz&#39;</span><span class="p">)</span>
<span class="n">os</span><span class="o">.</span><span class="n">close</span><span class="p">(</span><span class="n">fd</span><span class="p">)</span> <span class="c1"># avoid fd leak</span>
<span class="k">with</span> <span class="n">tarfile</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">dump_path</span><span class="p">,</span> <span class="s1">&#39;w:gz&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">tar</span><span class="p">:</span>
<span class="c1"># Can&#39;t blanket add kolla_home because the .ssh dir is</span>
<span class="c1"># accessible by the kolla user only (not kolla group)</span>
<span class="n">tar</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">kolla_ansible</span><span class="p">,</span>
<span class="n">arcname</span><span class="o">=</span><span class="n">kshare</span> <span class="o">+</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">kolla_ansible</span><span class="p">))</span>
<span class="c1"># Can&#39;t blanket add kolla_etc because the passwords.yml</span>
<span class="c1"># file is accessible by the kolla user only (not kolla group)</span>
<span class="n">tar</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">kollacli_etc</span><span class="p">,</span>
<span class="n">arcname</span><span class="o">=</span><span class="n">ketc</span> <span class="o">+</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">kollacli_etc</span><span class="p">))</span>
<span class="c1"># add kolla log files</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">kolla_logs</span><span class="p">):</span>
<span class="n">tar</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">kolla_logs</span><span class="p">)</span>
<span class="c1"># add output of various commands</span>
<span class="n">_add_cmd_info</span><span class="p">(</span><span class="n">tar</span><span class="p">)</span>
<span class="k">return</span> <span class="n">dump_path</span>
</div>
<span class="k">def</span> <span class="nf">_add_cmd_info</span><span class="p">(</span><span class="n">tar</span><span class="p">):</span>
<span class="c1"># run all the kollacli list commands</span>
<span class="n">cmds</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;kollacli --version&#39;</span><span class="p">,</span>
<span class="s1">&#39;kollacli service listgroups&#39;</span><span class="p">,</span>
<span class="s1">&#39;kollacli service list&#39;</span><span class="p">,</span>
<span class="s1">&#39;kollacli group listservices&#39;</span><span class="p">,</span>
<span class="s1">&#39;kollacli group listhosts&#39;</span><span class="p">,</span>
<span class="s1">&#39;kollacli host list&#39;</span><span class="p">,</span>
<span class="s1">&#39;kollacli property list&#39;</span><span class="p">,</span>
<span class="s1">&#39;kollacli password list&#39;</span><span class="p">]</span>
<span class="c1"># collect the json inventory output</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">inv_path</span> <span class="o">=</span> <span class="n">inventory</span><span class="o">.</span><span class="n">create_json_gen_file</span><span class="p">()</span>
<span class="n">cmds</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">inv_path</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">fd</span><span class="p">,</span> <span class="n">path</span> <span class="o">=</span> <span class="n">tempfile</span><span class="o">.</span><span class="n">mkstemp</span><span class="p">(</span><span class="n">suffix</span><span class="o">=</span><span class="s1">&#39;.tmp&#39;</span><span class="p">)</span>
<span class="n">os</span><span class="o">.</span><span class="n">close</span><span class="p">(</span><span class="n">fd</span><span class="p">)</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">tmp_file</span><span class="p">:</span>
<span class="k">for</span> <span class="n">cmd</span> <span class="ow">in</span> <span class="n">cmds</span><span class="p">:</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">run_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="bp">False</span><span class="p">)</span>
<span class="n">tmp_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n\n</span><span class="s1">$ </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">cmd</span><span class="p">)</span>
<span class="k">if</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="n">tmp_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s1">&#39;Error message: </span><span class="si">%s</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="n">err_msg</span><span class="p">)</span>
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">output</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">):</span>
<span class="n">tmp_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">line</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">tar</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">arcname</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s1">&#39;kolla&#39;</span><span class="p">,</span> <span class="s1">&#39;cmds_output&#39;</span><span class="p">))</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">raise</span> <span class="n">e</span>
<span class="k">finally</span><span class="p">:</span>
<span class="k">if</span> <span class="n">path</span><span class="p">:</span>
<span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
<span class="n">inventory</span><span class="o">.</span><span class="n">remove_json_gen_file</span><span class="p">(</span><span class="n">inv_path</span><span class="p">)</span>
<span class="k">return</span>
</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 4.0.1.dev498 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>

View File

@ -1,709 +0,0 @@
<!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.common.utils &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.common.utils</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright(c) 2017, 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">copy</span>
<span class="kn">import</span> <span class="nn">fcntl</span>
<span class="kn">import</span> <span class="nn">grp</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">pwd</span>
<span class="kn">import</span> <span class="nn">six</span>
<span class="kn">import</span> <span class="nn">subprocess</span> <span class="c1"># nosec</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">yaml</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.exceptions</span> <span class="kn">import</span> <span class="n">MissingArgument</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<div class="viewcode-block" id="get_log_level"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_log_level">[docs]</a><span class="k">def</span> <span class="nf">get_log_level</span><span class="p">():</span>
<span class="n">evar</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;KOLLA_LOG_LEVEL&#39;</span><span class="p">,</span> <span class="s1">&#39;info&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">evar</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;debug&#39;</span><span class="p">:</span>
<span class="n">level</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">DEBUG</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">level</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">INFO</span>
<span class="k">return</span> <span class="n">level</span>
</div>
<div class="viewcode-block" id="get_ansible_plugin_dir"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_ansible_plugin_dir">[docs]</a><span class="k">def</span> <span class="nf">get_ansible_plugin_dir</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;ANSIBLE_PLUGINS&quot;</span><span class="p">,</span>
<span class="s2">&quot;/usr/share/ansible/plugins/callback/&quot;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_ansible_etc"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_ansible_etc">[docs]</a><span class="k">def</span> <span class="nf">get_ansible_etc</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;ANSIBLE_ETC&quot;</span><span class="p">,</span>
<span class="s2">&quot;/etc/ansible/&quot;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_kolla_home"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_kolla_home">[docs]</a><span class="k">def</span> <span class="nf">get_kolla_ansible_home</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KOLLA_HOME&quot;</span><span class="p">,</span> <span class="s2">&quot;/usr/share/kolla/&quot;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_kolla_etc"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_kolla_etc">[docs]</a><span class="k">def</span> <span class="nf">get_kolla_etc</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KOLLA_ETC&quot;</span><span class="p">,</span> <span class="s2">&quot;/etc/kolla/&quot;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_kollacli_home"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_kollacli_home">[docs]</a><span class="k">def</span> <span class="nf">get_kolla_cli_home</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KOLLA_CLI_HOME&quot;</span><span class="p">,</span> <span class="s2">&quot;/usr/share/kolla/kollacli/&quot;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_kollacli_etc"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_kollacli_etc">[docs]</a><span class="k">def</span> <span class="nf">get_kolla_cli_etc</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KOLLA_CLI_ETC&quot;</span><span class="p">,</span> <span class="s2">&quot;/etc/kolla/kollacli/&quot;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_group_vars_dir"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_group_vars_dir">[docs]</a><span class="k">def</span> <span class="nf">get_group_vars_dir</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_ansible_home</span><span class="p">(),</span> <span class="s1">&#39;ansible/group_vars&#39;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_host_vars_dir"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_host_vars_dir">[docs]</a><span class="k">def</span> <span class="nf">get_host_vars_dir</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_ansible_home</span><span class="p">(),</span> <span class="s1">&#39;ansible/host_vars&#39;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_kolla_log_dir"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_kolla_log_dir">[docs]</a><span class="k">def</span> <span class="nf">get_kolla_ansible_log_dir</span><span class="p">():</span>
<span class="k">return</span> <span class="s1">&#39;/var/log/kolla/&#39;</span>
</div>
<div class="viewcode-block" id="get_ansible_lock_path"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_ansible_lock_path">[docs]</a><span class="k">def</span> <span class="nf">get_ansible_lock_path</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_cli_home</span><span class="p">(),</span> <span class="s1">&#39;ansible.lock&#39;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_kolla_actions_path"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_kolla_actions_path">[docs]</a><span class="k">def</span> <span class="nf">get_kolla_actions_path</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_cli_home</span><span class="p">(),</span> <span class="s1">&#39;tools&#39;</span><span class="p">,</span> <span class="s1">&#39;kolla_actions.py&#39;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_admin_uids"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_admin_uids">[docs]</a><span class="k">def</span> <span class="nf">get_admin_uids</span><span class="p">():</span>
<span class="sd">&quot;&quot;&quot;get uid and gid of admin user&quot;&quot;&quot;</span>
<span class="n">user_info</span> <span class="o">=</span> <span class="n">pwd</span><span class="o">.</span><span class="n">getpwnam</span><span class="p">(</span><span class="n">get_admin_user</span><span class="p">())</span>
<span class="n">uid</span> <span class="o">=</span> <span class="n">user_info</span><span class="o">.</span><span class="n">pw_uid</span>
<span class="n">gid</span> <span class="o">=</span> <span class="n">user_info</span><span class="o">.</span><span class="n">pw_gid</span>
<span class="k">return</span> <span class="n">uid</span><span class="p">,</span> <span class="n">gid</span>
</div>
<div class="viewcode-block" id="get_kolla_log_file_size"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_kolla_log_file_size">[docs]</a><span class="k">def</span> <span class="nf">get_kolla_log_file_size</span><span class="p">():</span>
<span class="n">envvar</span> <span class="o">=</span> <span class="s1">&#39;KOLLA_LOG_FILE_SIZE&#39;</span>
<span class="n">size_str</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">envvar</span><span class="p">,</span> <span class="s1">&#39;500000&#39;</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">size</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">size_str</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</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;Environmental variable ({env_var}) is not an &#39;</span>
<span class="s1">&#39;integer ({log_size}).&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">env_var</span><span class="o">=</span><span class="n">envvar</span><span class="p">,</span> <span class="n">log_size</span><span class="o">=</span><span class="n">size_str</span><span class="p">))</span>
<span class="k">return</span> <span class="n">size</span>
</div>
<div class="viewcode-block" id="get_property_list_length"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_property_list_length">[docs]</a><span class="k">def</span> <span class="nf">get_property_list_length</span><span class="p">():</span>
<span class="n">envvar</span> <span class="o">=</span> <span class="s1">&#39;KOLLA_PROP_LIST_LENGTH&#39;</span>
<span class="n">length_str</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">envvar</span><span class="p">,</span> <span class="s1">&#39;50&#39;</span><span class="p">)</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">length</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">length_str</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</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;Environmental variable ({env_var}) is not an &#39;</span>
<span class="s1">&#39;integer ({prop_length}).&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">env_var</span><span class="o">=</span><span class="n">envvar</span><span class="p">,</span> <span class="n">prop_length</span><span class="o">=</span><span class="n">length_str</span><span class="p">))</span>
<span class="k">return</span> <span class="n">length</span>
</div>
<div class="viewcode-block" id="get_admin_user"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_admin_user">[docs]</a><span class="k">def</span> <span class="nf">get_admin_user</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KOLLA_CLI_ADMIN_USER&quot;</span><span class="p">,</span> <span class="s2">&quot;kolla&quot;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_setup_user"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_setup_user">[docs]</a><span class="k">def</span> <span class="nf">get_setup_user</span><span class="p">():</span>
<span class="k">return</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;KOLLA_CLI_SETUP_USER&quot;</span><span class="p">,</span> <span class="s2">&quot;root&quot;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="get_lock_enabled"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_lock_enabled">[docs]</a><span class="k">def</span> <span class="nf">get_lock_enabled</span><span class="p">():</span>
<span class="n">evar</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">environ</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;KOLLA_CLI_LOCK&#39;</span><span class="p">,</span> <span class="s1">&#39;true&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="n">evar</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;false&#39;</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">False</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">True</span>
</div>
<div class="viewcode-block" id="get_ansible_command"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.get_ansible_command">[docs]</a><span class="k">def</span> <span class="nf">get_ansible_command</span><span class="p">(</span><span class="n">playbook</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;get a python2 ansible command</span>
<span class="sd"> Ansible cannot run yet with python3. If the current default</span>
<span class="sd"> python is py3, prefix the ansible command with a py2</span>
<span class="sd"> interpreter.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;ansible&#39;</span>
<span class="k">if</span> <span class="n">playbook</span><span class="p">:</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;ansible-playbook&#39;</span>
<span class="k">if</span> <span class="n">sys</span><span class="o">.</span><span class="n">version_info</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&gt;=</span> <span class="mi">3</span><span class="p">:</span>
<span class="c1"># running with py3, find a py2 interpreter for ansible</span>
<span class="n">py2_path</span> <span class="o">=</span> <span class="bp">None</span>
<span class="n">usr_bin</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="s1">&#39;/&#39;</span><span class="p">,</span> <span class="s1">&#39;usr&#39;</span><span class="p">,</span> <span class="s1">&#39;bin&#39;</span><span class="p">)</span>
<span class="k">for</span> <span class="n">fname</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">usr_bin</span><span class="p">):</span>
<span class="k">if</span> <span class="p">(</span><span class="n">fname</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s1">&#39;python2.&#39;</span><span class="p">)</span> <span class="ow">and</span>
<span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">usr_bin</span><span class="p">,</span> <span class="n">fname</span><span class="p">))):</span>
<span class="n">suffix</span> <span class="o">=</span> <span class="n">fname</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;.&#39;</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span>
<span class="k">if</span> <span class="n">suffix</span><span class="o">.</span><span class="n">isdigit</span><span class="p">():</span>
<span class="n">py2_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">usr_bin</span><span class="p">,</span> <span class="n">fname</span><span class="p">)</span>
<span class="k">break</span>
<span class="k">if</span> <span class="n">py2_path</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</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;ansible-playbook requires python2 and no &#39;</span>
<span class="s1">&#39;python2 interpreter found in {path}.&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">usr_bin</span><span class="p">))</span>
<span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1"> </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">py2_path</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">usr_bin</span><span class="p">,</span> <span class="n">cmd</span><span class="p">))</span>
<span class="k">return</span> <span class="n">cmd</span>
</div>
<div class="viewcode-block" id="convert_to_unicode"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.convert_to_unicode">[docs]</a><span class="k">def</span> <span class="nf">convert_to_unicode</span><span class="p">(</span><span class="n">the_string</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;convert string to unicode.</span>
<span class="sd"> This is used to fixup extended ascii chars in strings. these chars cause</span>
<span class="sd"> errors in json pickle/unpickle.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">the_string</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">return</span> <span class="n">the_string</span>
<span class="k">return</span> <span class="n">six</span><span class="o">.</span><span class="n">u</span><span class="p">(</span><span class="n">the_string</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="run_cmd"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.run_cmd">[docs]</a><span class="k">def</span> <span class="nf">run_cmd</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">print_output</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;run a system command</span>
<span class="sd"> return:</span>
<span class="sd"> - err_msg: empty string=command succeeded</span>
<span class="sd"> not None=command failed</span>
<span class="sd"> - output: string: all the output of the run command</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">err</span> <span class="o">=</span> <span class="bp">None</span>
<span class="n">output</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">process</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">(</span><span class="n">cmd</span><span class="p">,</span> <span class="n">shell</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="c1"># nosec</span>
<span class="n">stdout</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">,</span>
<span class="n">stderr</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">PIPE</span><span class="p">)</span>
<span class="n">output</span><span class="p">,</span> <span class="n">err</span> <span class="o">=</span> <span class="n">process</span><span class="o">.</span><span class="n">communicate</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="n">err</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">)</span>
<span class="n">err</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">err</span><span class="p">)</span>
<span class="n">output</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">output</span><span class="p">)</span>
<span class="k">if</span> <span class="n">process</span><span class="o">.</span><span class="n">returncode</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
<span class="n">err</span> <span class="o">=</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;Command failed. : {error}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">error</span><span class="o">=</span><span class="n">err</span><span class="p">))</span>
<span class="k">if</span> <span class="n">print_output</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">info</span><span class="p">(</span><span class="n">output</span><span class="p">)</span>
<span class="k">return</span> <span class="n">err</span><span class="p">,</span> <span class="n">output</span>
</div>
<div class="viewcode-block" id="change_password"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.change_password">[docs]</a><span class="k">def</span> <span class="nf">change_password</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="n">pname</span><span class="p">,</span> <span class="n">pvalue</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">public_key</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
<span class="n">private_key</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">clear</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;change password in passwords.yml file</span>
<span class="sd"> file_path: path to passwords file</span>
<span class="sd"> pname: name of password</span>
<span class="sd"> pvalue: value of password when not ssh key</span>
<span class="sd"> public_key: public ssh key</span>
<span class="sd"> private_key: private ssh key</span>
<span class="sd"> clear: flag to remove password</span>
<span class="sd"> If clear, and password exists, remove it from the password file.</span>
<span class="sd"> If clear, and password doesn&#39;t exists, nothing is done.</span>
<span class="sd"> If not clear, and key is not found, the new password will be added.</span>
<span class="sd"> If not clear, and key is found, edit password in place.</span>
<span class="sd"> The passwords file contains both key-value pairs and key-dictionary</span>
<span class="sd"> pairs.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">read_data</span> <span class="o">=</span> <span class="n">sync_read_file</span><span class="p">(</span><span class="n">file_path</span><span class="p">)</span>
<span class="n">file_pwds</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_load</span><span class="p">(</span><span class="n">read_data</span><span class="p">)</span>
<span class="k">if</span> <span class="n">clear</span><span class="p">:</span>
<span class="c1"># clear</span>
<span class="k">if</span> <span class="n">pname</span> <span class="ow">in</span> <span class="n">file_pwds</span><span class="p">:</span>
<span class="k">del</span> <span class="n">file_pwds</span><span class="p">[</span><span class="n">pname</span><span class="p">]</span>
<span class="k">else</span><span class="p">:</span>
<span class="c1"># edit</span>
<span class="k">if</span> <span class="n">private_key</span><span class="p">:</span>
<span class="n">file_pwds</span><span class="p">[</span><span class="n">pname</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;private_key&#39;</span><span class="p">:</span> <span class="n">private_key</span><span class="p">,</span>
<span class="s1">&#39;public_key&#39;</span><span class="p">:</span> <span class="n">public_key</span><span class="p">}</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">pvalue</span><span class="p">:</span>
<span class="n">pvalue</span> <span class="o">=</span> <span class="bp">None</span>
<span class="n">file_pwds</span><span class="p">[</span><span class="n">pname</span><span class="p">]</span> <span class="o">=</span> <span class="n">pvalue</span>
<span class="n">write_data</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_dump</span><span class="p">(</span><span class="n">file_pwds</span><span class="p">,</span> <span class="n">default_flow_style</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="n">sync_write_file</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="n">write_data</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="change_property"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.change_property">[docs]</a><span class="k">def</span> <span class="nf">change_property</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="n">property_dict</span><span class="p">,</span> <span class="n">clear</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;change property with a file</span>
<span class="sd"> file_path: path to property file</span>
<span class="sd"> property_dict: dictionary of property names and values</span>
<span class="sd"> clear: flag to remove property</span>
<span class="sd"> If clear, and property exists, remove it from the property file.</span>
<span class="sd"> If clear, and property doesn&#39;t exists, nothing is done.</span>
<span class="sd"> If not clear, and key is not found, the new property will be appended.</span>
<span class="sd"> If not clear, and key is found, edit property in place.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">cloned_dict</span> <span class="o">=</span> <span class="n">copy</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">property_dict</span><span class="p">)</span>
<span class="n">group_info</span> <span class="o">=</span> <span class="n">grp</span><span class="o">.</span><span class="n">getgrnam</span><span class="p">(</span><span class="s1">&#39;kolla&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">file_path</span><span class="p">):</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span><span class="p">):</span>
<span class="n">os</span><span class="o">.</span><span class="n">utime</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>
<span class="n">os</span><span class="o">.</span><span class="n">chown</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">group_info</span><span class="o">.</span><span class="n">gr_gid</span><span class="p">)</span>
<span class="n">new_contents</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">read_data</span> <span class="o">=</span> <span class="n">sync_read_file</span><span class="p">(</span><span class="n">file_path</span><span class="p">)</span>
<span class="n">lines</span> <span class="o">=</span> <span class="n">read_data</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="n">last_line_empty</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">lines</span><span class="p">:</span>
<span class="n">line</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">rstrip</span><span class="p">()</span>
<span class="c1"># yank spurious empty lines</span>
<span class="k">if</span> <span class="n">line</span><span class="p">:</span>
<span class="n">last_line_empty</span> <span class="o">=</span> <span class="bp">False</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">if</span> <span class="n">last_line_empty</span><span class="p">:</span>
<span class="k">continue</span>
<span class="n">last_line_empty</span> <span class="o">=</span> <span class="bp">True</span>
<span class="n">split_line</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;:&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">split_line</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="n">split_key</span> <span class="o">=</span> <span class="n">split_line</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="n">split_key</span><span class="o">.</span><span class="n">rstrip</span><span class="p">()</span>
<span class="k">if</span> <span class="n">split_key</span> <span class="ow">in</span> <span class="n">cloned_dict</span><span class="p">:</span>
<span class="k">if</span> <span class="n">clear</span><span class="p">:</span>
<span class="c1"># clear existing property</span>
<span class="k">continue</span>
<span class="c1"># edit existing property</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">cloned_dict</span><span class="p">[</span><span class="n">split_key</span><span class="p">]</span>
<span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="nb">str</span><span class="p">:</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_dump</span><span class="p">(</span><span class="n">value</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">line</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1">: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">split_key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">line</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1">: &quot;</span><span class="si">%s</span><span class="s1">&quot;&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">split_key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
<span class="c1"># clear out the key after we are done, all existing keys</span>
<span class="c1"># will be appended at the end (or for clear, ignored)</span>
<span class="k">del</span> <span class="n">cloned_dict</span><span class="p">[</span><span class="n">split_key</span><span class="p">]</span>
<span class="n">new_contents</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">clear</span><span class="p">:</span>
<span class="c1"># add new properties to file</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">cloned_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="k">if</span> <span class="nb">type</span><span class="p">(</span><span class="n">value</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="nb">str</span><span class="p">:</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">yaml</span><span class="o">.</span><span class="n">safe_dump</span><span class="p">(</span><span class="n">value</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="n">line</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1">: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">line</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="si">%s</span><span class="s1">: &quot;</span><span class="si">%s</span><span class="s1">&quot;&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
<span class="c1"># when we are doing an append we want to avoid</span>
<span class="c1"># blank lines before the new entry</span>
<span class="k">if</span> <span class="n">new_contents</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">:][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;&#39;</span><span class="p">:</span>
<span class="k">del</span> <span class="n">new_contents</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="n">new_contents</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
<span class="c1"># if the last line is blank, trim it off</span>
<span class="k">if</span> <span class="n">new_contents</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">:][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;&#39;</span><span class="p">:</span>
<span class="k">del</span> <span class="n">new_contents</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
<span class="n">write_data</span> <span class="o">=</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">new_contents</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span>
<span class="n">sync_write_file</span><span class="p">(</span><span class="n">file_path</span><span class="p">,</span> <span class="n">write_data</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="sync_read_file"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.sync_read_file">[docs]</a><span class="k">def</span> <span class="nf">sync_read_file</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s1">&#39;r&#39;</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;synchronously read file</span>
<span class="sd"> return file data</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">lock</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">if</span> <span class="n">get_lock_enabled</span><span class="p">():</span>
<span class="n">lock</span> <span class="o">=</span> <span class="n">Lock</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s1">&#39;sync_read&#39;</span><span class="p">)</span>
<span class="n">locked</span> <span class="o">=</span> <span class="n">lock</span><span class="o">.</span><span class="n">wait_acquire</span><span class="p">()</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">locked</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</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;unable to read file {path} &#39;</span>
<span class="s1">&#39;as it was locked.&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">path</span><span class="p">))</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">mode</span><span class="p">)</span> <span class="k">as</span> <span class="n">data_file</span><span class="p">:</span>
<span class="n">data</span> <span class="o">=</span> <span class="n">data_file</span><span class="o">.</span><span class="n">read</span><span class="p">()</span>
<span class="k">finally</span><span class="p">:</span>
<span class="k">if</span> <span class="n">lock</span><span class="p">:</span>
<span class="n">lock</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
<span class="k">return</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="sync_write_file"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.sync_write_file">[docs]</a><span class="k">def</span> <span class="nf">sync_write_file</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s1">&#39;w&#39;</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;synchronously write file&quot;&quot;&quot;</span>
<span class="n">ansible_lock</span> <span class="o">=</span> <span class="bp">None</span>
<span class="n">lock</span> <span class="o">=</span> <span class="bp">None</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">if</span> <span class="n">get_lock_enabled</span><span class="p">():</span>
<span class="n">ansible_lock</span> <span class="o">=</span> <span class="n">Lock</span><span class="p">(</span><span class="n">get_ansible_lock_path</span><span class="p">(),</span> <span class="s1">&#39;sync_write&#39;</span><span class="p">)</span>
<span class="n">locked</span> <span class="o">=</span> <span class="n">ansible_lock</span><span class="o">.</span><span class="n">wait_acquire</span><span class="p">()</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">locked</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</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;unable to get ansible lock while writing to {path} &#39;</span>
<span class="s1">&#39;as it was locked.&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">path</span><span class="p">))</span>
<span class="n">lock</span> <span class="o">=</span> <span class="n">Lock</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="s1">&#39;sync_write&#39;</span><span class="p">)</span>
<span class="n">locked</span> <span class="o">=</span> <span class="n">lock</span><span class="o">.</span><span class="n">wait_acquire</span><span class="p">()</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">locked</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</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;unable to write file {path} &#39;</span>
<span class="s1">&#39;as it was locked.&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">path</span><span class="o">=</span><span class="n">path</span><span class="p">))</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">mode</span><span class="p">)</span> <span class="k">as</span> <span class="n">data_file</span><span class="p">:</span>
<span class="n">data_file</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
<span class="k">finally</span><span class="p">:</span>
<span class="k">if</span> <span class="n">ansible_lock</span><span class="p">:</span>
<span class="n">ansible_lock</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
<span class="k">if</span> <span class="n">lock</span><span class="p">:</span>
<span class="n">lock</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="safe_decode"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.safe_decode">[docs]</a><span class="k">def</span> <span class="nf">safe_decode</span><span class="p">(</span><span class="n">obj_to_decode</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Convert bytes or strings to unicode string</span>
<span class="sd"> Converts strings, lists, or dictionaries to</span>
<span class="sd"> unicode.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">obj_to_decode</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">None</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">obj_to_decode</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
<span class="n">new_obj</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">text</span> <span class="ow">in</span> <span class="n">obj_to_decode</span><span class="p">:</span>
<span class="n">text</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
<span class="n">new_obj</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">text</span><span class="p">)</span>
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">obj_to_decode</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
<span class="n">new_obj</span> <span class="o">=</span> <span class="p">{}</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">obj_to_decode</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="n">key</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">key</span><span class="p">)</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">safe_decode</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
<span class="n">new_obj</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">new_obj</span> <span class="o">=</span> <span class="n">obj_to_decode</span>
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">obj_to_decode</span><span class="p">,</span> <span class="n">six</span><span class="o">.</span><span class="n">text_type</span><span class="p">):</span>
<span class="c1"># object is not unicode</span>
<span class="n">new_obj</span> <span class="o">=</span> <span class="n">obj_to_decode</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span>
<span class="k">return</span> <span class="n">new_obj</span>
</div>
<div class="viewcode-block" id="is_string_true"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.is_string_true">[docs]</a><span class="k">def</span> <span class="nf">is_string_true</span><span class="p">(</span><span class="n">string</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Return boolean True if string represents a true value (None is False)&quot;&quot;&quot;</span>
<span class="n">true_values</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;yes&#39;</span><span class="p">,</span> <span class="s1">&#39;true&#39;</span><span class="p">]</span>
<span class="k">if</span> <span class="n">string</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span> <span class="n">string</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="ow">in</span> <span class="n">true_values</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">True</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">False</span>
</div>
<div class="viewcode-block" id="convert_lists_to_string"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.convert_lists_to_string">[docs]</a><span class="k">def</span> <span class="nf">convert_lists_to_string</span><span class="p">(</span><span class="n">tuples</span><span class="p">,</span> <span class="n">parsed_args</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;convert lists to strings</span>
<span class="sd"> Because of the way cliff processes strings for tables, if a list</span>
<span class="sd"> has non-ascii chars in it, they would display as unicode bytes</span>
<span class="sd"> (\u0414\u0435\u043a\u0430\u0442). By converting</span>
<span class="sd"> the list to string here, the proper non-ascii chars are displayed.</span>
<span class="sd"> This will only change the lists when the output is to a user visible</span>
<span class="sd"> medium. It cannot be changed if the display output is json, yaml, etc.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">convert_types</span> <span class="o">=</span> <span class="p">[</span><span class="s1">&#39;table&#39;</span><span class="p">,</span> <span class="s1">&#39;csv&#39;</span><span class="p">,</span> <span class="s1">&#39;html&#39;</span><span class="p">,</span> <span class="s1">&#39;value&#39;</span><span class="p">]</span>
<span class="k">if</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">formatter</span> <span class="ow">and</span> <span class="n">parsed_args</span><span class="o">.</span><span class="n">formatter</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">convert_types</span><span class="p">:</span>
<span class="c1"># not table output, leave it as-is</span>
<span class="k">return</span> <span class="n">tuples</span>
<span class="n">new_tuples</span> <span class="o">=</span> <span class="p">[]</span>
<span class="k">for</span> <span class="n">data_tuple</span> <span class="ow">in</span> <span class="n">tuples</span><span class="p">:</span>
<span class="n">new_items</span> <span class="o">=</span> <span class="p">[]</span>
<span class="n">items</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">data_tuple</span><span class="p">)</span>
<span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">items</span><span class="p">:</span>
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
<span class="n">item</span> <span class="o">=</span> <span class="n">convert_list_to_string</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
<span class="n">new_items</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
<span class="n">data_tuple</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">new_items</span><span class="p">)</span>
<span class="n">new_tuples</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">data_tuple</span><span class="p">)</span>
<span class="k">return</span> <span class="n">new_tuples</span>
</div>
<div class="viewcode-block" id="convert_list_to_string"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.convert_list_to_string">[docs]</a><span class="k">def</span> <span class="nf">convert_list_to_string</span><span class="p">(</span><span class="n">alist</span><span class="p">):</span>
<span class="k">return</span> <span class="s1">&#39;[&#39;</span> <span class="o">+</span> <span class="s1">&#39;,&#39;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">alist</span><span class="p">)</span> <span class="o">+</span> <span class="s1">&#39;]&#39;</span>
</div>
<div class="viewcode-block" id="check_arg"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.check_arg">[docs]</a><span class="k">def</span> <span class="nf">check_arg</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">param_name</span><span class="p">,</span> <span class="n">expected_type</span><span class="p">,</span> <span class="n">none_ok</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">empty_ok</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
<span class="n">display_param</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
<span class="k">if</span> <span class="n">param</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">if</span> <span class="n">none_ok</span><span class="p">:</span>
<span class="k">return</span>
<span class="c1"># None arg</span>
<span class="k">raise</span> <span class="n">MissingArgument</span><span class="p">(</span><span class="n">param_name</span><span class="p">)</span>
<span class="k">if</span> <span class="p">((</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">six</span><span class="o">.</span><span class="n">string_types</span><span class="p">)</span> <span class="ow">or</span>
<span class="nb">isinstance</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="nb">dict</span><span class="p">)</span> <span class="ow">or</span>
<span class="nb">isinstance</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="nb">list</span><span class="p">))</span> <span class="ow">and</span>
<span class="ow">not</span> <span class="n">param</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">empty_ok</span><span class="p">):</span>
<span class="c1"># empty string, dict or list</span>
<span class="k">raise</span> <span class="n">MissingArgument</span><span class="p">(</span><span class="n">param_name</span><span class="p">)</span>
<span class="c1"># if expected type is None, skip the type checking</span>
<span class="k">if</span> <span class="n">expected_type</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
<span class="k">return</span>
<span class="c1"># normalize expected string types for py2 and py3</span>
<span class="k">if</span> <span class="n">expected_type</span> <span class="ow">is</span> <span class="nb">str</span><span class="p">:</span>
<span class="n">expected_type</span> <span class="o">=</span> <span class="n">six</span><span class="o">.</span><span class="n">string_types</span>
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">param</span><span class="p">,</span> <span class="n">expected_type</span><span class="p">):</span>
<span class="c1"># wrong type</span>
<span class="k">if</span> <span class="n">display_param</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;{name} ({param}) is not a {type}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">param_name</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="n">param</span><span class="p">,</span>
<span class="nb">type</span><span class="o">=</span><span class="n">expected_type</span><span class="p">))</span>
<span class="k">else</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;{name} is not a {type}&#39;</span><span class="p">)</span>
<span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">param_name</span><span class="p">,</span>
<span class="nb">type</span><span class="o">=</span><span class="n">expected_type</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="Lock"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.Lock">[docs]</a><span class="k">class</span> <span class="nc">Lock</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Object which represents an exclusive resource lock</span>
<span class="sd"> flock usage is the default behavior but a separate pidfile mechanism</span>
<span class="sd"> is also available. flock doesn&#39;t have the same orphaned lock issue</span>
<span class="sd"> that pidfile usage does. both need to be tests on NFS. if flock</span>
<span class="sd"> works then it seems better / less complicated for our needs.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lockpath</span><span class="p">,</span> <span class="n">owner</span><span class="o">=</span><span class="s1">&#39;unknown owner&#39;</span><span class="p">,</span> <span class="n">use_flock</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">lockpath</span> <span class="o">=</span> <span class="n">lockpath</span>
<span class="bp">self</span><span class="o">.</span><span class="n">pid</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">getpid</span><span class="p">())</span>
<span class="bp">self</span><span class="o">.</span><span class="n">fd</span> <span class="o">=</span> <span class="bp">None</span>
<span class="bp">self</span><span class="o">.</span><span class="n">owner</span> <span class="o">=</span> <span class="n">owner</span>
<span class="bp">self</span><span class="o">.</span><span class="n">current_pid</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
<span class="bp">self</span><span class="o">.</span><span class="n">current_owner</span> <span class="o">=</span> <span class="s1">&#39;&#39;</span>
<span class="bp">self</span><span class="o">.</span><span class="n">use_flock</span> <span class="o">=</span> <span class="n">use_flock</span>
<div class="viewcode-block" id="Lock.acquire"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.Lock.acquire">[docs]</a> <span class="k">def</span> <span class="nf">acquire</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">use_flock</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_acquire_flock</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_acquire_pidfile</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lockpath</span><span class="p">):</span>
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s1">&#39;Lock file (</span><span class="si">%s</span><span class="s1">) is missing&#39;</span>
<span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">lockpath</span><span class="p">)</span>
<span class="c1"># it is ok to fail to acquire, we just return that we failed</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;Exception in acquire lock. &#39;</span>
<span class="s1">&#39;path: </span><span class="si">%s</span><span class="s1"> pid: </span><span class="si">%s</span><span class="s1"> owner: </span><span class="si">%s</span><span class="s1"> error: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span>
<span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lockpath</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">pid</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">owner</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">)))</span>
</div>
<span class="k">def</span> <span class="nf">_acquire_pidfile</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_owned_by_me</span><span class="p">():</span>
<span class="n">fd</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lockpath</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">O_CREAT</span> <span class="o">|</span> <span class="n">os</span><span class="o">.</span><span class="n">O_EXCL</span> <span class="o">|</span> <span class="n">os</span><span class="o">.</span><span class="n">O_RDWR</span><span class="p">)</span>
<span class="k">with</span> <span class="n">os</span><span class="o">.</span><span class="n">fdopen</span><span class="p">(</span><span class="n">fd</span><span class="p">,</span> <span class="s1">&#39;a&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="n">f</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pid</span> <span class="o">+</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">owner</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_owned_by_me</span><span class="p">()</span>
<span class="k">def</span> <span class="nf">_acquire_flock</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="bp">self</span><span class="o">.</span><span class="n">fd</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lockpath</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">O_RDWR</span><span class="p">)</span>
<span class="n">fcntl</span><span class="o">.</span><span class="n">flock</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fd</span><span class="p">,</span> <span class="n">fcntl</span><span class="o">.</span><span class="n">LOCK_EX</span> <span class="o">|</span> <span class="n">fcntl</span><span class="o">.</span><span class="n">LOCK_NB</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">True</span>
<div class="viewcode-block" id="Lock.wait_acquire"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.Lock.wait_acquire">[docs]</a> <span class="k">def</span> <span class="nf">wait_acquire</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">wait_duration</span><span class="o">=</span><span class="mi">3</span><span class="p">,</span> <span class="n">interval</span><span class="o">=</span><span class="mf">0.1</span><span class="p">):</span>
<span class="n">wait_time</span> <span class="o">=</span> <span class="mi">0</span>
<span class="k">while</span> <span class="p">(</span><span class="n">wait_time</span> <span class="o">&lt;</span> <span class="n">wait_duration</span><span class="p">):</span>
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">acquire</span><span class="p">():</span>
<span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="n">interval</span><span class="p">)</span>
<span class="n">wait_time</span> <span class="o">+=</span> <span class="n">interval</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">True</span>
<span class="k">return</span> <span class="bp">False</span>
</div>
<div class="viewcode-block" id="Lock.is_owned_by_me"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.Lock.is_owned_by_me">[docs]</a> <span class="k">def</span> <span class="nf">is_owned_by_me</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Returns True if we own the lock or False otherwise&quot;&quot;&quot;</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">use_flock</span><span class="p">:</span>
<span class="k">raise</span> <span class="ne">Exception</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 use of is_owned_by_me while&#39;</span>
<span class="s1">&#39;using flock&#39;</span><span class="p">))</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lockpath</span><span class="p">):</span>
<span class="c1"># lock doesn&#39;t exist, just return</span>
<span class="k">return</span> <span class="bp">False</span>
<span class="n">fd</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lockpath</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">O_RDONLY</span><span class="p">)</span>
<span class="k">with</span> <span class="n">os</span><span class="o">.</span><span class="n">fdopen</span><span class="p">(</span><span class="n">fd</span><span class="p">,</span> <span class="s1">&#39;r&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
<span class="n">contents</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">2048</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">contents</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">current_pid</span> <span class="o">=</span> <span class="n">contents</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">contents</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">current_owner</span> <span class="o">=</span> <span class="n">contents</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
<span class="k">if</span> <span class="n">contents</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">pid</span><span class="p">):</span>
<span class="k">return</span> <span class="bp">True</span>
<span class="k">else</span><span class="p">:</span>
<span class="k">return</span> <span class="bp">False</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="c1"># it is ok to fail to acquire, we just return that we failed</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;Exception in is_owned_by_me lock check. &#39;</span>
<span class="s1">&#39;path: </span><span class="si">%s</span><span class="s1"> pid: </span><span class="si">%s</span><span class="s1"> owner: </span><span class="si">%s</span><span class="s1"> error: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span>
<span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lockpath</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">pid</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">owner</span><span class="p">,</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">)))</span>
<span class="k">return</span> <span class="bp">False</span>
</div>
<div class="viewcode-block" id="Lock.release"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.Lock.release">[docs]</a> <span class="k">def</span> <span class="nf">release</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">use_flock</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_release_flock</span><span class="p">()</span>
<span class="k">else</span><span class="p">:</span>
<span class="bp">self</span><span class="o">.</span><span class="n">_release_pidfile</span><span class="p">()</span>
<span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
<span class="c1"># this really shouldn&#39;t happen unless for some reason</span>
<span class="c1"># two areas in the same process try to release the lock</span>
<span class="c1"># at the same time and if that happens you want to see</span>
<span class="c1"># an error about it</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">error</span><span class="p">(</span><span class="s1">&#39;Error releasing lock&#39;</span><span class="p">,</span> <span class="n">exc_info</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">False</span>
</div>
<span class="k">def</span> <span class="nf">_release_pidfile</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_owned_by_me</span><span class="p">():</span>
<span class="n">os</span><span class="o">.</span><span class="n">remove</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lockpath</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">True</span>
<span class="k">def</span> <span class="nf">_release_flock</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="k">try</span><span class="p">:</span>
<span class="n">fcntl</span><span class="o">.</span><span class="n">flock</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fd</span><span class="p">,</span> <span class="n">fcntl</span><span class="o">.</span><span class="n">LOCK_UN</span><span class="p">)</span>
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
<span class="n">LOG</span><span class="o">.</span><span class="n">debug</span><span class="p">(</span><span class="s1">&#39;Exception while releasing lock: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
<span class="k">finally</span><span class="p">:</span>
<span class="n">os</span><span class="o">.</span><span class="n">close</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fd</span><span class="p">)</span>
<span class="k">return</span> <span class="bp">True</span>
</div>
<div class="viewcode-block" id="PidManager"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.PidManager">[docs]</a><span class="k">class</span> <span class="nc">PidManager</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="nd">@staticmethod</span>
<div class="viewcode-block" id="PidManager.get_child_pids"><a class="viewcode-back" href="../../../kollacli.common.html#kollacli.common.utils.PidManager.get_child_pids">[docs]</a> <span class="k">def</span> <span class="nf">get_child_pids</span><span class="p">(</span><span class="n">pid</span><span class="p">,</span> <span class="n">child_pids</span><span class="o">=</span><span class="p">[]):</span>
<span class="sd">&quot;&quot;&quot;get child pids of parent pid&quot;&quot;&quot;</span>
<span class="c1"># This ps command will return child pids of parent pid, separated by</span>
<span class="c1"># newlines.</span>
<span class="n">err_msg</span><span class="p">,</span> <span class="n">output</span> <span class="o">=</span> <span class="n">run_cmd</span><span class="p">(</span><span class="s1">&#39;ps --ppid </span><span class="si">%s</span><span class="s1"> -o pid=&quot;&quot;&#39;</span> <span class="o">%</span> <span class="n">pid</span><span class="p">,</span>
<span class="n">print_output</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
<span class="c1"># err_msg is expected when pid has no children</span>
<span class="k">if</span> <span class="ow">not</span> <span class="n">err_msg</span><span class="p">:</span>
<span class="n">output</span> <span class="o">=</span> <span class="n">output</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span>
<span class="k">if</span> <span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span> <span class="ow">in</span> <span class="n">output</span><span class="p">:</span>
<span class="n">ps_pids</span> <span class="o">=</span> <span class="n">output</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\n</span><span class="s1">&#39;</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">ps_pids</span> <span class="o">=</span> <span class="p">[</span><span class="n">output</span><span class="p">]</span>
<span class="k">if</span> <span class="n">ps_pids</span><span class="p">:</span>
<span class="n">child_pids</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">ps_pids</span><span class="p">)</span>
<span class="c1"># recurse through children to get all child pids</span>
<span class="k">for</span> <span class="n">ps_pid</span> <span class="ow">in</span> <span class="n">ps_pids</span><span class="p">:</span>
<span class="n">PidManager</span><span class="o">.</span><span class="n">get_child_pids</span><span class="p">(</span><span class="n">ps_pid</span><span class="p">,</span> <span class="n">child_pids</span><span class="p">)</span>
<span class="k">return</span> <span class="n">child_pids</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 4.0.1.dev498 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>

View File

@ -1,113 +0,0 @@
<!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.exceptions &mdash; kollacli 1.0.0.dev401 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.dev401',
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.dev401 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.dev401 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.exceptions</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="sd">&quot;&quot;&quot;Exception definitions.&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">kollacli.i18n</span> <span class="kn">as</span> <span class="nn">u</span>
<div class="viewcode-block" id="CommandError"><a class="viewcode-back" href="../../kollacli.html#kollacli.exceptions.CommandError">[docs]</a><span class="k">class</span> <span class="nc">CommandError</span><span class="p">(</span><span class="ne">Exception</span><span class="p">):</span>
<span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
<span class="n">message</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;ERROR: {message}&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">message</span><span class="o">=</span><span class="n">message</span><span class="p">)</span>
<span class="nb">super</span><span class="p">(</span><span class="n">CommandError</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="n">message</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">)</span></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.dev401 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>

View File

@ -1,158 +0,0 @@
<!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.shell &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 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 4.0.1.dev498 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.shell</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="sd">&quot;&quot;&quot;Command-line interface to Kolla&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">logging</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">sys</span>
<span class="kn">from</span> <span class="nn">cliff.app</span> <span class="kn">import</span> <span class="n">App</span>
<span class="kn">from</span> <span class="nn">cliff.commandmanager</span> <span class="kn">import</span> <span class="n">CommandManager</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.client</span> <span class="kn">import</span> <span class="n">ClientApi</span>
<span class="kn">from</span> <span class="nn">kollacli.commands.exceptions</span> <span class="kn">import</span> <span class="n">CommandError</span>
<span class="kn">from</span> <span class="nn">kollacli.common.inventory</span> <span class="kn">import</span> <span class="n">INVENTORY_PATH</span>
<span class="kn">from</span> <span class="nn">kollacli.common.utils</span> <span class="kn">import</span> <span class="n">get_kolla_cli_etc</span>
<span class="n">LOG</span> <span class="o">=</span> <span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="vm">__name__</span><span class="p">)</span>
<span class="n">VERSION</span> <span class="o">=</span> <span class="s1">&#39;4.0&#39;</span>
<div class="viewcode-block" id="KollaCli"><a class="viewcode-back" href="../../kollacli.html#kollacli.shell.KollaCli">[docs]</a><span class="k">class</span> <span class="nc">KollaCli</span><span class="p">(</span><span class="n">App</span><span class="p">):</span>
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="nb">super</span><span class="p">(</span><span class="n">KollaCli</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span>
<span class="n">description</span><span class="o">=</span><span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span><span class="s1">&#39;Command-Line Client for OpenStack Kolla&#39;</span><span class="p">),</span>
<span class="n">version</span><span class="o">=</span><span class="n">VERSION</span><span class="p">,</span>
<span class="n">command_manager</span><span class="o">=</span><span class="n">CommandManager</span><span class="p">(</span><span class="s1">&#39;kolla.cli&#39;</span><span class="p">),</span>
<span class="p">)</span>
<span class="n">inventory_path</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">get_kolla_cli_etc</span><span class="p">(),</span>
<span class="n">INVENTORY_PATH</span><span class="p">)</span>
<span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">inventory_path</span><span class="p">)</span> <span class="ow">is</span> <span class="bp">False</span><span class="p">:</span>
<span class="n">err_string</span> <span class="o">=</span> <span class="n">u</span><span class="o">.</span><span class="n">_</span><span class="p">(</span>
<span class="s1">&#39;Required file ({inventory}) does not exist.</span><span class="se">\n</span><span class="s1">&#39;</span>
<span class="s1">&#39;Please re-install the kollacli to &#39;</span>
<span class="s1">&#39;recreate the file.&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">inventory</span><span class="o">=</span><span class="n">inventory_path</span><span class="p">)</span>
<span class="k">raise</span> <span class="n">CommandError</span><span class="p">(</span><span class="n">err_string</span><span class="p">)</span>
<span class="c1"># set up logging and test that user running shell is part</span>
<span class="c1"># of kolla group</span>
<span class="n">ClientApi</span><span class="p">()</span>
<span class="c1"># paramiko log is very chatty, tune it down</span>
<span class="n">logging</span><span class="o">.</span><span class="n">getLogger</span><span class="p">(</span><span class="s1">&#39;paramiko&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">setLevel</span><span class="p">(</span><span class="n">logging</span><span class="o">.</span><span class="n">WARNING</span><span class="p">)</span>
<span class="bp">self</span><span class="o">.</span><span class="n">dump_stack_trace</span> <span class="o">=</span> <span class="bp">False</span>
</div>
<div class="viewcode-block" id="main"><a class="viewcode-back" href="../../kollacli.html#kollacli.shell.main">[docs]</a><span class="k">def</span> <span class="nf">main</span><span class="p">(</span><span class="n">argv</span><span class="o">=</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">:]):</span>
<span class="n">shell</span> <span class="o">=</span> <span class="n">KollaCli</span><span class="p">()</span>
<span class="k">return</span> <span class="n">shell</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">argv</span><span class="p">)</span>
</div>
<span class="k">if</span> <span class="vm">__name__</span> <span class="o">==</span> <span class="s2">&quot;__main__&quot;</span><span class="p">:</span>
<span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="n">main</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">:]))</span>
</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 4.0.1.dev498 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>

View File

@ -1,20 +0,0 @@
.. kollacli documentation master file, created by
sphinx-quickstart on Thu Mar 17 18:17:04 2016.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to kollacli's documentation!
====================================
Contents:
.. toctree::
:maxdepth: 2
Indices and tables
==================
* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

View File

@ -1,94 +0,0 @@
kollacli.api package
====================
Submodules
----------
kollacli.api.client module
--------------------------
.. automodule:: kollacli.api.client
:members:
:undoc-members:
:show-inheritance:
kollacli.api.control_plane module
---------------------------------
.. automodule:: kollacli.api.control_plane
:members:
:undoc-members:
:show-inheritance:
kollacli.api.exceptions module
------------------------------
.. automodule:: kollacli.api.exceptions
:members:
:undoc-members:
:show-inheritance:
kollacli.api.group module
-------------------------
.. automodule:: kollacli.api.group
:members:
:undoc-members:
:show-inheritance:
kollacli.api.host module
------------------------
.. automodule:: kollacli.api.host
:members:
:undoc-members:
:show-inheritance:
kollacli.api.job module
-----------------------
.. automodule:: kollacli.api.job
:members:
:undoc-members:
:show-inheritance:
kollacli.api.password module
----------------------------
.. automodule:: kollacli.api.password
:members:
:undoc-members:
:show-inheritance:
kollacli.api.properties module
------------------------------
.. automodule:: kollacli.api.properties
:members:
:undoc-members:
:show-inheritance:
kollacli.api.service module
---------------------------
.. automodule:: kollacli.api.service
:members:
:undoc-members:
:show-inheritance:
kollacli.api.support module
---------------------------
.. automodule:: kollacli.api.support
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: kollacli.api
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,102 +0,0 @@
kollacli.commands package
=========================
Submodules
----------
kollacli.commands.deploy module
-------------------------------
.. automodule:: kollacli.commands.deploy
:members:
:undoc-members:
:show-inheritance:
kollacli.commands.exceptions module
-----------------------------------
.. automodule:: kollacli.commands.exceptions
:members:
:undoc-members:
:show-inheritance:
kollacli.commands.group module
------------------------------
.. automodule:: kollacli.commands.group
:members:
:undoc-members:
:show-inheritance:
kollacli.commands.host module
-----------------------------
.. automodule:: kollacli.commands.host
:members:
:undoc-members:
:show-inheritance:
kollacli.commands.password module
---------------------------------
.. automodule:: kollacli.commands.password
:members:
:undoc-members:
:show-inheritance:
kollacli.commands.property module
---------------------------------
.. automodule:: kollacli.commands.property
:members:
:undoc-members:
:show-inheritance:
kollacli.commands.pull module
-----------------------------
.. automodule:: kollacli.commands.pull
:members:
:undoc-members:
:show-inheritance:
kollacli.commands.reconfigure module
------------------------------------
.. automodule:: kollacli.commands.reconfigure
:members:
:undoc-members:
:show-inheritance:
kollacli.commands.service module
--------------------------------
.. automodule:: kollacli.commands.service
:members:
:undoc-members:
:show-inheritance:
kollacli.commands.support module
--------------------------------
.. automodule:: kollacli.commands.support
:members:
:undoc-members:
:show-inheritance:
kollacli.commands.upgrade module
--------------------------------
.. automodule:: kollacli.commands.upgrade
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: kollacli.commands
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,38 +0,0 @@
kollacli.common.ansible package
===============================
Submodules
----------
kollacli.common.ansible.actions module
--------------------------------------
.. automodule:: kollacli.common.ansible.actions
:members:
:undoc-members:
:show-inheritance:
kollacli.common.ansible.job module
----------------------------------
.. automodule:: kollacli.common.ansible.job
:members:
:undoc-members:
:show-inheritance:
kollacli.common.ansible.playbook module
---------------------------------------
.. automodule:: kollacli.common.ansible.playbook
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: kollacli.common.ansible
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,109 +0,0 @@
kollacli.common package
=======================
Subpackages
-----------
.. toctree::
kollacli.common.ansible
Submodules
----------
kollacli.common.allinone module
-------------------------------
.. automodule:: kollacli.common.allinone
:members:
:undoc-members:
:show-inheritance:
kollacli.common.host module
---------------------------
.. automodule:: kollacli.common.host
:members:
:undoc-members:
:show-inheritance:
kollacli.common.host_group module
---------------------------------
.. automodule:: kollacli.common.host_group
:members:
:undoc-members:
:show-inheritance:
kollacli.common.inventory module
--------------------------------
.. automodule:: kollacli.common.inventory
:members:
:undoc-members:
:show-inheritance:
kollacli.common.passwords module
--------------------------------
.. automodule:: kollacli.common.passwords
:members:
:undoc-members:
:show-inheritance:
kollacli.common.properties module
---------------------------------
.. automodule:: kollacli.common.properties
:members:
:undoc-members:
:show-inheritance:
kollacli.common.service module
------------------------------
.. automodule:: kollacli.common.service
:members:
:undoc-members:
:show-inheritance:
kollacli.common.sshutils module
-------------------------------
.. automodule:: kollacli.common.sshutils
:members:
:undoc-members:
:show-inheritance:
kollacli.common.subservice module
---------------------------------
.. automodule:: kollacli.common.subservice
:members:
:undoc-members:
:show-inheritance:
kollacli.common.support module
------------------------------
.. automodule:: kollacli.common.support
:members:
:undoc-members:
:show-inheritance:
kollacli.common.utils module
----------------------------
.. automodule:: kollacli.common.utils
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: kollacli.common
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,39 +0,0 @@
kollacli package
================
Subpackages
-----------
.. toctree::
kollacli.api
kollacli.commands
kollacli.common
Submodules
----------
kollacli.i18n module
--------------------
.. automodule:: kollacli.i18n
:members:
:undoc-members:
:show-inheritance:
kollacli.shell module
---------------------
.. automodule:: kollacli.shell
:members:
:undoc-members:
:show-inheritance:
Module contents
---------------
.. automodule:: kollacli
:members:
:undoc-members:
:show-inheritance:

View File

@ -1,7 +0,0 @@
kollacli
========
.. toctree::
:maxdepth: 4
kollacli

Binary file not shown.

Before

Width:  |  Height:  |  Size: 673 B

View File

@ -1,537 +0,0 @@
/*
* basic.css
* ~~~~~~~~~
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/* -- main layout ----------------------------------------------------------- */
div.clearer {
clear: both;
}
/* -- relbar ---------------------------------------------------------------- */
div.related {
width: 100%;
font-size: 90%;
}
div.related h3 {
display: none;
}
div.related ul {
margin: 0;
padding: 0 0 0 10px;
list-style: none;
}
div.related li {
display: inline;
}
div.related li.right {
float: right;
margin-right: 5px;
}
/* -- sidebar --------------------------------------------------------------- */
div.sphinxsidebarwrapper {
padding: 10px 5px 0 10px;
}
div.sphinxsidebar {
float: left;
width: 230px;
margin-left: -100%;
font-size: 90%;
}
div.sphinxsidebar ul {
list-style: none;
}
div.sphinxsidebar ul ul,
div.sphinxsidebar ul.want-points {
margin-left: 20px;
list-style: square;
}
div.sphinxsidebar ul ul {
margin-top: 0;
margin-bottom: 0;
}
div.sphinxsidebar form {
margin-top: 10px;
}
div.sphinxsidebar input {
border: 1px solid #98dbcc;
font-family: sans-serif;
font-size: 1em;
}
div.sphinxsidebar #searchbox input[type="text"] {
width: 170px;
}
div.sphinxsidebar #searchbox input[type="submit"] {
width: 30px;
}
img {
border: 0;
max-width: 100%;
}
/* -- search page ----------------------------------------------------------- */
ul.search {
margin: 10px 0 0 20px;
padding: 0;
}
ul.search li {
padding: 5px 0 5px 20px;
background-image: url(file.png);
background-repeat: no-repeat;
background-position: 0 7px;
}
ul.search li a {
font-weight: bold;
}
ul.search li div.context {
color: #888;
margin: 2px 0 0 30px;
text-align: left;
}
ul.keywordmatches li.goodmatch a {
font-weight: bold;
}
/* -- index page ------------------------------------------------------------ */
table.contentstable {
width: 90%;
}
table.contentstable p.biglink {
line-height: 150%;
}
a.biglink {
font-size: 1.3em;
}
span.linkdescr {
font-style: italic;
padding-top: 5px;
font-size: 90%;
}
/* -- general index --------------------------------------------------------- */
table.indextable {
width: 100%;
}
table.indextable td {
text-align: left;
vertical-align: top;
}
table.indextable dl, table.indextable dd {
margin-top: 0;
margin-bottom: 0;
}
table.indextable tr.pcap {
height: 10px;
}
table.indextable tr.cap {
margin-top: 10px;
background-color: #f2f2f2;
}
img.toggler {
margin-right: 3px;
margin-top: 3px;
cursor: pointer;
}
div.modindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
div.genindex-jumpbox {
border-top: 1px solid #ddd;
border-bottom: 1px solid #ddd;
margin: 1em 0 1em 0;
padding: 0.4em;
}
/* -- general body styles --------------------------------------------------- */
a.headerlink {
visibility: hidden;
}
h1:hover > a.headerlink,
h2:hover > a.headerlink,
h3:hover > a.headerlink,
h4:hover > a.headerlink,
h5:hover > a.headerlink,
h6:hover > a.headerlink,
dt:hover > a.headerlink {
visibility: visible;
}
div.body p.caption {
text-align: inherit;
}
div.body td {
text-align: left;
}
.field-list ul {
padding-left: 1em;
}
.first {
margin-top: 0 !important;
}
p.rubric {
margin-top: 30px;
font-weight: bold;
}
img.align-left, .figure.align-left, object.align-left {
clear: left;
float: left;
margin-right: 1em;
}
img.align-right, .figure.align-right, object.align-right {
clear: right;
float: right;
margin-left: 1em;
}
img.align-center, .figure.align-center, object.align-center {
display: block;
margin-left: auto;
margin-right: auto;
}
.align-left {
text-align: left;
}
.align-center {
text-align: center;
}
.align-right {
text-align: right;
}
/* -- sidebars -------------------------------------------------------------- */
div.sidebar {
margin: 0 0 0.5em 1em;
border: 1px solid #ddb;
padding: 7px 7px 0 7px;
background-color: #ffe;
width: 40%;
float: right;
}
p.sidebar-title {
font-weight: bold;
}
/* -- topics ---------------------------------------------------------------- */
div.topic {
border: 1px solid #ccc;
padding: 7px 7px 0 7px;
margin: 10px 0 10px 0;
}
p.topic-title {
font-size: 1.1em;
font-weight: bold;
margin-top: 10px;
}
/* -- admonitions ----------------------------------------------------------- */
div.admonition {
margin-top: 10px;
margin-bottom: 10px;
padding: 7px;
}
div.admonition dt {
font-weight: bold;
}
div.admonition dl {
margin-bottom: 0;
}
p.admonition-title {
margin: 0px 10px 5px 0px;
font-weight: bold;
}
div.body p.centered {
text-align: center;
margin-top: 25px;
}
/* -- tables ---------------------------------------------------------------- */
table.docutils {
border: 0;
border-collapse: collapse;
}
table.docutils td, table.docutils th {
padding: 1px 8px 1px 5px;
border-top: 0;
border-left: 0;
border-right: 0;
border-bottom: 1px solid #aaa;
}
table.field-list td, table.field-list th {
border: 0 !important;
}
table.footnote td, table.footnote th {
border: 0 !important;
}
th {
text-align: left;
padding-right: 5px;
}
table.citation {
border-left: solid 1px gray;
margin-left: 1px;
}
table.citation td {
border-bottom: none;
}
/* -- other body styles ----------------------------------------------------- */
ol.arabic {
list-style: decimal;
}
ol.loweralpha {
list-style: lower-alpha;
}
ol.upperalpha {
list-style: upper-alpha;
}
ol.lowerroman {
list-style: lower-roman;
}
ol.upperroman {
list-style: upper-roman;
}
dl {
margin-bottom: 15px;
}
dd p {
margin-top: 0px;
}
dd ul, dd table {
margin-bottom: 10px;
}
dd {
margin-top: 3px;
margin-bottom: 10px;
margin-left: 30px;
}
dt:target, .highlighted {
background-color: #fbe54e;
}
dl.glossary dt {
font-weight: bold;
font-size: 1.1em;
}
.field-list ul {
margin: 0;
padding-left: 1em;
}
.field-list p {
margin: 0;
}
.optional {
font-size: 1.3em;
}
.versionmodified {
font-style: italic;
}
.system-message {
background-color: #fda;
padding: 5px;
border: 3px solid red;
}
.footnote:target {
background-color: #ffa;
}
.line-block {
display: block;
margin-top: 1em;
margin-bottom: 1em;
}
.line-block .line-block {
margin-top: 0;
margin-bottom: 0;
margin-left: 1.5em;
}
.guilabel, .menuselection {
font-family: sans-serif;
}
.accelerator {
text-decoration: underline;
}
.classifier {
font-style: oblique;
}
abbr, acronym {
border-bottom: dotted 1px;
cursor: help;
}
/* -- code displays --------------------------------------------------------- */
pre {
overflow: auto;
overflow-y: hidden; /* fixes display issues on Chrome browsers */
}
td.linenos pre {
padding: 5px 0px;
border: 0;
background-color: transparent;
color: #aaa;
}
table.highlighttable {
margin-left: 0.5em;
}
table.highlighttable td {
padding: 0 0.5em 0 0.5em;
}
tt.descname {
background-color: transparent;
font-weight: bold;
font-size: 1.2em;
}
tt.descclassname {
background-color: transparent;
}
tt.xref, a tt {
background-color: transparent;
font-weight: bold;
}
h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
background-color: transparent;
}
.viewcode-link {
float: right;
}
.viewcode-back {
float: right;
font-family: sans-serif;
}
div.viewcode-block:target {
margin: -1px -10px;
padding: 0 10px;
}
/* -- math display ---------------------------------------------------------- */
img.math {
vertical-align: middle;
}
div.body div.math p {
text-align: center;
}
span.eqno {
float: right;
}
/* -- printout stylesheet --------------------------------------------------- */
@media print {
div.document,
div.documentwrapper,
div.bodywrapper {
margin: 0 !important;
width: 100%;
}
div.sphinxsidebar,
div.related,
div.footer,
#top-link {
display: none;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

View File

@ -1,256 +0,0 @@
/*
* default.css_t
* ~~~~~~~~~~~~~
*
* Sphinx stylesheet -- default theme.
*
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
@import url("basic.css");
/* -- page layout ----------------------------------------------------------- */
body {
font-family: sans-serif;
font-size: 100%;
background-color: #11303d;
color: #000;
margin: 0;
padding: 0;
}
div.document {
background-color: #1c4e63;
}
div.documentwrapper {
float: left;
width: 100%;
}
div.bodywrapper {
margin: 0 0 0 230px;
}
div.body {
background-color: #ffffff;
color: #000000;
padding: 0 20px 30px 20px;
}
div.footer {
color: #ffffff;
width: 100%;
padding: 9px 0 9px 0;
text-align: center;
font-size: 75%;
}
div.footer a {
color: #ffffff;
text-decoration: underline;
}
div.related {
background-color: #133f52;
line-height: 30px;
color: #ffffff;
}
div.related a {
color: #ffffff;
}
div.sphinxsidebar {
}
div.sphinxsidebar h3 {
font-family: 'Trebuchet MS', sans-serif;
color: #ffffff;
font-size: 1.4em;
font-weight: normal;
margin: 0;
padding: 0;
}
div.sphinxsidebar h3 a {
color: #ffffff;
}
div.sphinxsidebar h4 {
font-family: 'Trebuchet MS', sans-serif;
color: #ffffff;
font-size: 1.3em;
font-weight: normal;
margin: 5px 0 0 0;
padding: 0;
}
div.sphinxsidebar p {
color: #ffffff;
}
div.sphinxsidebar p.topless {
margin: 5px 10px 10px 10px;
}
div.sphinxsidebar ul {
margin: 10px;
padding: 0;
color: #ffffff;
}
div.sphinxsidebar a {
color: #98dbcc;
}
div.sphinxsidebar input {
border: 1px solid #98dbcc;
font-family: sans-serif;
font-size: 1em;
}
/* -- hyperlink styles ------------------------------------------------------ */
a {
color: #355f7c;
text-decoration: none;
}
a:visited {
color: #355f7c;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
/* -- body styles ----------------------------------------------------------- */
div.body h1,
div.body h2,
div.body h3,
div.body h4,
div.body h5,
div.body h6 {
font-family: 'Trebuchet MS', sans-serif;
background-color: #f2f2f2;
font-weight: normal;
color: #20435c;
border-bottom: 1px solid #ccc;
margin: 20px -20px 10px -20px;
padding: 3px 0 3px 10px;
}
div.body h1 { margin-top: 0; font-size: 200%; }
div.body h2 { font-size: 160%; }
div.body h3 { font-size: 140%; }
div.body h4 { font-size: 120%; }
div.body h5 { font-size: 110%; }
div.body h6 { font-size: 100%; }
a.headerlink {
color: #c60f0f;
font-size: 0.8em;
padding: 0 4px 0 4px;
text-decoration: none;
}
a.headerlink:hover {
background-color: #c60f0f;
color: white;
}
div.body p, div.body dd, div.body li {
text-align: justify;
line-height: 130%;
}
div.admonition p.admonition-title + p {
display: inline;
}
div.admonition p {
margin-bottom: 5px;
}
div.admonition pre {
margin-bottom: 5px;
}
div.admonition ul, div.admonition ol {
margin-bottom: 5px;
}
div.note {
background-color: #eee;
border: 1px solid #ccc;
}
div.seealso {
background-color: #ffc;
border: 1px solid #ff6;
}
div.topic {
background-color: #eee;
}
div.warning {
background-color: #ffe4e4;
border: 1px solid #f66;
}
p.admonition-title {
display: inline;
}
p.admonition-title:after {
content: ":";
}
pre {
padding: 5px;
background-color: #eeffcc;
color: #333333;
line-height: 120%;
border: 1px solid #ac9;
border-left: none;
border-right: none;
}
tt {
background-color: #ecf0f3;
padding: 0 1px 0 1px;
font-size: 0.95em;
}
th {
background-color: #ede;
}
.warning tt {
background: #efc2c2;
}
.note tt {
background: #d6d6d6;
}
.viewcode-back {
font-family: sans-serif;
}
div.viewcode-block:target {
background-color: #f4debf;
border-top: 1px solid #ac9;
border-bottom: 1px solid #ac9;
}

View File

@ -1,238 +0,0 @@
/*
* doctools.js
* ~~~~~~~~~~~
*
* Sphinx JavaScript utilities for all documentation.
*
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/**
* select a different prefix for underscore
*/
$u = _.noConflict();
/**
* make the code below compatible with browsers without
* an installed firebug like debugger
if (!window.console || !console.firebug) {
var names = ["log", "debug", "info", "warn", "error", "assert", "dir",
"dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace",
"profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {};
}
*/
/**
* small helper function to urldecode strings
*/
jQuery.urldecode = function(x) {
return decodeURIComponent(x).replace(/\+/g, ' ');
};
/**
* small helper function to urlencode strings
*/
jQuery.urlencode = encodeURIComponent;
/**
* This function returns the parsed url parameters of the
* current request. Multiple values per key are supported,
* it will always return arrays of strings for the value parts.
*/
jQuery.getQueryParameters = function(s) {
if (typeof s == 'undefined')
s = document.location.search;
var parts = s.substr(s.indexOf('?') + 1).split('&');
var result = {};
for (var i = 0; i < parts.length; i++) {
var tmp = parts[i].split('=', 2);
var key = jQuery.urldecode(tmp[0]);
var value = jQuery.urldecode(tmp[1]);
if (key in result)
result[key].push(value);
else
result[key] = [value];
}
return result;
};
/**
* highlight a given string on a jquery object by wrapping it in
* span elements with the given class name.
*/
jQuery.fn.highlightText = function(text, className) {
function highlight(node) {
if (node.nodeType == 3) {
var val = node.nodeValue;
var pos = val.toLowerCase().indexOf(text);
if (pos >= 0 && !jQuery(node.parentNode).hasClass(className)) {
var span = document.createElement("span");
span.className = className;
span.appendChild(document.createTextNode(val.substr(pos, text.length)));
node.parentNode.insertBefore(span, node.parentNode.insertBefore(
document.createTextNode(val.substr(pos + text.length)),
node.nextSibling));
node.nodeValue = val.substr(0, pos);
}
}
else if (!jQuery(node).is("button, select, textarea")) {
jQuery.each(node.childNodes, function() {
highlight(this);
});
}
}
return this.each(function() {
highlight(this);
});
};
/**
* Small JavaScript module for the documentation.
*/
var Documentation = {
init : function() {
this.fixFirefoxAnchorBug();
this.highlightSearchWords();
this.initIndexTable();
},
/**
* i18n support
*/
TRANSLATIONS : {},
PLURAL_EXPR : function(n) { return n == 1 ? 0 : 1; },
LOCALE : 'unknown',
// gettext and ngettext don't access this so that the functions
// can safely bound to a different name (_ = Documentation.gettext)
gettext : function(string) {
var translated = Documentation.TRANSLATIONS[string];
if (typeof translated == 'undefined')
return string;
return (typeof translated == 'string') ? translated : translated[0];
},
ngettext : function(singular, plural, n) {
var translated = Documentation.TRANSLATIONS[singular];
if (typeof translated == 'undefined')
return (n == 1) ? singular : plural;
return translated[Documentation.PLURALEXPR(n)];
},
addTranslations : function(catalog) {
for (var key in catalog.messages)
this.TRANSLATIONS[key] = catalog.messages[key];
this.PLURAL_EXPR = new Function('n', 'return +(' + catalog.plural_expr + ')');
this.LOCALE = catalog.locale;
},
/**
* add context elements like header anchor links
*/
addContextElements : function() {
$('div[id] > :header:first').each(function() {
$('<a class="headerlink">\u00B6</a>').
attr('href', '#' + this.id).
attr('title', _('Permalink to this headline')).
appendTo(this);
});
$('dt[id]').each(function() {
$('<a class="headerlink">\u00B6</a>').
attr('href', '#' + this.id).
attr('title', _('Permalink to this definition')).
appendTo(this);
});
},
/**
* workaround a firefox stupidity
*/
fixFirefoxAnchorBug : function() {
if (document.location.hash && $.browser.mozilla)
window.setTimeout(function() {
document.location.href += '';
}, 10);
},
/**
* highlight the search words provided in the url in the text
*/
highlightSearchWords : function() {
var params = $.getQueryParameters();
var terms = (params.highlight) ? params.highlight[0].split(/\s+/) : [];
if (terms.length) {
var body = $('div.body');
if (!body.length) {
body = $('body');
}
window.setTimeout(function() {
$.each(terms, function() {
body.highlightText(this.toLowerCase(), 'highlighted');
});
}, 10);
$('<p class="highlight-link"><a href="javascript:Documentation.' +
'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')
.appendTo($('#searchbox'));
}
},
/**
* init the domain index toggle buttons
*/
initIndexTable : function() {
var togglers = $('img.toggler').click(function() {
var src = $(this).attr('src');
var idnum = $(this).attr('id').substr(7);
$('tr.cg-' + idnum).toggle();
if (src.substr(-9) == 'minus.png')
$(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
else
$(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
}).css('display', '');
if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
togglers.click();
}
},
/**
* helper function to hide the search marks again
*/
hideSearchWords : function() {
$('#searchbox .highlight-link').fadeOut(300);
$('span.highlighted').removeClass('highlighted');
},
/**
* make the url absolute
*/
makeURL : function(relativeURL) {
return DOCUMENTATION_OPTIONS.URL_ROOT + '/' + relativeURL;
},
/**
* get the current relative url
*/
getCurrentURL : function() {
var path = document.location.pathname;
var parts = path.split(/\//);
$.each(DOCUMENTATION_OPTIONS.URL_ROOT.split(/\//), function() {
if (this == '..')
parts.pop();
});
var url = parts.join('/');
return path.substring(url.lastIndexOf('/') + 1, path.length - 1);
}
};
// quick alias for translations
_ = Documentation.gettext;
$(document).ready(function() {
Documentation.init();
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 392 B

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 199 B

View File

@ -1,69 +0,0 @@
.highlight .hll { background-color: #ffffcc }
.highlight { background: #eeffcc; }
.highlight .c { color: #408090; font-style: italic } /* Comment */
.highlight .err { border: 1px solid #FF0000 } /* Error */
.highlight .k { color: #007020; font-weight: bold } /* Keyword */
.highlight .o { color: #666666 } /* Operator */
.highlight .ch { color: #408090; font-style: italic } /* Comment.Hashbang */
.highlight .cm { color: #408090; font-style: italic } /* Comment.Multiline */
.highlight .cp { color: #007020 } /* Comment.Preproc */
.highlight .cpf { color: #408090; font-style: italic } /* Comment.PreprocFile */
.highlight .c1 { color: #408090; font-style: italic } /* Comment.Single */
.highlight .cs { color: #408090; background-color: #fff0f0 } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #333333 } /* Generic.Output */
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0044DD } /* Generic.Traceback */
.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #007020 } /* Keyword.Pseudo */
.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #902000 } /* Keyword.Type */
.highlight .m { color: #208050 } /* Literal.Number */
.highlight .s { color: #4070a0 } /* Literal.String */
.highlight .na { color: #4070a0 } /* Name.Attribute */
.highlight .nb { color: #007020 } /* Name.Builtin */
.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
.highlight .no { color: #60add5 } /* Name.Constant */
.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #007020 } /* Name.Exception */
.highlight .nf { color: #06287e } /* Name.Function */
.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
.highlight .nv { color: #bb60d5 } /* Name.Variable */
.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #208050 } /* Literal.Number.Bin */
.highlight .mf { color: #208050 } /* Literal.Number.Float */
.highlight .mh { color: #208050 } /* Literal.Number.Hex */
.highlight .mi { color: #208050 } /* Literal.Number.Integer */
.highlight .mo { color: #208050 } /* Literal.Number.Oct */
.highlight .sa { color: #4070a0 } /* Literal.String.Affix */
.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
.highlight .sc { color: #4070a0 } /* Literal.String.Char */
.highlight .dl { color: #4070a0 } /* Literal.String.Delimiter */
.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
.highlight .s2 { color: #4070a0 } /* Literal.String.Double */
.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
.highlight .sx { color: #c65d09 } /* Literal.String.Other */
.highlight .sr { color: #235388 } /* Literal.String.Regex */
.highlight .s1 { color: #4070a0 } /* Literal.String.Single */
.highlight .ss { color: #517918 } /* Literal.String.Symbol */
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #06287e } /* Name.Function.Magic */
.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
.highlight .vm { color: #bb60d5 } /* Name.Variable.Magic */
.highlight .il { color: #208050 } /* Literal.Number.Integer.Long */

View File

@ -1,622 +0,0 @@
/*
* searchtools.js_t
* ~~~~~~~~~~~~~~~~
*
* Sphinx JavaScript utilties for the full-text search.
*
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
/**
* Porter Stemmer
*/
var Stemmer = function() {
var step2list = {
ational: 'ate',
tional: 'tion',
enci: 'ence',
anci: 'ance',
izer: 'ize',
bli: 'ble',
alli: 'al',
entli: 'ent',
eli: 'e',
ousli: 'ous',
ization: 'ize',
ation: 'ate',
ator: 'ate',
alism: 'al',
iveness: 'ive',
fulness: 'ful',
ousness: 'ous',
aliti: 'al',
iviti: 'ive',
biliti: 'ble',
logi: 'log'
};
var step3list = {
icate: 'ic',
ative: '',
alize: 'al',
iciti: 'ic',
ical: 'ic',
ful: '',
ness: ''
};
var c = "[^aeiou]"; // consonant
var v = "[aeiouy]"; // vowel
var C = c + "[^aeiouy]*"; // consonant sequence
var V = v + "[aeiou]*"; // vowel sequence
var mgr0 = "^(" + C + ")?" + V + C; // [C]VC... is m>0
var meq1 = "^(" + C + ")?" + V + C + "(" + V + ")?$"; // [C]VC[V] is m=1
var mgr1 = "^(" + C + ")?" + V + C + V + C; // [C]VCVC... is m>1
var s_v = "^(" + C + ")?" + v; // vowel in stem
this.stemWord = function (w) {
var stem;
var suffix;
var firstch;
var origword = w;
if (w.length < 3)
return w;
var re;
var re2;
var re3;
var re4;
firstch = w.substr(0,1);
if (firstch == "y")
w = firstch.toUpperCase() + w.substr(1);
// Step 1a
re = /^(.+?)(ss|i)es$/;
re2 = /^(.+?)([^s])s$/;
if (re.test(w))
w = w.replace(re,"$1$2");
else if (re2.test(w))
w = w.replace(re2,"$1$2");
// Step 1b
re = /^(.+?)eed$/;
re2 = /^(.+?)(ed|ing)$/;
if (re.test(w)) {
var fp = re.exec(w);
re = new RegExp(mgr0);
if (re.test(fp[1])) {
re = /.$/;
w = w.replace(re,"");
}
}
else if (re2.test(w)) {
var fp = re2.exec(w);
stem = fp[1];
re2 = new RegExp(s_v);
if (re2.test(stem)) {
w = stem;
re2 = /(at|bl|iz)$/;
re3 = new RegExp("([^aeiouylsz])\\1$");
re4 = new RegExp("^" + C + v + "[^aeiouwxy]$");
if (re2.test(w))
w = w + "e";
else if (re3.test(w)) {
re = /.$/;
w = w.replace(re,"");
}
else if (re4.test(w))
w = w + "e";
}
}
// Step 1c
re = /^(.+?)y$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(s_v);
if (re.test(stem))
w = stem + "i";
}
// Step 2
re = /^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
suffix = fp[2];
re = new RegExp(mgr0);
if (re.test(stem))
w = stem + step2list[suffix];
}
// Step 3
re = /^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
suffix = fp[2];
re = new RegExp(mgr0);
if (re.test(stem))
w = stem + step3list[suffix];
}
// Step 4
re = /^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/;
re2 = /^(.+?)(s|t)(ion)$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(mgr1);
if (re.test(stem))
w = stem;
}
else if (re2.test(w)) {
var fp = re2.exec(w);
stem = fp[1] + fp[2];
re2 = new RegExp(mgr1);
if (re2.test(stem))
w = stem;
}
// Step 5
re = /^(.+?)e$/;
if (re.test(w)) {
var fp = re.exec(w);
stem = fp[1];
re = new RegExp(mgr1);
re2 = new RegExp(meq1);
re3 = new RegExp("^" + C + v + "[^aeiouwxy]$");
if (re.test(stem) || (re2.test(stem) && !(re3.test(stem))))
w = stem;
}
re = /ll$/;
re2 = new RegExp(mgr1);
if (re.test(w) && re2.test(w)) {
re = /.$/;
w = w.replace(re,"");
}
// and turn initial Y back to y
if (firstch == "y")
w = firstch.toLowerCase() + w.substr(1);
return w;
}
}
/**
* Simple result scoring code.
*/
var Scorer = {
// Implement the following function to further tweak the score for each result
// The function takes a result array [filename, title, anchor, descr, score]
// and returns the new score.
/*
score: function(result) {
return result[4];
},
*/
// query matches the full name of an object
objNameMatch: 11,
// or matches in the last dotted part of the object name
objPartialMatch: 6,
// Additive scores depending on the priority of the object
objPrio: {0: 15, // used to be importantResults
1: 5, // used to be objectResults
2: -5}, // used to be unimportantResults
// Used when the priority is not in the mapping.
objPrioDefault: 0,
// query found in title
title: 15,
// query found in terms
term: 5
};
/**
* Search Module
*/
var Search = {
_index : null,
_queued_query : null,
_pulse_status : -1,
init : function() {
var params = $.getQueryParameters();
if (params.q) {
var query = params.q[0];
$('input[name="q"]')[0].value = query;
this.performSearch(query);
}
},
loadIndex : function(url) {
$.ajax({type: "GET", url: url, data: null,
dataType: "script", cache: true,
complete: function(jqxhr, textstatus) {
if (textstatus != "success") {
document.getElementById("searchindexloader").src = url;
}
}});
},
setIndex : function(index) {
var q;
this._index = index;
if ((q = this._queued_query) !== null) {
this._queued_query = null;
Search.query(q);
}
},
hasIndex : function() {
return this._index !== null;
},
deferQuery : function(query) {
this._queued_query = query;
},
stopPulse : function() {
this._pulse_status = 0;
},
startPulse : function() {
if (this._pulse_status >= 0)
return;
function pulse() {
var i;
Search._pulse_status = (Search._pulse_status + 1) % 4;
var dotString = '';
for (i = 0; i < Search._pulse_status; i++)
dotString += '.';
Search.dots.text(dotString);
if (Search._pulse_status > -1)
window.setTimeout(pulse, 500);
}
pulse();
},
/**
* perform a search for something (or wait until index is loaded)
*/
performSearch : function(query) {
// create the required interface elements
this.out = $('#search-results');
this.title = $('<h2>' + _('Searching') + '</h2>').appendTo(this.out);
this.dots = $('<span></span>').appendTo(this.title);
this.status = $('<p style="display: none"></p>').appendTo(this.out);
this.output = $('<ul class="search"/>').appendTo(this.out);
$('#search-progress').text(_('Preparing search...'));
this.startPulse();
// index already loaded, the browser was quick!
if (this.hasIndex())
this.query(query);
else
this.deferQuery(query);
},
/**
* execute search (requires search index to be loaded)
*/
query : function(query) {
var i;
var stopwords = ["a","and","are","as","at","be","but","by","for","if","in","into","is","it","near","no","not","of","on","or","such","that","the","their","then","there","these","they","this","to","was","will","with"];
// stem the searchterms and add them to the correct list
var stemmer = new Stemmer();
var searchterms = [];
var excluded = [];
var hlterms = [];
var tmp = query.split(/\s+/);
var objectterms = [];
for (i = 0; i < tmp.length; i++) {
if (tmp[i] !== "") {
objectterms.push(tmp[i].toLowerCase());
}
if ($u.indexOf(stopwords, tmp[i].toLowerCase()) != -1 || tmp[i].match(/^\d+$/) ||
tmp[i] === "") {
// skip this "word"
continue;
}
// stem the word
var word = stemmer.stemWord(tmp[i].toLowerCase());
var toAppend;
// select the correct list
if (word[0] == '-') {
toAppend = excluded;
word = word.substr(1);
}
else {
toAppend = searchterms;
hlterms.push(tmp[i].toLowerCase());
}
// only add if not already in the list
if (!$u.contains(toAppend, word))
toAppend.push(word);
}
var highlightstring = '?highlight=' + $.urlencode(hlterms.join(" "));
// console.debug('SEARCH: searching for:');
// console.info('required: ', searchterms);
// console.info('excluded: ', excluded);
// prepare search
var terms = this._index.terms;
var titleterms = this._index.titleterms;
// array of [filename, title, anchor, descr, score]
var results = [];
$('#search-progress').empty();
// lookup as object
for (i = 0; i < objectterms.length; i++) {
var others = [].concat(objectterms.slice(0, i),
objectterms.slice(i+1, objectterms.length));
results = results.concat(this.performObjectSearch(objectterms[i], others));
}
// lookup as search terms in fulltext
results = results.concat(this.performTermsSearch(searchterms, excluded, terms, Scorer.term))
.concat(this.performTermsSearch(searchterms, excluded, titleterms, Scorer.title));
// let the scorer override scores with a custom scoring function
if (Scorer.score) {
for (i = 0; i < results.length; i++)
results[i][4] = Scorer.score(results[i]);
}
// now sort the results by score (in opposite order of appearance, since the
// display function below uses pop() to retrieve items) and then
// alphabetically
results.sort(function(a, b) {
var left = a[4];
var right = b[4];
if (left > right) {
return 1;
} else if (left < right) {
return -1;
} else {
// same score: sort alphabetically
left = a[1].toLowerCase();
right = b[1].toLowerCase();
return (left > right) ? -1 : ((left < right) ? 1 : 0);
}
});
// for debugging
//Search.lastresults = results.slice(); // a copy
//console.info('search results:', Search.lastresults);
// print the results
var resultCount = results.length;
function displayNextItem() {
// results left, load the summary and display it
if (results.length) {
var item = results.pop();
var listItem = $('<li style="display:none"></li>');
if (DOCUMENTATION_OPTIONS.FILE_SUFFIX === '') {
// dirhtml builder
var dirname = item[0] + '/';
if (dirname.match(/\/index\/$/)) {
dirname = dirname.substring(0, dirname.length-6);
} else if (dirname == 'index/') {
dirname = '';
}
listItem.append($('<a/>').attr('href',
DOCUMENTATION_OPTIONS.URL_ROOT + dirname +
highlightstring + item[2]).html(item[1]));
} else {
// normal html builders
listItem.append($('<a/>').attr('href',
item[0] + DOCUMENTATION_OPTIONS.FILE_SUFFIX +
highlightstring + item[2]).html(item[1]));
}
if (item[3]) {
listItem.append($('<span> (' + item[3] + ')</span>'));
Search.output.append(listItem);
listItem.slideDown(5, function() {
displayNextItem();
});
} else if (DOCUMENTATION_OPTIONS.HAS_SOURCE) {
$.ajax({url: DOCUMENTATION_OPTIONS.URL_ROOT + '_sources/' + item[0] + '.txt',
dataType: "text",
complete: function(jqxhr, textstatus) {
var data = jqxhr.responseText;
if (data !== '') {
listItem.append(Search.makeSearchSummary(data, searchterms, hlterms));
}
Search.output.append(listItem);
listItem.slideDown(5, function() {
displayNextItem();
});
}});
} else {
// no source available, just display title
Search.output.append(listItem);
listItem.slideDown(5, function() {
displayNextItem();
});
}
}
// search finished, update title and status message
else {
Search.stopPulse();
Search.title.text(_('Search Results'));
if (!resultCount)
Search.status.text(_('Your search did not match any documents. Please make sure that all words are spelled correctly and that you\'ve selected enough categories.'));
else
Search.status.text(_('Search finished, found %s page(s) matching the search query.').replace('%s', resultCount));
Search.status.fadeIn(500);
}
}
displayNextItem();
},
/**
* search for object names
*/
performObjectSearch : function(object, otherterms) {
var filenames = this._index.filenames;
var objects = this._index.objects;
var objnames = this._index.objnames;
var titles = this._index.titles;
var i;
var results = [];
for (var prefix in objects) {
for (var name in objects[prefix]) {
var fullname = (prefix ? prefix + '.' : '') + name;
if (fullname.toLowerCase().indexOf(object) > -1) {
var score = 0;
var parts = fullname.split('.');
// check for different match types: exact matches of full name or
// "last name" (i.e. last dotted part)
if (fullname == object || parts[parts.length - 1] == object) {
score += Scorer.objNameMatch;
// matches in last name
} else if (parts[parts.length - 1].indexOf(object) > -1) {
score += Scorer.objPartialMatch;
}
var match = objects[prefix][name];
var objname = objnames[match[1]][2];
var title = titles[match[0]];
// If more than one term searched for, we require other words to be
// found in the name/title/description
if (otherterms.length > 0) {
var haystack = (prefix + ' ' + name + ' ' +
objname + ' ' + title).toLowerCase();
var allfound = true;
for (i = 0; i < otherterms.length; i++) {
if (haystack.indexOf(otherterms[i]) == -1) {
allfound = false;
break;
}
}
if (!allfound) {
continue;
}
}
var descr = objname + _(', in ') + title;
var anchor = match[3];
if (anchor === '')
anchor = fullname;
else if (anchor == '-')
anchor = objnames[match[1]][1] + '-' + fullname;
// add custom score for some objects according to scorer
if (Scorer.objPrio.hasOwnProperty(match[2])) {
score += Scorer.objPrio[match[2]];
} else {
score += Scorer.objPrioDefault;
}
results.push([filenames[match[0]], fullname, '#'+anchor, descr, score]);
}
}
}
return results;
},
/**
* search for full-text terms in the index
*/
performTermsSearch : function(searchterms, excluded, terms, score) {
var filenames = this._index.filenames;
var titles = this._index.titles;
var i, j, file, files;
var fileMap = {};
var results = [];
// perform the search on the required terms
for (i = 0; i < searchterms.length; i++) {
var word = searchterms[i];
// no match but word was a required one
if ((files = terms[word]) === undefined)
break;
if (files.length === undefined) {
files = [files];
}
// create the mapping
for (j = 0; j < files.length; j++) {
file = files[j];
if (file in fileMap)
fileMap[file].push(word);
else
fileMap[file] = [word];
}
}
// now check if the files don't contain excluded terms
for (file in fileMap) {
var valid = true;
// check if all requirements are matched
if (fileMap[file].length != searchterms.length)
continue;
// ensure that none of the excluded terms is in the search result
for (i = 0; i < excluded.length; i++) {
if (terms[excluded[i]] == file ||
$u.contains(terms[excluded[i]] || [], file)) {
valid = false;
break;
}
}
// if we have still a valid result we can add it to the result list
if (valid) {
results.push([filenames[file], titles[file], '', null, score]);
}
}
return results;
},
/**
* helper function to return a node containing the
* search summary for a given text. keywords is a list
* of stemmed words, hlwords is the list of normal, unstemmed
* words. the first one is used to find the occurance, the
* latter for highlighting it.
*/
makeSearchSummary : function(text, keywords, hlwords) {
var textLower = text.toLowerCase();
var start = 0;
$.each(keywords, function() {
var i = textLower.indexOf(this.toLowerCase());
if (i > -1)
start = i;
});
start = Math.max(start - 120, 0);
var excerpt = ((start > 0) ? '...' : '') +
$.trim(text.substr(start, 240)) +
((start + 240 - text.length) ? '...' : '');
var rv = $('<div class="context"></div>').text(excerpt);
$.each(hlwords, function() {
rv = rv.highlightText(this, 'highlighted');
});
return rv;
}
};
$(document).ready(function() {
Search.init();
});

View File

@ -1,159 +0,0 @@
/*
* sidebar.js
* ~~~~~~~~~~
*
* This script makes the Sphinx sidebar collapsible.
*
* .sphinxsidebar contains .sphinxsidebarwrapper. This script adds
* in .sphixsidebar, after .sphinxsidebarwrapper, the #sidebarbutton
* used to collapse and expand the sidebar.
*
* When the sidebar is collapsed the .sphinxsidebarwrapper is hidden
* and the width of the sidebar and the margin-left of the document
* are decreased. When the sidebar is expanded the opposite happens.
* This script saves a per-browser/per-session cookie used to
* remember the position of the sidebar among the pages.
* Once the browser is closed the cookie is deleted and the position
* reset to the default (expanded).
*
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
$(function() {
// global elements used by the functions.
// the 'sidebarbutton' element is defined as global after its
// creation, in the add_sidebar_button function
var bodywrapper = $('.bodywrapper');
var sidebar = $('.sphinxsidebar');
var sidebarwrapper = $('.sphinxsidebarwrapper');
// for some reason, the document has no sidebar; do not run into errors
if (!sidebar.length) return;
// original margin-left of the bodywrapper and width of the sidebar
// with the sidebar expanded
var bw_margin_expanded = bodywrapper.css('margin-left');
var ssb_width_expanded = sidebar.width();
// margin-left of the bodywrapper and width of the sidebar
// with the sidebar collapsed
var bw_margin_collapsed = '.8em';
var ssb_width_collapsed = '.8em';
// colors used by the current theme
var dark_color = $('.related').css('background-color');
var light_color = $('.document').css('background-color');
function sidebar_is_collapsed() {
return sidebarwrapper.is(':not(:visible)');
}
function toggle_sidebar() {
if (sidebar_is_collapsed())
expand_sidebar();
else
collapse_sidebar();
}
function collapse_sidebar() {
sidebarwrapper.hide();
sidebar.css('width', ssb_width_collapsed);
bodywrapper.css('margin-left', bw_margin_collapsed);
sidebarbutton.css({
'margin-left': '0',
'height': bodywrapper.height()
});
sidebarbutton.find('span').text('»');
sidebarbutton.attr('title', _('Expand sidebar'));
document.cookie = 'sidebar=collapsed';
}
function expand_sidebar() {
bodywrapper.css('margin-left', bw_margin_expanded);
sidebar.css('width', ssb_width_expanded);
sidebarwrapper.show();
sidebarbutton.css({
'margin-left': ssb_width_expanded-12,
'height': bodywrapper.height()
});
sidebarbutton.find('span').text('«');
sidebarbutton.attr('title', _('Collapse sidebar'));
document.cookie = 'sidebar=expanded';
}
function add_sidebar_button() {
sidebarwrapper.css({
'float': 'left',
'margin-right': '0',
'width': ssb_width_expanded - 28
});
// create the button
sidebar.append(
'<div id="sidebarbutton"><span>&laquo;</span></div>'
);
var sidebarbutton = $('#sidebarbutton');
light_color = sidebarbutton.css('background-color');
// find the height of the viewport to center the '<<' in the page
var viewport_height;
if (window.innerHeight)
viewport_height = window.innerHeight;
else
viewport_height = $(window).height();
sidebarbutton.find('span').css({
'display': 'block',
'margin-top': (viewport_height - sidebar.position().top - 20) / 2
});
sidebarbutton.click(toggle_sidebar);
sidebarbutton.attr('title', _('Collapse sidebar'));
sidebarbutton.css({
'color': '#FFFFFF',
'border-left': '1px solid ' + dark_color,
'font-size': '1.2em',
'cursor': 'pointer',
'height': bodywrapper.height(),
'padding-top': '1px',
'margin-left': ssb_width_expanded - 12
});
sidebarbutton.hover(
function () {
$(this).css('background-color', dark_color);
},
function () {
$(this).css('background-color', light_color);
}
);
}
function set_position_from_cookie() {
if (!document.cookie)
return;
var items = document.cookie.split(';');
for(var k=0; k<items.length; k++) {
var key_val = items[k].split('=');
var key = key_val[0].replace(/ /, ""); // strip leading spaces
if (key == 'sidebar') {
var value = key_val[1];
if ((value == 'collapsed') && (!sidebar_is_collapsed()))
collapse_sidebar();
else if ((value == 'expanded') && (sidebar_is_collapsed()))
expand_sidebar();
}
}
}
add_sidebar_button();
var sidebarbutton = $('#sidebarbutton');
set_position_from_cookie();
});

View File

@ -1,31 +0,0 @@
// Underscore.js 1.3.1
// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the MIT license.
// Portions of Underscore are inspired or borrowed from Prototype,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore
(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source==
c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c,
h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else r._=b;b.VERSION="1.3.1";var j=b.each=
b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e<f;e++){if(e in a&&c.call(d,a[e],e,a)===n)break}else for(e in a)if(b.has(a,e)&&c.call(d,a[e],e,a)===n)break};b.map=b.collect=function(a,c,b){var e=[];if(a==null)return e;if(x&&a.map===x)return a.map(c,b);j(a,function(a,g,h){e[e.length]=c.call(b,a,g,h)});if(a.length===+a.length)e.length=a.length;return e};b.reduce=b.foldl=b.inject=function(a,c,d,e){var f=arguments.length>2;a==
null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&&(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=
function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e;if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e=
e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a,function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=
function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b<e.computed&&(e={value:a,computed:b})});
return e.value};b.shuffle=function(a){var b=[],d;j(a,function(a,f){f==0?b[0]=a:(d=Math.floor(Math.random()*(f+1)),b[f]=b[d],b[d]=a)});return b};b.sortBy=function(a,c,d){return b.pluck(b.map(a,function(a,b,g){return{value:a,criteria:c.call(d,a,b,g)}}).sort(function(a,b){var c=a.criteria,d=b.criteria;return c<d?-1:c>d?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c=e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,
c,d){d||(d=b.identity);for(var e=0,f=a.length;e<f;){var g=e+f>>1;d(a[g])<d(c)?e=g+1:f=g}return e};b.toArray=function(a){return!a?[]:a.toArray?a.toArray():b.isArray(a)?i.call(a):b.isArguments(a)?i.call(a):b.values(a)};b.size=function(a){return b.toArray(a).length};b.first=b.head=function(a,b,d){return b!=null&&!d?i.call(a,0,b):a[0]};b.initial=function(a,b,d){return i.call(a,0,a.length-(b==null||d?1:b))};b.last=function(a,b,d){return b!=null&&!d?i.call(a,Math.max(a.length-b,0)):a[a.length-1]};b.rest=
b.tail=function(a,b,d){return i.call(a,b==null||d?1:b)};b.compact=function(a){return b.filter(a,function(a){return!!a})};b.flatten=function(a,c){return b.reduce(a,function(a,e){if(b.isArray(e))return a.concat(c?e:b.flatten(e));a[a.length]=e;return a},[])};b.without=function(a){return b.difference(a,i.call(arguments,1))};b.uniq=b.unique=function(a,c,d){var d=d?b.map(a,d):a,e=[];b.reduce(d,function(d,g,h){if(0==h||(c===true?b.last(d)!=g:!b.include(d,g)))d[d.length]=g,e[e.length]=a[h];return d},[]);
return e};b.union=function(){return b.uniq(b.flatten(arguments,true))};b.intersection=b.intersect=function(a){var c=i.call(arguments,1);return b.filter(b.uniq(a),function(a){return b.every(c,function(c){return b.indexOf(c,a)>=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e=0;e<c;e++)d[e]=b.pluck(a,""+e);return d};b.indexOf=function(a,c,
d){if(a==null)return-1;var e;if(d)return d=b.sortedIndex(a,c),a[d]===c?d:-1;if(p&&a.indexOf===p)return a.indexOf(c);for(d=0,e=a.length;d<e;d++)if(d in a&&a[d]===c)return d;return-1};b.lastIndexOf=function(a,b){if(a==null)return-1;if(D&&a.lastIndexOf===D)return a.lastIndexOf(b);for(var d=a.length;d--;)if(d in a&&a[d]===b)return d;return-1};b.range=function(a,b,d){arguments.length<=1&&(b=a||0,a=0);for(var d=arguments[2]||1,e=Math.max(Math.ceil((b-a)/d),0),f=0,g=Array(e);f<e;)g[f++]=a,a+=d;return g};
var F=function(){};b.bind=function(a,c){var d,e;if(a.bind===s&&s)return s.apply(a,i.call(arguments,1));if(!b.isFunction(a))throw new TypeError;e=i.call(arguments,2);return d=function(){if(!(this instanceof d))return a.apply(c,e.concat(i.call(arguments)));F.prototype=a.prototype;var b=new F,g=a.apply(b,e.concat(i.call(arguments)));return Object(g)===g?g:b}};b.bindAll=function(a){var c=i.call(arguments,1);c.length==0&&(c=b.functions(a));j(c,function(c){a[c]=b.bind(a[c],a)});return a};b.memoize=function(a,
c){var d={};c||(c=b.identity);return function(){var e=c.apply(this,arguments);return b.has(d,e)?d[e]:d[e]=a.apply(this,arguments)}};b.delay=function(a,b){var d=i.call(arguments,2);return setTimeout(function(){return a.apply(a,d)},b)};b.defer=function(a){return b.delay.apply(b,[a,1].concat(i.call(arguments,1)))};b.throttle=function(a,c){var d,e,f,g,h,i=b.debounce(function(){h=g=false},c);return function(){d=this;e=arguments;var b;f||(f=setTimeout(function(){f=null;h&&a.apply(d,e);i()},c));g?h=true:
a.apply(d,e);i();g=true}};b.debounce=function(a,b){var d;return function(){var e=this,f=arguments;clearTimeout(d);d=setTimeout(function(){d=null;a.apply(e,f)},b)}};b.once=function(a){var b=false,d;return function(){if(b)return d;b=true;return d=a.apply(this,arguments)}};b.wrap=function(a,b){return function(){var d=[a].concat(i.call(arguments,0));return b.apply(this,d)}};b.compose=function(){var a=arguments;return function(){for(var b=arguments,d=a.length-1;d>=0;d--)b=[a[d].apply(this,b)];return b[0]}};
b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]});return a};b.defaults=function(a){j(i.call(arguments,
1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"};b.isObject=function(a){return a===Object(a)};
b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate=function(a){return l.call(a)=="[object Date]"};
b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e<a;e++)b.call(d,e)};b.escape=function(a){return(""+a).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#x27;").replace(/\//g,"&#x2F;")};b.mixin=function(a){j(b.functions(a),
function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape||t,function(a,b){return"',_.escape("+
u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c?b(a).chain():a},K=function(a,c){m.prototype[a]=
function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments),this._chain)}});m.prototype.chain=function(){this._chain=
true;return this};m.prototype.value=function(){return this._wrapped}}).call(this);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 372 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

View File

@ -1,808 +0,0 @@
/*
* websupport.js
* ~~~~~~~~~~~~~
*
* sphinx.websupport utilties for all documentation.
*
* :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
(function($) {
$.fn.autogrow = function() {
return this.each(function() {
var textarea = this;
$.fn.autogrow.resize(textarea);
$(textarea)
.focus(function() {
textarea.interval = setInterval(function() {
$.fn.autogrow.resize(textarea);
}, 500);
})
.blur(function() {
clearInterval(textarea.interval);
});
});
};
$.fn.autogrow.resize = function(textarea) {
var lineHeight = parseInt($(textarea).css('line-height'), 10);
var lines = textarea.value.split('\n');
var columns = textarea.cols;
var lineCount = 0;
$.each(lines, function() {
lineCount += Math.ceil(this.length / columns) || 1;
});
var height = lineHeight * (lineCount + 1);
$(textarea).css('height', height);
};
})(jQuery);
(function($) {
var comp, by;
function init() {
initEvents();
initComparator();
}
function initEvents() {
$('a.comment-close').live("click", function(event) {
event.preventDefault();
hide($(this).attr('id').substring(2));
});
$('a.vote').live("click", function(event) {
event.preventDefault();
handleVote($(this));
});
$('a.reply').live("click", function(event) {
event.preventDefault();
openReply($(this).attr('id').substring(2));
});
$('a.close-reply').live("click", function(event) {
event.preventDefault();
closeReply($(this).attr('id').substring(2));
});
$('a.sort-option').live("click", function(event) {
event.preventDefault();
handleReSort($(this));
});
$('a.show-proposal').live("click", function(event) {
event.preventDefault();
showProposal($(this).attr('id').substring(2));
});
$('a.hide-proposal').live("click", function(event) {
event.preventDefault();
hideProposal($(this).attr('id').substring(2));
});
$('a.show-propose-change').live("click", function(event) {
event.preventDefault();
showProposeChange($(this).attr('id').substring(2));
});
$('a.hide-propose-change').live("click", function(event) {
event.preventDefault();
hideProposeChange($(this).attr('id').substring(2));
});
$('a.accept-comment').live("click", function(event) {
event.preventDefault();
acceptComment($(this).attr('id').substring(2));
});
$('a.delete-comment').live("click", function(event) {
event.preventDefault();
deleteComment($(this).attr('id').substring(2));
});
$('a.comment-markup').live("click", function(event) {
event.preventDefault();
toggleCommentMarkupBox($(this).attr('id').substring(2));
});
}
/**
* Set comp, which is a comparator function used for sorting and
* inserting comments into the list.
*/
function setComparator() {
// If the first three letters are "asc", sort in ascending order
// and remove the prefix.
if (by.substring(0,3) == 'asc') {
var i = by.substring(3);
comp = function(a, b) { return a[i] - b[i]; };
} else {
// Otherwise sort in descending order.
comp = function(a, b) { return b[by] - a[by]; };
}
// Reset link styles and format the selected sort option.
$('a.sel').attr('href', '#').removeClass('sel');
$('a.by' + by).removeAttr('href').addClass('sel');
}
/**
* Create a comp function. If the user has preferences stored in
* the sortBy cookie, use those, otherwise use the default.
*/
function initComparator() {
by = 'rating'; // Default to sort by rating.
// If the sortBy cookie is set, use that instead.
if (document.cookie.length > 0) {
var start = document.cookie.indexOf('sortBy=');
if (start != -1) {
start = start + 7;
var end = document.cookie.indexOf(";", start);
if (end == -1) {
end = document.cookie.length;
by = unescape(document.cookie.substring(start, end));
}
}
}
setComparator();
}
/**
* Show a comment div.
*/
function show(id) {
$('#ao' + id).hide();
$('#ah' + id).show();
var context = $.extend({id: id}, opts);
var popup = $(renderTemplate(popupTemplate, context)).hide();
popup.find('textarea[name="proposal"]').hide();
popup.find('a.by' + by).addClass('sel');
var form = popup.find('#cf' + id);
form.submit(function(event) {
event.preventDefault();
addComment(form);
});
$('#s' + id).after(popup);
popup.slideDown('fast', function() {
getComments(id);
});
}
/**
* Hide a comment div.
*/
function hide(id) {
$('#ah' + id).hide();
$('#ao' + id).show();
var div = $('#sc' + id);
div.slideUp('fast', function() {
div.remove();
});
}
/**
* Perform an ajax request to get comments for a node
* and insert the comments into the comments tree.
*/
function getComments(id) {
$.ajax({
type: 'GET',
url: opts.getCommentsURL,
data: {node: id},
success: function(data, textStatus, request) {
var ul = $('#cl' + id);
var speed = 100;
$('#cf' + id)
.find('textarea[name="proposal"]')
.data('source', data.source);
if (data.comments.length === 0) {
ul.html('<li>No comments yet.</li>');
ul.data('empty', true);
} else {
// If there are comments, sort them and put them in the list.
var comments = sortComments(data.comments);
speed = data.comments.length * 100;
appendComments(comments, ul);
ul.data('empty', false);
}
$('#cn' + id).slideUp(speed + 200);
ul.slideDown(speed);
},
error: function(request, textStatus, error) {
showError('Oops, there was a problem retrieving the comments.');
},
dataType: 'json'
});
}
/**
* Add a comment via ajax and insert the comment into the comment tree.
*/
function addComment(form) {
var node_id = form.find('input[name="node"]').val();
var parent_id = form.find('input[name="parent"]').val();
var text = form.find('textarea[name="comment"]').val();
var proposal = form.find('textarea[name="proposal"]').val();
if (text == '') {
showError('Please enter a comment.');
return;
}
// Disable the form that is being submitted.
form.find('textarea,input').attr('disabled', 'disabled');
// Send the comment to the server.
$.ajax({
type: "POST",
url: opts.addCommentURL,
dataType: 'json',
data: {
node: node_id,
parent: parent_id,
text: text,
proposal: proposal
},
success: function(data, textStatus, error) {
// Reset the form.
if (node_id) {
hideProposeChange(node_id);
}
form.find('textarea')
.val('')
.add(form.find('input'))
.removeAttr('disabled');
var ul = $('#cl' + (node_id || parent_id));
if (ul.data('empty')) {
$(ul).empty();
ul.data('empty', false);
}
insertComment(data.comment);
var ao = $('#ao' + node_id);
ao.find('img').attr({'src': opts.commentBrightImage});
if (node_id) {
// if this was a "root" comment, remove the commenting box
// (the user can get it back by reopening the comment popup)
$('#ca' + node_id).slideUp();
}
},
error: function(request, textStatus, error) {
form.find('textarea,input').removeAttr('disabled');
showError('Oops, there was a problem adding the comment.');
}
});
}
/**
* Recursively append comments to the main comment list and children
* lists, creating the comment tree.
*/
function appendComments(comments, ul) {
$.each(comments, function() {
var div = createCommentDiv(this);
ul.append($(document.createElement('li')).html(div));
appendComments(this.children, div.find('ul.comment-children'));
// To avoid stagnating data, don't store the comments children in data.
this.children = null;
div.data('comment', this);
});
}
/**
* After adding a new comment, it must be inserted in the correct
* location in the comment tree.
*/
function insertComment(comment) {
var div = createCommentDiv(comment);
// To avoid stagnating data, don't store the comments children in data.
comment.children = null;
div.data('comment', comment);
var ul = $('#cl' + (comment.node || comment.parent));
var siblings = getChildren(ul);
var li = $(document.createElement('li'));
li.hide();
// Determine where in the parents children list to insert this comment.
for(i=0; i < siblings.length; i++) {
if (comp(comment, siblings[i]) <= 0) {
$('#cd' + siblings[i].id)
.parent()
.before(li.html(div));
li.slideDown('fast');
return;
}
}
// If we get here, this comment rates lower than all the others,
// or it is the only comment in the list.
ul.append(li.html(div));
li.slideDown('fast');
}
function acceptComment(id) {
$.ajax({
type: 'POST',
url: opts.acceptCommentURL,
data: {id: id},
success: function(data, textStatus, request) {
$('#cm' + id).fadeOut('fast');
$('#cd' + id).removeClass('moderate');
},
error: function(request, textStatus, error) {
showError('Oops, there was a problem accepting the comment.');
}
});
}
function deleteComment(id) {
$.ajax({
type: 'POST',
url: opts.deleteCommentURL,
data: {id: id},
success: function(data, textStatus, request) {
var div = $('#cd' + id);
if (data == 'delete') {
// Moderator mode: remove the comment and all children immediately
div.slideUp('fast', function() {
div.remove();
});
return;
}
// User mode: only mark the comment as deleted
div
.find('span.user-id:first')
.text('[deleted]').end()
.find('div.comment-text:first')
.text('[deleted]').end()
.find('#cm' + id + ', #dc' + id + ', #ac' + id + ', #rc' + id +
', #sp' + id + ', #hp' + id + ', #cr' + id + ', #rl' + id)
.remove();
var comment = div.data('comment');
comment.username = '[deleted]';
comment.text = '[deleted]';
div.data('comment', comment);
},
error: function(request, textStatus, error) {
showError('Oops, there was a problem deleting the comment.');
}
});
}
function showProposal(id) {
$('#sp' + id).hide();
$('#hp' + id).show();
$('#pr' + id).slideDown('fast');
}
function hideProposal(id) {
$('#hp' + id).hide();
$('#sp' + id).show();
$('#pr' + id).slideUp('fast');
}
function showProposeChange(id) {
$('#pc' + id).hide();
$('#hc' + id).show();
var textarea = $('#pt' + id);
textarea.val(textarea.data('source'));
$.fn.autogrow.resize(textarea[0]);
textarea.slideDown('fast');
}
function hideProposeChange(id) {
$('#hc' + id).hide();
$('#pc' + id).show();
var textarea = $('#pt' + id);
textarea.val('').removeAttr('disabled');
textarea.slideUp('fast');
}
function toggleCommentMarkupBox(id) {
$('#mb' + id).toggle();
}
/** Handle when the user clicks on a sort by link. */
function handleReSort(link) {
var classes = link.attr('class').split(/\s+/);
for (var i=0; i<classes.length; i++) {
if (classes[i] != 'sort-option') {
by = classes[i].substring(2);
}
}
setComparator();
// Save/update the sortBy cookie.
var expiration = new Date();
expiration.setDate(expiration.getDate() + 365);
document.cookie= 'sortBy=' + escape(by) +
';expires=' + expiration.toUTCString();
$('ul.comment-ul').each(function(index, ul) {
var comments = getChildren($(ul), true);
comments = sortComments(comments);
appendComments(comments, $(ul).empty());
});
}
/**
* Function to process a vote when a user clicks an arrow.
*/
function handleVote(link) {
if (!opts.voting) {
showError("You'll need to login to vote.");
return;
}
var id = link.attr('id');
if (!id) {
// Didn't click on one of the voting arrows.
return;
}
// If it is an unvote, the new vote value is 0,
// Otherwise it's 1 for an upvote, or -1 for a downvote.
var value = 0;
if (id.charAt(1) != 'u') {
value = id.charAt(0) == 'u' ? 1 : -1;
}
// The data to be sent to the server.
var d = {
comment_id: id.substring(2),
value: value
};
// Swap the vote and unvote links.
link.hide();
$('#' + id.charAt(0) + (id.charAt(1) == 'u' ? 'v' : 'u') + d.comment_id)
.show();
// The div the comment is displayed in.
var div = $('div#cd' + d.comment_id);
var data = div.data('comment');
// If this is not an unvote, and the other vote arrow has
// already been pressed, unpress it.
if ((d.value !== 0) && (data.vote === d.value * -1)) {
$('#' + (d.value == 1 ? 'd' : 'u') + 'u' + d.comment_id).hide();
$('#' + (d.value == 1 ? 'd' : 'u') + 'v' + d.comment_id).show();
}
// Update the comments rating in the local data.
data.rating += (data.vote === 0) ? d.value : (d.value - data.vote);
data.vote = d.value;
div.data('comment', data);
// Change the rating text.
div.find('.rating:first')
.text(data.rating + ' point' + (data.rating == 1 ? '' : 's'));
// Send the vote information to the server.
$.ajax({
type: "POST",
url: opts.processVoteURL,
data: d,
error: function(request, textStatus, error) {
showError('Oops, there was a problem casting that vote.');
}
});
}
/**
* Open a reply form used to reply to an existing comment.
*/
function openReply(id) {
// Swap out the reply link for the hide link
$('#rl' + id).hide();
$('#cr' + id).show();
// Add the reply li to the children ul.
var div = $(renderTemplate(replyTemplate, {id: id})).hide();
$('#cl' + id)
.prepend(div)
// Setup the submit handler for the reply form.
.find('#rf' + id)
.submit(function(event) {
event.preventDefault();
addComment($('#rf' + id));
closeReply(id);
})
.find('input[type=button]')
.click(function() {
closeReply(id);
});
div.slideDown('fast', function() {
$('#rf' + id).find('textarea').focus();
});
}
/**
* Close the reply form opened with openReply.
*/
function closeReply(id) {
// Remove the reply div from the DOM.
$('#rd' + id).slideUp('fast', function() {
$(this).remove();
});
// Swap out the hide link for the reply link
$('#cr' + id).hide();
$('#rl' + id).show();
}
/**
* Recursively sort a tree of comments using the comp comparator.
*/
function sortComments(comments) {
comments.sort(comp);
$.each(comments, function() {
this.children = sortComments(this.children);
});
return comments;
}
/**
* Get the children comments from a ul. If recursive is true,
* recursively include childrens' children.
*/
function getChildren(ul, recursive) {
var children = [];
ul.children().children("[id^='cd']")
.each(function() {
var comment = $(this).data('comment');
if (recursive)
comment.children = getChildren($(this).find('#cl' + comment.id), true);
children.push(comment);
});
return children;
}
/** Create a div to display a comment in. */
function createCommentDiv(comment) {
if (!comment.displayed && !opts.moderator) {
return $('<div class="moderate">Thank you! Your comment will show up '
+ 'once it is has been approved by a moderator.</div>');
}
// Prettify the comment rating.
comment.pretty_rating = comment.rating + ' point' +
(comment.rating == 1 ? '' : 's');
// Make a class (for displaying not yet moderated comments differently)
comment.css_class = comment.displayed ? '' : ' moderate';
// Create a div for this comment.
var context = $.extend({}, opts, comment);
var div = $(renderTemplate(commentTemplate, context));
// If the user has voted on this comment, highlight the correct arrow.
if (comment.vote) {
var direction = (comment.vote == 1) ? 'u' : 'd';
div.find('#' + direction + 'v' + comment.id).hide();
div.find('#' + direction + 'u' + comment.id).show();
}
if (opts.moderator || comment.text != '[deleted]') {
div.find('a.reply').show();
if (comment.proposal_diff)
div.find('#sp' + comment.id).show();
if (opts.moderator && !comment.displayed)
div.find('#cm' + comment.id).show();
if (opts.moderator || (opts.username == comment.username))
div.find('#dc' + comment.id).show();
}
return div;
}
/**
* A simple template renderer. Placeholders such as <%id%> are replaced
* by context['id'] with items being escaped. Placeholders such as <#id#>
* are not escaped.
*/
function renderTemplate(template, context) {
var esc = $(document.createElement('div'));
function handle(ph, escape) {
var cur = context;
$.each(ph.split('.'), function() {
cur = cur[this];
});
return escape ? esc.text(cur || "").html() : cur;
}
return template.replace(/<([%#])([\w\.]*)\1>/g, function() {
return handle(arguments[2], arguments[1] == '%' ? true : false);
});
}
/** Flash an error message briefly. */
function showError(message) {
$(document.createElement('div')).attr({'class': 'popup-error'})
.append($(document.createElement('div'))
.attr({'class': 'error-message'}).text(message))
.appendTo('body')
.fadeIn("slow")
.delay(2000)
.fadeOut("slow");
}
/** Add a link the user uses to open the comments popup. */
$.fn.comment = function() {
return this.each(function() {
var id = $(this).attr('id').substring(1);
var count = COMMENT_METADATA[id];
var title = count + ' comment' + (count == 1 ? '' : 's');
var image = count > 0 ? opts.commentBrightImage : opts.commentImage;
var addcls = count == 0 ? ' nocomment' : '';
$(this)
.append(
$(document.createElement('a')).attr({
href: '#',
'class': 'sphinx-comment-open' + addcls,
id: 'ao' + id
})
.append($(document.createElement('img')).attr({
src: image,
alt: 'comment',
title: title
}))
.click(function(event) {
event.preventDefault();
show($(this).attr('id').substring(2));
})
)
.append(
$(document.createElement('a')).attr({
href: '#',
'class': 'sphinx-comment-close hidden',
id: 'ah' + id
})
.append($(document.createElement('img')).attr({
src: opts.closeCommentImage,
alt: 'close',
title: 'close'
}))
.click(function(event) {
event.preventDefault();
hide($(this).attr('id').substring(2));
})
);
});
};
var opts = {
processVoteURL: '/_process_vote',
addCommentURL: '/_add_comment',
getCommentsURL: '/_get_comments',
acceptCommentURL: '/_accept_comment',
deleteCommentURL: '/_delete_comment',
commentImage: '/static/_static/comment.png',
closeCommentImage: '/static/_static/comment-close.png',
loadingImage: '/static/_static/ajax-loader.gif',
commentBrightImage: '/static/_static/comment-bright.png',
upArrow: '/static/_static/up.png',
downArrow: '/static/_static/down.png',
upArrowPressed: '/static/_static/up-pressed.png',
downArrowPressed: '/static/_static/down-pressed.png',
voting: false,
moderator: false
};
if (typeof COMMENT_OPTIONS != "undefined") {
opts = jQuery.extend(opts, COMMENT_OPTIONS);
}
var popupTemplate = '\
<div class="sphinx-comments" id="sc<%id%>">\
<p class="sort-options">\
Sort by:\
<a href="#" class="sort-option byrating">best rated</a>\
<a href="#" class="sort-option byascage">newest</a>\
<a href="#" class="sort-option byage">oldest</a>\
</p>\
<div class="comment-header">Comments</div>\
<div class="comment-loading" id="cn<%id%>">\
loading comments... <img src="<%loadingImage%>" alt="" /></div>\
<ul id="cl<%id%>" class="comment-ul"></ul>\
<div id="ca<%id%>">\
<p class="add-a-comment">Add a comment\
(<a href="#" class="comment-markup" id="ab<%id%>">markup</a>):</p>\
<div class="comment-markup-box" id="mb<%id%>">\
reStructured text markup: <i>*emph*</i>, <b>**strong**</b>, \
<tt>``code``</tt>, \
code blocks: <tt>::</tt> and an indented block after blank line</div>\
<form method="post" id="cf<%id%>" class="comment-form" action="">\
<textarea name="comment" cols="80"></textarea>\
<p class="propose-button">\
<a href="#" id="pc<%id%>" class="show-propose-change">\
Propose a change &#9657;\
</a>\
<a href="#" id="hc<%id%>" class="hide-propose-change">\
Propose a change &#9663;\
</a>\
</p>\
<textarea name="proposal" id="pt<%id%>" cols="80"\
spellcheck="false"></textarea>\
<input type="submit" value="Add comment" />\
<input type="hidden" name="node" value="<%id%>" />\
<input type="hidden" name="parent" value="" />\
</form>\
</div>\
</div>';
var commentTemplate = '\
<div id="cd<%id%>" class="sphinx-comment<%css_class%>">\
<div class="vote">\
<div class="arrow">\
<a href="#" id="uv<%id%>" class="vote" title="vote up">\
<img src="<%upArrow%>" />\
</a>\
<a href="#" id="uu<%id%>" class="un vote" title="vote up">\
<img src="<%upArrowPressed%>" />\
</a>\
</div>\
<div class="arrow">\
<a href="#" id="dv<%id%>" class="vote" title="vote down">\
<img src="<%downArrow%>" id="da<%id%>" />\
</a>\
<a href="#" id="du<%id%>" class="un vote" title="vote down">\
<img src="<%downArrowPressed%>" />\
</a>\
</div>\
</div>\
<div class="comment-content">\
<p class="tagline comment">\
<span class="user-id"><%username%></span>\
<span class="rating"><%pretty_rating%></span>\
<span class="delta"><%time.delta%></span>\
</p>\
<div class="comment-text comment"><#text#></div>\
<p class="comment-opts comment">\
<a href="#" class="reply hidden" id="rl<%id%>">reply &#9657;</a>\
<a href="#" class="close-reply" id="cr<%id%>">reply &#9663;</a>\
<a href="#" id="sp<%id%>" class="show-proposal">proposal &#9657;</a>\
<a href="#" id="hp<%id%>" class="hide-proposal">proposal &#9663;</a>\
<a href="#" id="dc<%id%>" class="delete-comment hidden">delete</a>\
<span id="cm<%id%>" class="moderation hidden">\
<a href="#" id="ac<%id%>" class="accept-comment">accept</a>\
</span>\
</p>\
<pre class="proposal" id="pr<%id%>">\
<#proposal_diff#>\
</pre>\
<ul class="comment-children" id="cl<%id%>"></ul>\
</div>\
<div class="clearleft"></div>\
</div>\
</div>';
var replyTemplate = '\
<li>\
<div class="reply-div" id="rd<%id%>">\
<form id="rf<%id%>">\
<textarea name="comment" cols="80"></textarea>\
<input type="submit" value="Add reply" />\
<input type="button" value="Cancel" />\
<input type="hidden" name="parent" value="<%id%>" />\
<input type="hidden" name="node" value="" />\
</form>\
</div>\
</li>';
$(document).ready(function() {
init();
});
})(jQuery);
$(document).ready(function() {
// add comment anchors for all paragraphs that are commentable
$('.sphinx-has-comment').comment();
// highlight search words in search results
$("div.context").each(function() {
var params = $.getQueryParameters();
var terms = (params.q) ? params.q[0].split(/\s+/) : [];
var result = $(this);
$.each(terms, function() {
result.highlightText(this.toLowerCase(), 'highlighted');
});
});
// directly open comment window if requested
var anchor = document.location.hash;
if (anchor.substring(0, 9) == '#comment-') {
$('#ao' + anchor.substring(9)).click();
document.location.hash = '#s' + anchor.substring(9);
}
});

File diff suppressed because it is too large Load Diff

View File

@ -1,115 +0,0 @@
<!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>Welcome to kollaclis documentation! &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 documentation" href="#" />
</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="#">kollacli 4.0.1.dev498 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="welcome-to-kollacli-s-documentation">
<h1>Welcome to kollacli&#8217;s documentation!<a class="headerlink" href="#welcome-to-kollacli-s-documentation" title="Permalink to this headline"></a></h1>
<p>Contents:</p>
<div class="toctree-wrapper compound">
<ul class="simple">
</ul>
</div>
</div>
<div class="section" id="indices-and-tables">
<h1>Indices and tables<a class="headerlink" href="#indices-and-tables" title="Permalink to this headline"></a></h1>
<ul class="simple">
<li><a class="reference internal" href="genindex.html"><em>Index</em></a></li>
<li><a class="reference internal" href="py-modindex.html"><em>Module Index</em></a></li>
<li><a class="reference internal" href="search.html"><em>Search Page</em></a></li>
</ul>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="#">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Welcome to kollacli&#8217;s documentation!</a></li>
<li><a class="reference internal" href="#indices-and-tables">Indices and tables</a></li>
</ul>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/index.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><a href="#">kollacli 4.0.1.dev498 documentation</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>

File diff suppressed because it is too large Load Diff

View File

@ -1,697 +0,0 @@
<!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.commands package &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 documentation" 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 4.0.1.dev498 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="kollacli-commands-package">
<h1>kollacli.commands package<a class="headerlink" href="#kollacli-commands-package" title="Permalink to this headline"></a></h1>
<div class="section" id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-kollacli.commands.deploy">
<span id="kollacli-commands-deploy-module"></span><h2>kollacli.commands.deploy module<a class="headerlink" href="#module-kollacli.commands.deploy" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.commands.deploy.Deploy">
<em class="property">class </em><tt class="descclassname">kollacli.commands.deploy.</tt><tt class="descname">Deploy</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/deploy.html#Deploy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.deploy.Deploy" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Deploy containers to hosts.</p>
<dl class="method">
<dt id="kollacli.commands.deploy.Deploy.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/deploy.html#Deploy.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.deploy.Deploy.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.deploy.Deploy.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/deploy.html#Deploy.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.deploy.Deploy.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.deploy.Setdeploy">
<em class="property">class </em><tt class="descclassname">kollacli.commands.deploy.</tt><tt class="descname">Setdeploy</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/deploy.html#Setdeploy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.deploy.Setdeploy" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Set deploy mode.</p>
<p>Set deploy mode to either local or remote. Local indicates
that the openstack deployment will be to the local host.
Remote means that the deployment is on remote hosts.</p>
<dl class="method">
<dt id="kollacli.commands.deploy.Setdeploy.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/deploy.html#Setdeploy.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.deploy.Setdeploy.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.deploy.Setdeploy.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/deploy.html#Setdeploy.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.deploy.Setdeploy.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.commands.exceptions">
<span id="kollacli-commands-exceptions-module"></span><h2>kollacli.commands.exceptions module<a class="headerlink" href="#module-kollacli.commands.exceptions" title="Permalink to this headline"></a></h2>
<p>Exception definitions.</p>
<dl class="exception">
<dt id="kollacli.commands.exceptions.CommandError">
<em class="property">exception </em><tt class="descclassname">kollacli.commands.exceptions.</tt><tt class="descname">CommandError</tt><big>(</big><em>message</em>, <em>*args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/exceptions.html#CommandError"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.exceptions.CommandError" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">exceptions.Exception</span></tt></p>
<p>CLI command error</p>
</dd></dl>
</div>
<div class="section" id="module-kollacli.commands.group">
<span id="kollacli-commands-group-module"></span><h2>kollacli.commands.group module<a class="headerlink" href="#module-kollacli.commands.group" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.commands.group.GroupAdd">
<em class="property">class </em><tt class="descclassname">kollacli.commands.group.</tt><tt class="descname">GroupAdd</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupAdd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupAdd" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Add group to openstack-kolla.</p>
<dl class="method">
<dt id="kollacli.commands.group.GroupAdd.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupAdd.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupAdd.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.group.GroupAdd.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupAdd.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupAdd.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.group.GroupAddhost">
<em class="property">class </em><tt class="descclassname">kollacli.commands.group.</tt><tt class="descname">GroupAddhost</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupAddhost"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupAddhost" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Add host to group.</p>
<dl class="method">
<dt id="kollacli.commands.group.GroupAddhost.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupAddhost.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupAddhost.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.group.GroupAddhost.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupAddhost.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupAddhost.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.group.GroupAddservice">
<em class="property">class </em><tt class="descclassname">kollacli.commands.group.</tt><tt class="descname">GroupAddservice</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupAddservice"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupAddservice" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Add service to group.</p>
<dl class="method">
<dt id="kollacli.commands.group.GroupAddservice.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupAddservice.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupAddservice.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.group.GroupAddservice.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupAddservice.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupAddservice.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.group.GroupListhosts">
<em class="property">class </em><tt class="descclassname">kollacli.commands.group.</tt><tt class="descname">GroupListhosts</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupListhosts"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupListhosts" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.lister.Lister</span></tt></p>
<p>List all groups and their hosts.</p>
<dl class="method">
<dt id="kollacli.commands.group.GroupListhosts.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupListhosts.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupListhosts.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.group.GroupListservices">
<em class="property">class </em><tt class="descclassname">kollacli.commands.group.</tt><tt class="descname">GroupListservices</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupListservices"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupListservices" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.lister.Lister</span></tt></p>
<p>List all groups and their services.</p>
<dl class="method">
<dt id="kollacli.commands.group.GroupListservices.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupListservices.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupListservices.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.group.GroupRemove">
<em class="property">class </em><tt class="descclassname">kollacli.commands.group.</tt><tt class="descname">GroupRemove</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupRemove"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupRemove" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Remove group from openstack-kolla.</p>
<dl class="method">
<dt id="kollacli.commands.group.GroupRemove.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupRemove.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupRemove.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.group.GroupRemove.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupRemove.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupRemove.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.group.GroupRemovehost">
<em class="property">class </em><tt class="descclassname">kollacli.commands.group.</tt><tt class="descname">GroupRemovehost</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupRemovehost"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupRemovehost" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Remove host group from group.</p>
<dl class="method">
<dt id="kollacli.commands.group.GroupRemovehost.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupRemovehost.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupRemovehost.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.group.GroupRemovehost.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupRemovehost.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupRemovehost.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.group.GroupRemoveservice">
<em class="property">class </em><tt class="descclassname">kollacli.commands.group.</tt><tt class="descname">GroupRemoveservice</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupRemoveservice"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupRemoveservice" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Remove service group from group.</p>
<dl class="method">
<dt id="kollacli.commands.group.GroupRemoveservice.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupRemoveservice.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupRemoveservice.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.group.GroupRemoveservice.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/group.html#GroupRemoveservice.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.group.GroupRemoveservice.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.commands.host">
<span id="kollacli-commands-host-module"></span><h2>kollacli.commands.host module<a class="headerlink" href="#module-kollacli.commands.host" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.commands.host.HostAdd">
<em class="property">class </em><tt class="descclassname">kollacli.commands.host.</tt><tt class="descname">HostAdd</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostAdd"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostAdd" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Add host to openstack-kolla.</p>
<dl class="method">
<dt id="kollacli.commands.host.HostAdd.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostAdd.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostAdd.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.host.HostAdd.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostAdd.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostAdd.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.host.HostCheck">
<em class="property">class </em><tt class="descclassname">kollacli.commands.host.</tt><tt class="descname">HostCheck</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostCheck"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostCheck" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Check configuration of host(s).</p>
<dl class="method">
<dt id="kollacli.commands.host.HostCheck.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostCheck.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostCheck.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.host.HostCheck.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostCheck.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostCheck.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.host.HostDestroy">
<em class="property">class </em><tt class="descclassname">kollacli.commands.host.</tt><tt class="descname">HostDestroy</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostDestroy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostDestroy" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Destroy all kolla containers on host(s).</p>
<p>Stops and removes all kolla related docker containers on either the
specified host or all hosts if the hostname all is used.</p>
<dl class="method">
<dt id="kollacli.commands.host.HostDestroy.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostDestroy.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostDestroy.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.host.HostDestroy.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostDestroy.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostDestroy.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.host.HostList">
<em class="property">class </em><tt class="descclassname">kollacli.commands.host.</tt><tt class="descname">HostList</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostList"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostList" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.lister.Lister</span></tt></p>
<p>List hosts and their groups.</p>
<p>If a hostname is provided, only list information about that host.</p>
<dl class="method">
<dt id="kollacli.commands.host.HostList.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostList.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostList.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.host.HostList.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostList.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostList.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.host.HostRemove">
<em class="property">class </em><tt class="descclassname">kollacli.commands.host.</tt><tt class="descname">HostRemove</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostRemove"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostRemove" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Remove host from openstack-kolla.</p>
<dl class="method">
<dt id="kollacli.commands.host.HostRemove.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostRemove.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostRemove.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.host.HostRemove.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostRemove.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostRemove.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.host.HostSetup">
<em class="property">class </em><tt class="descclassname">kollacli.commands.host.</tt><tt class="descname">HostSetup</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostSetup"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostSetup" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Setup openstack-kollacli on host.</p>
<dl class="method">
<dt id="kollacli.commands.host.HostSetup.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostSetup.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostSetup.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.host.HostSetup.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostSetup.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostSetup.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.host.HostStop">
<em class="property">class </em><tt class="descclassname">kollacli.commands.host.</tt><tt class="descname">HostStop</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostStop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostStop" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Stop all kolla containers on host(s).</p>
<p>Stops all kolla related docker containers on either the
specified host or all hosts if the hostname all is used.</p>
<dl class="method">
<dt id="kollacli.commands.host.HostStop.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostStop.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostStop.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.host.HostStop.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/host.html#HostStop.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.host.HostStop.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.commands.password">
<span id="kollacli-commands-password-module"></span><h2>kollacli.commands.password module<a class="headerlink" href="#module-kollacli.commands.password" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.commands.password.PasswordClear">
<em class="property">class </em><tt class="descclassname">kollacli.commands.password.</tt><tt class="descname">PasswordClear</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordClear"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordClear" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Password Clear</p>
<dl class="method">
<dt id="kollacli.commands.password.PasswordClear.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordClear.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordClear.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.password.PasswordClear.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordClear.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordClear.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.password.PasswordInit">
<em class="property">class </em><tt class="descclassname">kollacli.commands.password.</tt><tt class="descname">PasswordInit</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordInit"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordInit" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Init all empty passwords and ssh keys.</p>
<dl class="method">
<dt id="kollacli.commands.password.PasswordInit.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordInit.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordInit.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.password.PasswordList">
<em class="property">class </em><tt class="descclassname">kollacli.commands.password.</tt><tt class="descname">PasswordList</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordList"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordList" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.lister.Lister</span></tt></p>
<p>List all password names.</p>
<dl class="method">
<dt id="kollacli.commands.password.PasswordList.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordList.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordList.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.password.PasswordSet">
<em class="property">class </em><tt class="descclassname">kollacli.commands.password.</tt><tt class="descname">PasswordSet</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordSet"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordSet" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Password Set</p>
<dl class="method">
<dt id="kollacli.commands.password.PasswordSet.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordSet.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordSet.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.password.PasswordSet.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordSet.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordSet.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.password.PasswordSetKey">
<em class="property">class </em><tt class="descclassname">kollacli.commands.password.</tt><tt class="descname">PasswordSetKey</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordSetKey"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordSetKey" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Password Set SSH Key</p>
<dl class="method">
<dt id="kollacli.commands.password.PasswordSetKey.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordSetKey.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordSetKey.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.password.PasswordSetKey.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/password.html#PasswordSetKey.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.password.PasswordSetKey.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.commands.property">
<span id="kollacli-commands-property-module"></span><h2>kollacli.commands.property module<a class="headerlink" href="#module-kollacli.commands.property" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.commands.property.PropertyClear">
<em class="property">class </em><tt class="descclassname">kollacli.commands.property.</tt><tt class="descname">PropertyClear</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/property.html#PropertyClear"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.property.PropertyClear" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Property Clear</p>
<dl class="method">
<dt id="kollacli.commands.property.PropertyClear.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/property.html#PropertyClear.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.property.PropertyClear.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.property.PropertyClear.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/property.html#PropertyClear.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.property.PropertyClear.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.property.PropertyList">
<em class="property">class </em><tt class="descclassname">kollacli.commands.property.</tt><tt class="descname">PropertyList</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/property.html#PropertyList"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.property.PropertyList" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.lister.Lister</span></tt></p>
<p>List all properties.</p>
<dl class="method">
<dt id="kollacli.commands.property.PropertyList.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/property.html#PropertyList.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.property.PropertyList.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.property.PropertyList.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/property.html#PropertyList.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.property.PropertyList.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.property.PropertySet">
<em class="property">class </em><tt class="descclassname">kollacli.commands.property.</tt><tt class="descname">PropertySet</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/property.html#PropertySet"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.property.PropertySet" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Property Set</p>
<dl class="method">
<dt id="kollacli.commands.property.PropertySet.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/property.html#PropertySet.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.property.PropertySet.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.property.PropertySet.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/property.html#PropertySet.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.property.PropertySet.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.commands.pull">
<span id="kollacli-commands-pull-module"></span><h2>kollacli.commands.pull module<a class="headerlink" href="#module-kollacli.commands.pull" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.commands.pull.Pull">
<em class="property">class </em><tt class="descclassname">kollacli.commands.pull.</tt><tt class="descname">Pull</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/pull.html#Pull"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.pull.Pull" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Pull enabled service images onto appropriate hosts.</p>
<dl class="method">
<dt id="kollacli.commands.pull.Pull.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/pull.html#Pull.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.pull.Pull.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.commands.reconfigure">
<span id="kollacli-commands-reconfigure-module"></span><h2>kollacli.commands.reconfigure module<a class="headerlink" href="#module-kollacli.commands.reconfigure" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.commands.reconfigure.Reconfigure">
<em class="property">class </em><tt class="descclassname">kollacli.commands.reconfigure.</tt><tt class="descname">Reconfigure</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/reconfigure.html#Reconfigure"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.reconfigure.Reconfigure" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Reconfigure and update kolla containers on all hosts.</p>
<dl class="method">
<dt id="kollacli.commands.reconfigure.Reconfigure.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/reconfigure.html#Reconfigure.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.reconfigure.Reconfigure.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.reconfigure.Reconfigure.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/reconfigure.html#Reconfigure.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.reconfigure.Reconfigure.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.commands.service">
<span id="kollacli-commands-service-module"></span><h2>kollacli.commands.service module<a class="headerlink" href="#module-kollacli.commands.service" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.commands.service.ServiceAddGroup">
<em class="property">class </em><tt class="descclassname">kollacli.commands.service.</tt><tt class="descname">ServiceAddGroup</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/service.html#ServiceAddGroup"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.service.ServiceAddGroup" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Add group to service.</p>
<p>Associated the service to a group. If this is a sub-service,
the inherit flag will be cleared.</p>
<dl class="method">
<dt id="kollacli.commands.service.ServiceAddGroup.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/service.html#ServiceAddGroup.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.service.ServiceAddGroup.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.service.ServiceAddGroup.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/service.html#ServiceAddGroup.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.service.ServiceAddGroup.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.service.ServiceList">
<em class="property">class </em><tt class="descclassname">kollacli.commands.service.</tt><tt class="descname">ServiceList</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/service.html#ServiceList"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.service.ServiceList" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.lister.Lister</span></tt></p>
<p>List services and their sub-services.</p>
<dl class="method">
<dt id="kollacli.commands.service.ServiceList.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/service.html#ServiceList.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.service.ServiceList.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.service.ServiceListGroups">
<em class="property">class </em><tt class="descclassname">kollacli.commands.service.</tt><tt class="descname">ServiceListGroups</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/service.html#ServiceListGroups"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.service.ServiceListGroups" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.lister.Lister</span></tt></p>
<p>List services and their groups.</p>
<dl class="method">
<dt id="kollacli.commands.service.ServiceListGroups.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/service.html#ServiceListGroups.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.service.ServiceListGroups.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
<dl class="class">
<dt id="kollacli.commands.service.ServiceRemoveGroup">
<em class="property">class </em><tt class="descclassname">kollacli.commands.service.</tt><tt class="descname">ServiceRemoveGroup</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/service.html#ServiceRemoveGroup"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.service.ServiceRemoveGroup" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Remove group from service.</p>
<dl class="method">
<dt id="kollacli.commands.service.ServiceRemoveGroup.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/service.html#ServiceRemoveGroup.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.service.ServiceRemoveGroup.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.service.ServiceRemoveGroup.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/service.html#ServiceRemoveGroup.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.service.ServiceRemoveGroup.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.commands.support">
<span id="kollacli-commands-support-module"></span><h2>kollacli.commands.support module<a class="headerlink" href="#module-kollacli.commands.support" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.commands.support.Dump">
<em class="property">class </em><tt class="descclassname">kollacli.commands.support.</tt><tt class="descname">Dump</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/support.html#Dump"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.support.Dump" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Dumps configuration data for debugging.</p>
<p>Dumps most files in /etc/kolla and /usr/share/kolla into a
tar file so be given to support / development to help with
debugging problems.</p>
<dl class="method">
<dt id="kollacli.commands.support.Dump.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/support.html#Dump.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.support.Dump.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.commands.upgrade">
<span id="kollacli-commands-upgrade-module"></span><h2>kollacli.commands.upgrade module<a class="headerlink" href="#module-kollacli.commands.upgrade" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.commands.upgrade.Upgrade">
<em class="property">class </em><tt class="descclassname">kollacli.commands.upgrade.</tt><tt class="descname">Upgrade</tt><big>(</big><em>app</em>, <em>app_args</em>, <em>cmd_name=None</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/upgrade.html#Upgrade"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.upgrade.Upgrade" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.command.Command</span></tt></p>
<p>Upgrade.</p>
<dl class="method">
<dt id="kollacli.commands.upgrade.Upgrade.get_parser">
<tt class="descname">get_parser</tt><big>(</big><em>prog_name</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/upgrade.html#Upgrade.get_parser"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.upgrade.Upgrade.get_parser" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.commands.upgrade.Upgrade.take_action">
<tt class="descname">take_action</tt><big>(</big><em>parsed_args</em><big>)</big><a class="reference internal" href="_modules/kollacli/commands/upgrade.html#Upgrade.take_action"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.commands.upgrade.Upgrade.take_action" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.commands">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-kollacli.commands" title="Permalink to this headline"></a></h2>
</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="#">kollacli.commands package</a><ul>
<li><a class="reference internal" href="#submodules">Submodules</a></li>
<li><a class="reference internal" href="#module-kollacli.commands.deploy">kollacli.commands.deploy module</a></li>
<li><a class="reference internal" href="#module-kollacli.commands.exceptions">kollacli.commands.exceptions module</a></li>
<li><a class="reference internal" href="#module-kollacli.commands.group">kollacli.commands.group module</a></li>
<li><a class="reference internal" href="#module-kollacli.commands.host">kollacli.commands.host module</a></li>
<li><a class="reference internal" href="#module-kollacli.commands.password">kollacli.commands.password module</a></li>
<li><a class="reference internal" href="#module-kollacli.commands.property">kollacli.commands.property module</a></li>
<li><a class="reference internal" href="#module-kollacli.commands.pull">kollacli.commands.pull module</a></li>
<li><a class="reference internal" href="#module-kollacli.commands.reconfigure">kollacli.commands.reconfigure module</a></li>
<li><a class="reference internal" href="#module-kollacli.commands.service">kollacli.commands.service module</a></li>
<li><a class="reference internal" href="#module-kollacli.commands.support">kollacli.commands.support module</a></li>
<li><a class="reference internal" href="#module-kollacli.commands.upgrade">kollacli.commands.upgrade module</a></li>
<li><a class="reference internal" href="#module-kollacli.commands">Module contents</a></li>
</ul>
</li>
</ul>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/kollacli.commands.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><a href="index.html">kollacli 4.0.1.dev498 documentation</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>

View File

@ -1,298 +0,0 @@
<!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.common.ansible package &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 documentation" 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 4.0.1.dev498 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="kollacli-common-ansible-package">
<h1>kollacli.common.ansible package<a class="headerlink" href="#kollacli-common-ansible-package" title="Permalink to this headline"></a></h1>
<div class="section" id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-kollacli.common.ansible.actions">
<span id="kollacli-common-ansible-actions-module"></span><h2>kollacli.common.ansible.actions module<a class="headerlink" href="#module-kollacli.common.ansible.actions" title="Permalink to this headline"></a></h2>
<dl class="function">
<dt id="kollacli.common.ansible.actions.deploy">
<tt class="descclassname">kollacli.common.ansible.actions.</tt><tt class="descname">deploy</tt><big>(</big><em>hostnames=[]</em>, <em>serial_flag=False</em>, <em>verbose_level=1</em>, <em>servicenames=[]</em><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/actions.html#deploy"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.actions.deploy" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="function">
<dt id="kollacli.common.ansible.actions.destroy_hosts">
<tt class="descclassname">kollacli.common.ansible.actions.</tt><tt class="descname">destroy_hosts</tt><big>(</big><em>hostnames</em>, <em>destroy_type</em>, <em>verbose_level=1</em>, <em>include_data=False</em>, <em>remove_images=False</em><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/actions.html#destroy_hosts"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.actions.destroy_hosts" title="Permalink to this definition"></a></dt>
<dd><p>destroy containers on a set of hosts.</p>
<p>The containers on the specified hosts will be stopped
or killed.</p>
</dd></dl>
<dl class="function">
<dt id="kollacli.common.ansible.actions.precheck">
<tt class="descclassname">kollacli.common.ansible.actions.</tt><tt class="descname">precheck</tt><big>(</big><em>hostnames</em>, <em>verbose_level=1</em><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/actions.html#precheck"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.actions.precheck" title="Permalink to this definition"></a></dt>
<dd><p>run check playbooks on a set of hosts</p>
</dd></dl>
<dl class="function">
<dt id="kollacli.common.ansible.actions.pull">
<tt class="descclassname">kollacli.common.ansible.actions.</tt><tt class="descname">pull</tt><big>(</big><em>verbose_level=1</em><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/actions.html#pull"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.actions.pull" title="Permalink to this definition"></a></dt>
<dd><p>run pull action against all hosts</p>
</dd></dl>
<dl class="function">
<dt id="kollacli.common.ansible.actions.reconfigure">
<tt class="descclassname">kollacli.common.ansible.actions.</tt><tt class="descname">reconfigure</tt><big>(</big><em>verbose_level=1</em><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/actions.html#reconfigure"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.actions.reconfigure" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="function">
<dt id="kollacli.common.ansible.actions.stop_hosts">
<tt class="descclassname">kollacli.common.ansible.actions.</tt><tt class="descname">stop_hosts</tt><big>(</big><em>hostnames=[]</em>, <em>verbose_level=1</em><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/actions.html#stop_hosts"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.actions.stop_hosts" title="Permalink to this definition"></a></dt>
<dd><p>stop containers on a set of hosts.</p>
<p>The containers on the specified hosts will be stopped
or killed if the stop takes over 20 seconds.</p>
</dd></dl>
<dl class="function">
<dt id="kollacli.common.ansible.actions.upgrade">
<tt class="descclassname">kollacli.common.ansible.actions.</tt><tt class="descname">upgrade</tt><big>(</big><em>verbose_level=1</em>, <em>servicenames=[]</em><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/actions.html#upgrade"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.actions.upgrade" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</div>
<div class="section" id="module-kollacli.common.ansible.job">
<span id="kollacli-common-ansible-job-module"></span><h2>kollacli.common.ansible.job module<a class="headerlink" href="#module-kollacli.common.ansible.job" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.common.ansible.job.AnsibleJob">
<em class="property">class </em><tt class="descclassname">kollacli.common.ansible.job.</tt><tt class="descname">AnsibleJob</tt><big>(</big><em>cmd</em>, <em>deploy_id</em>, <em>print_output</em>, <em>inventory_path</em><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/job.html#AnsibleJob"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.job.AnsibleJob" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<p>class for running ansible commands</p>
<dl class="method">
<dt id="kollacli.common.ansible.job.AnsibleJob.get_command_output">
<tt class="descname">get_command_output</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/job.html#AnsibleJob.get_command_output"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.job.AnsibleJob.get_command_output" title="Permalink to this definition"></a></dt>
<dd><p>get command output</p>
<p>get final output text from command execution</p>
</dd></dl>
<dl class="method">
<dt id="kollacli.common.ansible.job.AnsibleJob.get_error_message">
<tt class="descname">get_error_message</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/job.html#AnsibleJob.get_error_message"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.job.AnsibleJob.get_error_message" title="Permalink to this definition"></a></dt>
<dd><p>&#8220;get error message</p>
</dd></dl>
<dl class="method">
<dt id="kollacli.common.ansible.job.AnsibleJob.get_status">
<tt class="descname">get_status</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/job.html#AnsibleJob.get_status"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.job.AnsibleJob.get_status" title="Permalink to this definition"></a></dt>
<dd><p>get process status</p>
<p>status:
- None: running
- 0: done, success
- 1: done, error
- 2: done, killed by user</p>
</dd></dl>
<dl class="method">
<dt id="kollacli.common.ansible.job.AnsibleJob.json_load">
<tt class="descname">json_load</tt><big>(</big><em>string_var</em>, <em>raise_on_err=False</em><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/job.html#AnsibleJob.json_load"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.job.AnsibleJob.json_load" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.common.ansible.job.AnsibleJob.kill">
<tt class="descname">kill</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/job.html#AnsibleJob.kill"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.job.AnsibleJob.kill" title="Permalink to this definition"></a></dt>
<dd><p>kill job in progress</p>
<p>The process pid is owned by root, so
that is not killable. Need to kill all its children.</p>
</dd></dl>
<dl class="method">
<dt id="kollacli.common.ansible.job.AnsibleJob.run">
<tt class="descname">run</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/job.html#AnsibleJob.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.job.AnsibleJob.run" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.common.ansible.job.AnsibleJob.wait">
<tt class="descname">wait</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/job.html#AnsibleJob.wait"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.job.AnsibleJob.wait" title="Permalink to this definition"></a></dt>
<dd><p>wait for job to complete</p>
<p>return status of job (see get_status for status values)</p>
</dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.common.ansible.playbook">
<span id="kollacli-common-ansible-playbook-module"></span><h2>kollacli.common.ansible.playbook module<a class="headerlink" href="#module-kollacli.common.ansible.playbook" title="Permalink to this headline"></a></h2>
<dl class="class">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook">
<em class="property">class </em><tt class="descclassname">kollacli.common.ansible.playbook.</tt><tt class="descname">AnsiblePlaybook</tt><a class="reference internal" href="_modules/kollacli/common/ansible/playbook.html#AnsiblePlaybook"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">object</span></tt></p>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.deploy_id">
<tt class="descname">deploy_id</tt><em class="property"> = None</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.deploy_id" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.extra_vars">
<tt class="descname">extra_vars</tt><em class="property"> = ''</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.extra_vars" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.flush_cache">
<tt class="descname">flush_cache</tt><em class="property"> = True</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.flush_cache" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.groups">
<tt class="descname">groups</tt><em class="property"> = None</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.groups" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.hosts">
<tt class="descname">hosts</tt><em class="property"> = None</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.hosts" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.ignore_error_strings">
<tt class="descname">ignore_error_strings</tt><em class="property"> = None</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.ignore_error_strings" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.include_passwords">
<tt class="descname">include_passwords</tt><em class="property"> = True</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.include_passwords" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.inventory">
<tt class="descname">inventory</tt><em class="property"> = None</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.inventory" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.playbook_path">
<tt class="descname">playbook_path</tt><em class="property"> = ''</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.playbook_path" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.print_output">
<tt class="descname">print_output</tt><em class="property"> = True</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.print_output" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="method">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.run">
<tt class="descname">run</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/kollacli/common/ansible/playbook.html#AnsiblePlaybook.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.run" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.serial">
<tt class="descname">serial</tt><em class="property"> = False</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.serial" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.services">
<tt class="descname">services</tt><em class="property"> = None</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.services" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="attribute">
<dt id="kollacli.common.ansible.playbook.AnsiblePlaybook.verbose_level">
<tt class="descname">verbose_level</tt><em class="property"> = 0</em><a class="headerlink" href="#kollacli.common.ansible.playbook.AnsiblePlaybook.verbose_level" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</dd></dl>
</div>
<div class="section" id="module-kollacli.common.ansible">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-kollacli.common.ansible" title="Permalink to this headline"></a></h2>
</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="#">kollacli.common.ansible package</a><ul>
<li><a class="reference internal" href="#submodules">Submodules</a></li>
<li><a class="reference internal" href="#module-kollacli.common.ansible.actions">kollacli.common.ansible.actions module</a></li>
<li><a class="reference internal" href="#module-kollacli.common.ansible.job">kollacli.common.ansible.job module</a></li>
<li><a class="reference internal" href="#module-kollacli.common.ansible.playbook">kollacli.common.ansible.playbook module</a></li>
<li><a class="reference internal" href="#module-kollacli.common.ansible">Module contents</a></li>
</ul>
</li>
</ul>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/kollacli.common.ansible.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><a href="index.html">kollacli 4.0.1.dev498 documentation</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>

File diff suppressed because it is too large Load Diff

View File

@ -1,197 +0,0 @@
<!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 package &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 documentation" 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 4.0.1.dev498 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="kollacli-package">
<h1>kollacli package<a class="headerlink" href="#kollacli-package" title="Permalink to this headline"></a></h1>
<div class="section" id="subpackages">
<h2>Subpackages<a class="headerlink" href="#subpackages" title="Permalink to this headline"></a></h2>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="kollacli.api.html">kollacli.api package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.client">kollacli.api.client module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.control_plane">kollacli.api.control_plane module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.exceptions">kollacli.api.exceptions module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.group">kollacli.api.group module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.host">kollacli.api.host module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.job">kollacli.api.job module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.password">kollacli.api.password module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.properties">kollacli.api.properties module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.service">kollacli.api.service module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.support">kollacli.api.support module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.api.html#module-kollacli.api">Module contents</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="kollacli.commands.html">kollacli.commands package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.deploy">kollacli.commands.deploy module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.exceptions">kollacli.commands.exceptions module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.group">kollacli.commands.group module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.host">kollacli.commands.host module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.password">kollacli.commands.password module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.property">kollacli.commands.property module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.pull">kollacli.commands.pull module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.reconfigure">kollacli.commands.reconfigure module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.service">kollacli.commands.service module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.support">kollacli.commands.support module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.upgrade">kollacli.commands.upgrade module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands">Module contents</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="kollacli.common.html">kollacli.common package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#subpackages">Subpackages</a><ul>
<li class="toctree-l3"><a class="reference internal" href="kollacli.common.ansible.html">kollacli.common.ansible package</a><ul>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.ansible.html#submodules">Submodules</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.ansible.html#module-kollacli.common.ansible.actions">kollacli.common.ansible.actions module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.ansible.html#module-kollacli.common.ansible.job">kollacli.common.ansible.job module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.ansible.html#module-kollacli.common.ansible.playbook">kollacli.common.ansible.playbook module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.ansible.html#module-kollacli.common.ansible">Module contents</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.allinone">kollacli.common.allinone module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.host">kollacli.common.host module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.host_group">kollacli.common.host_group module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.inventory">kollacli.common.inventory module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.passwords">kollacli.common.passwords module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.properties">kollacli.common.properties module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.service">kollacli.common.service module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.sshutils">kollacli.common.sshutils module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.subservice">kollacli.common.subservice module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.support">kollacli.common.support module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.utils">kollacli.common.utils module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.common.html#module-kollacli.common">Module contents</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="section" id="submodules">
<h2>Submodules<a class="headerlink" href="#submodules" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-kollacli.i18n">
<span id="kollacli-i18n-module"></span><h2>kollacli.i18n module<a class="headerlink" href="#module-kollacli.i18n" title="Permalink to this headline"></a></h2>
</div>
<div class="section" id="module-kollacli.shell">
<span id="kollacli-shell-module"></span><h2>kollacli.shell module<a class="headerlink" href="#module-kollacli.shell" title="Permalink to this headline"></a></h2>
<p>Command-line interface to Kolla</p>
<dl class="class">
<dt id="kollacli.shell.KollaCli">
<em class="property">class </em><tt class="descclassname">kollacli.shell.</tt><tt class="descname">KollaCli</tt><a class="reference internal" href="_modules/kollacli/shell.html#KollaCli"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.shell.KollaCli" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <tt class="xref py py-class docutils literal"><span class="pre">cliff.app.App</span></tt></p>
</dd></dl>
<dl class="function">
<dt id="kollacli.shell.main">
<tt class="descclassname">kollacli.shell.</tt><tt class="descname">main</tt><big>(</big><em>argv=['build_sphinx']</em><big>)</big><a class="reference internal" href="_modules/kollacli/shell.html#main"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#kollacli.shell.main" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
</div>
<div class="section" id="module-kollacli">
<span id="module-contents"></span><h2>Module contents<a class="headerlink" href="#module-kollacli" title="Permalink to this headline"></a></h2>
</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="#">kollacli package</a><ul>
<li><a class="reference internal" href="#subpackages">Subpackages</a></li>
<li><a class="reference internal" href="#submodules">Submodules</a></li>
<li><a class="reference internal" href="#module-kollacli.i18n">kollacli.i18n module</a></li>
<li><a class="reference internal" href="#module-kollacli.shell">kollacli.shell module</a></li>
<li><a class="reference internal" href="#module-kollacli">Module contents</a></li>
</ul>
</li>
</ul>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/kollacli.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><a href="index.html">kollacli 4.0.1.dev498 documentation</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>

View File

@ -1,158 +0,0 @@
<!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 &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 documentation" 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 4.0.1.dev498 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="kollacli">
<h1>kollacli<a class="headerlink" href="#kollacli" title="Permalink to this headline"></a></h1>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="kollacli.html">kollacli package</a><ul>
<li class="toctree-l2"><a class="reference internal" href="kollacli.html#subpackages">Subpackages</a><ul>
<li class="toctree-l3"><a class="reference internal" href="kollacli.api.html">kollacli.api package</a><ul>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#submodules">Submodules</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.client">kollacli.api.client module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.control_plane">kollacli.api.control_plane module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.exceptions">kollacli.api.exceptions module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.group">kollacli.api.group module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.host">kollacli.api.host module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.job">kollacli.api.job module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.password">kollacli.api.password module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.properties">kollacli.api.properties module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.service">kollacli.api.service module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#module-kollacli.api.support">kollacli.api.support module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.api.html#module-kollacli.api">Module contents</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="kollacli.commands.html">kollacli.commands package</a><ul>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#submodules">Submodules</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.deploy">kollacli.commands.deploy module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.exceptions">kollacli.commands.exceptions module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.group">kollacli.commands.group module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.host">kollacli.commands.host module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.password">kollacli.commands.password module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.property">kollacli.commands.property module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.pull">kollacli.commands.pull module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.reconfigure">kollacli.commands.reconfigure module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.service">kollacli.commands.service module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.support">kollacli.commands.support module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands.upgrade">kollacli.commands.upgrade module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.commands.html#module-kollacli.commands">Module contents</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="kollacli.common.html">kollacli.common package</a><ul>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#subpackages">Subpackages</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#submodules">Submodules</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.allinone">kollacli.common.allinone module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.host">kollacli.common.host module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.host_group">kollacli.common.host_group module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.inventory">kollacli.common.inventory module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.passwords">kollacli.common.passwords module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.properties">kollacli.common.properties module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.service">kollacli.common.service module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.sshutils">kollacli.common.sshutils module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.subservice">kollacli.common.subservice module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.support">kollacli.common.support module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common.utils">kollacli.common.utils module</a></li>
<li class="toctree-l4"><a class="reference internal" href="kollacli.common.html#module-kollacli.common">Module contents</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.html#submodules">Submodules</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.html#module-kollacli.i18n">kollacli.i18n module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.html#module-kollacli.shell">kollacli.shell module</a></li>
<li class="toctree-l2"><a class="reference internal" href="kollacli.html#module-kollacli">Module contents</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="_sources/modules.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><a href="index.html">kollacli 4.0.1.dev498 documentation</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>

Binary file not shown.

View File

@ -1,314 +0,0 @@
<!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>Python Module Index &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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 4.0.1.dev498 documentation" 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="#" title="Python Module Index"
>modules</a> |</li>
<li><a href="index.html">kollacli 4.0.1.dev498 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<h1>Python Module Index</h1>
<div class="modindex-jumpbox">
<a href="#cap-k"><strong>k</strong></a>
</div>
<table class="indextable modindextable" cellspacing="0" cellpadding="2">
<tr class="pcap"><td></td><td>&nbsp;</td><td></td></tr>
<tr class="cap" id="cap-k"><td></td><td>
<strong>k</strong></td><td></td></tr>
<tr>
<td><img src="_static/minus.png" class="toggler"
id="toggle-1" style="display: none" alt="-" /></td>
<td>
<a href="kollacli.html#module-kollacli"><tt class="xref">kollacli</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.api.html#module-kollacli.api"><tt class="xref">kollacli.api</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.api.html#module-kollacli.api.client"><tt class="xref">kollacli.api.client</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.api.html#module-kollacli.api.control_plane"><tt class="xref">kollacli.api.control_plane</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.api.html#module-kollacli.api.exceptions"><tt class="xref">kollacli.api.exceptions</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.api.html#module-kollacli.api.group"><tt class="xref">kollacli.api.group</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.api.html#module-kollacli.api.host"><tt class="xref">kollacli.api.host</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.api.html#module-kollacli.api.job"><tt class="xref">kollacli.api.job</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.api.html#module-kollacli.api.password"><tt class="xref">kollacli.api.password</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.api.html#module-kollacli.api.properties"><tt class="xref">kollacli.api.properties</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.api.html#module-kollacli.api.service"><tt class="xref">kollacli.api.service</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.api.html#module-kollacli.api.support"><tt class="xref">kollacli.api.support</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands"><tt class="xref">kollacli.commands</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands.deploy"><tt class="xref">kollacli.commands.deploy</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands.exceptions"><tt class="xref">kollacli.commands.exceptions</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands.group"><tt class="xref">kollacli.commands.group</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands.host"><tt class="xref">kollacli.commands.host</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands.password"><tt class="xref">kollacli.commands.password</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands.property"><tt class="xref">kollacli.commands.property</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands.pull"><tt class="xref">kollacli.commands.pull</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands.reconfigure"><tt class="xref">kollacli.commands.reconfigure</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands.service"><tt class="xref">kollacli.commands.service</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands.support"><tt class="xref">kollacli.commands.support</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.commands.html#module-kollacli.commands.upgrade"><tt class="xref">kollacli.commands.upgrade</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common"><tt class="xref">kollacli.common</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common.allinone"><tt class="xref">kollacli.common.allinone</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.ansible.html#module-kollacli.common.ansible"><tt class="xref">kollacli.common.ansible</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.ansible.html#module-kollacli.common.ansible.actions"><tt class="xref">kollacli.common.ansible.actions</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.ansible.html#module-kollacli.common.ansible.job"><tt class="xref">kollacli.common.ansible.job</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.ansible.html#module-kollacli.common.ansible.playbook"><tt class="xref">kollacli.common.ansible.playbook</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common.host"><tt class="xref">kollacli.common.host</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common.host_group"><tt class="xref">kollacli.common.host_group</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common.inventory"><tt class="xref">kollacli.common.inventory</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common.passwords"><tt class="xref">kollacli.common.passwords</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common.properties"><tt class="xref">kollacli.common.properties</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common.service"><tt class="xref">kollacli.common.service</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common.sshutils"><tt class="xref">kollacli.common.sshutils</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common.subservice"><tt class="xref">kollacli.common.subservice</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common.support"><tt class="xref">kollacli.common.support</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.common.html#module-kollacli.common.utils"><tt class="xref">kollacli.common.utils</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.html#module-kollacli.i18n"><tt class="xref">kollacli.i18n</tt></a></td><td>
<em></em></td></tr>
<tr class="cg-1">
<td></td>
<td>&nbsp;&nbsp;&nbsp;
<a href="kollacli.html#module-kollacli.shell"><tt class="xref">kollacli.shell</tt></a></td><td>
<em></em></td></tr>
</table>
</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="#" title="Python Module Index"
>modules</a> |</li>
<li><a href="index.html">kollacli 4.0.1.dev498 documentation</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>

View File

@ -1,105 +0,0 @@
<!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>Search &mdash; kollacli 4.0.1.dev498 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: '4.0.1.dev498',
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>
<script type="text/javascript" src="_static/searchtools.js"></script>
<link rel="top" title="kollacli 4.0.1.dev498 documentation" href="index.html" />
<script type="text/javascript">
jQuery(function() { Search.loadIndex("searchindex.js"); });
</script>
<script type="text/javascript" id="searchindexloader"></script>
</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 4.0.1.dev498 documentation</a> &raquo;</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<h1 id="search-documentation">Search</h1>
<div id="fallback" class="admonition warning">
<script type="text/javascript">$('#fallback').hide();</script>
<p>
Please activate JavaScript to enable the search
functionality.
</p>
</div>
<p>
From here you can search these documents. Enter your search
words into the box below and click "search". Note that the search
function will automatically search for all of the words. Pages
containing fewer words won't appear in the result list.
</p>
<form action="" method="get">
<input type="text" name="q" value="" />
<input type="submit" value="search" />
<span id="search-progress" style="padding-left: 10px"></span>
</form>
<div id="search-results">
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
</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 4.0.1.dev498 documentation</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>

File diff suppressed because one or more lines are too long