mirror of https://github.com/ansible/ansible.git
Polish the docs up some more. Also make 'index.html' forward to the actual html output
parent
5e453555e3
commit
baf2a05708
@ -1,197 +0,0 @@
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
/* Common
|
||||
/*
|
||||
/*****************************************************************************/
|
||||
|
||||
/* Global Reset */
|
||||
|
||||
* {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: white;
|
||||
font: 13.34px helvetica, arial, clean, sans-serif;
|
||||
*font-size: small;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-size: 100%;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #00a;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: black;
|
||||
}
|
||||
|
||||
a:visited {
|
||||
color: #a0a;
|
||||
}
|
||||
|
||||
table {
|
||||
font-size: inherit;
|
||||
font: 100%;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
/* Home
|
||||
/*
|
||||
/*****************************************************************************/
|
||||
|
||||
ul.posts {
|
||||
list-style-type: none;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
ul.posts li {
|
||||
line-height: 1.75em;
|
||||
}
|
||||
|
||||
ul.posts span {
|
||||
color: #aaa;
|
||||
font-family: Monaco, "Courier New", monospace;
|
||||
font-size: 80%;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
/* Site
|
||||
/*
|
||||
/*****************************************************************************/
|
||||
|
||||
.site {
|
||||
font-size: 110%;
|
||||
text-align: justify;
|
||||
width: 40em;
|
||||
margin: 3em auto 2em auto;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: #a00;
|
||||
font-weight: bold;
|
||||
margin-bottom: 2em;
|
||||
}
|
||||
|
||||
.site .title a {
|
||||
color: #a00;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.site .title a:hover {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.site .title a.extra {
|
||||
color: #aaa;
|
||||
text-decoration: none;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.site .title a.extra:hover {
|
||||
color: black;
|
||||
}
|
||||
|
||||
.site .meta {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.site .footer {
|
||||
font-size: 80%;
|
||||
color: #666;
|
||||
border-top: 4px solid #eee;
|
||||
margin-top: 2em;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.site .footer .contact {
|
||||
float: left;
|
||||
margin-right: 3em;
|
||||
}
|
||||
|
||||
.site .footer .contact a {
|
||||
color: #8085C1;
|
||||
}
|
||||
|
||||
.site .footer .rss {
|
||||
margin-top: 1.1em;
|
||||
margin-right: -.2em;
|
||||
float: right;
|
||||
}
|
||||
|
||||
.site .footer .rss img {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
/* Posts
|
||||
/*
|
||||
/*****************************************************************************/
|
||||
|
||||
#post {
|
||||
|
||||
}
|
||||
|
||||
/* standard */
|
||||
|
||||
#post pre {
|
||||
border: 1px solid #ddd;
|
||||
background-color: #eef;
|
||||
padding: 0 .4em;
|
||||
}
|
||||
|
||||
#post ul,
|
||||
#post ol {
|
||||
margin-left: 1.35em;
|
||||
}
|
||||
|
||||
#post code {
|
||||
border: 1px solid #ddd;
|
||||
background-color: #eef;
|
||||
font-size: 85%;
|
||||
padding: 0 .2em;
|
||||
}
|
||||
|
||||
#post pre code {
|
||||
border: none;
|
||||
}
|
||||
|
||||
/* terminal */
|
||||
|
||||
#post pre.terminal {
|
||||
border: 1px solid black;
|
||||
background-color: #333;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#post pre.terminal code {
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
#related {
|
||||
margin-top: 2em;
|
||||
}
|
||||
|
||||
#related h2 {
|
||||
margin-bottom: 1em;
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
.highlight { background: #ffffff; }
|
||||
.highlight .c { color: #999988; font-style: italic } /* Comment */
|
||||
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
|
||||
.highlight .k { font-weight: bold } /* Keyword */
|
||||
.highlight .o { font-weight: bold } /* Operator */
|
||||
.highlight .cm { color: #999988; font-style: italic } /* Comment.Multiline */
|
||||
.highlight .cp { color: #999999; font-weight: bold } /* Comment.Preproc */
|
||||
.highlight .c1 { color: #999988; font-style: italic } /* Comment.Single */
|
||||
.highlight .cs { color: #999999; font-weight: bold; font-style: italic } /* Comment.Special */
|
||||
.highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */
|
||||
.highlight .gd .x { color: #000000; background-color: #ffaaaa } /* Generic.Deleted.Specific */
|
||||
.highlight .ge { font-style: italic } /* Generic.Emph */
|
||||
.highlight .gr { color: #aa0000 } /* Generic.Error */
|
||||
.highlight .gh { color: #999999 } /* Generic.Heading */
|
||||
.highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */
|
||||
.highlight .gi .x { color: #000000; background-color: #aaffaa } /* Generic.Inserted.Specific */
|
||||
.highlight .go { color: #888888 } /* Generic.Output */
|
||||
.highlight .gp { color: #555555 } /* Generic.Prompt */
|
||||
.highlight .gs { font-weight: bold } /* Generic.Strong */
|
||||
.highlight .gu { color: #aaaaaa } /* Generic.Subheading */
|
||||
.highlight .gt { color: #aa0000 } /* Generic.Traceback */
|
||||
.highlight .kc { font-weight: bold } /* Keyword.Constant */
|
||||
.highlight .kd { font-weight: bold } /* Keyword.Declaration */
|
||||
.highlight .kp { font-weight: bold } /* Keyword.Pseudo */
|
||||
.highlight .kr { font-weight: bold } /* Keyword.Reserved */
|
||||
.highlight .kt { color: #445588; font-weight: bold } /* Keyword.Type */
|
||||
.highlight .m { color: #009999 } /* Literal.Number */
|
||||
.highlight .s { color: #d14 } /* Literal.String */
|
||||
.highlight .na { color: #008080 } /* Name.Attribute */
|
||||
.highlight .nb { color: #0086B3 } /* Name.Builtin */
|
||||
.highlight .nc { color: #445588; font-weight: bold } /* Name.Class */
|
||||
.highlight .no { color: #008080 } /* Name.Constant */
|
||||
.highlight .ni { color: #800080 } /* Name.Entity */
|
||||
.highlight .ne { color: #990000; font-weight: bold } /* Name.Exception */
|
||||
.highlight .nf { color: #990000; font-weight: bold } /* Name.Function */
|
||||
.highlight .nn { color: #555555 } /* Name.Namespace */
|
||||
.highlight .nt { color: #000080 } /* Name.Tag */
|
||||
.highlight .nv { color: #008080 } /* Name.Variable */
|
||||
.highlight .ow { font-weight: bold } /* Operator.Word */
|
||||
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
|
||||
.highlight .mf { color: #009999 } /* Literal.Number.Float */
|
||||
.highlight .mh { color: #009999 } /* Literal.Number.Hex */
|
||||
.highlight .mi { color: #009999 } /* Literal.Number.Integer */
|
||||
.highlight .mo { color: #009999 } /* Literal.Number.Oct */
|
||||
.highlight .sb { color: #d14 } /* Literal.String.Backtick */
|
||||
.highlight .sc { color: #d14 } /* Literal.String.Char */
|
||||
.highlight .sd { color: #d14 } /* Literal.String.Doc */
|
||||
.highlight .s2 { color: #d14 } /* Literal.String.Double */
|
||||
.highlight .se { color: #d14 } /* Literal.String.Escape */
|
||||
.highlight .sh { color: #d14 } /* Literal.String.Heredoc */
|
||||
.highlight .si { color: #d14 } /* Literal.String.Interpol */
|
||||
.highlight .sx { color: #d14 } /* Literal.String.Other */
|
||||
.highlight .sr { color: #009926 } /* Literal.String.Regex */
|
||||
.highlight .s1 { color: #d14 } /* Literal.String.Single */
|
||||
.highlight .ss { color: #990073 } /* Literal.String.Symbol */
|
||||
.highlight .bp { color: #999999 } /* Name.Builtin.Pseudo */
|
||||
.highlight .vc { color: #008080 } /* Name.Variable.Class */
|
||||
.highlight .vg { color: #008080 } /* Name.Variable.Global */
|
||||
.highlight .vi { color: #008080 } /* Name.Variable.Instance */
|
||||
.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
|
||||
|
@ -1,95 +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 — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 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><a href="../index.html">Taboot v0.4.0 documentation</a> »</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="taboot/output.html">taboot.output</a></li>
|
||||
<li><a href="taboot/runner.html">taboot.runner</a></li>
|
||||
<li><a href="taboot/tasks.html">taboot.tasks</a></li>
|
||||
<ul><li><a href="taboot/tasks/command.html">taboot.tasks.command</a></li>
|
||||
<li><a href="taboot/tasks/mod_jk.html">taboot.tasks.mod_jk</a></li>
|
||||
<li><a href="taboot/tasks/nagios.html">taboot.tasks.nagios</a></li>
|
||||
<li><a href="taboot/tasks/poller.html">taboot.tasks.poller</a></li>
|
||||
<li><a href="taboot/tasks/puppet.html">taboot.tasks.puppet</a></li>
|
||||
<li><a href="taboot/tasks/rpm.html">taboot.tasks.rpm</a></li>
|
||||
<li><a href="taboot/tasks/service.html">taboot.tasks.service</a></li>
|
||||
<li><a href="taboot/tasks/sleep.html">taboot.tasks.sleep</a></li>
|
||||
<li><a href="taboot/tasks/yum.html">taboot.tasks.yum</a></li>
|
||||
</ul></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" size="18" />
|
||||
<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><a href="../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,618 +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>taboot.output — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 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><a href="../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../index.html" accesskey="U">Module code</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.output</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2009,2011, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks.puppet</span> <span class="kn">import</span> <span class="n">PuppetTaskResult</span>
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks.rpm</span> <span class="kn">import</span> <span class="n">RPMTaskResult</span>
|
||||
<span class="kn">import</span> <span class="nn">re</span>
|
||||
|
||||
|
||||
<span class="k">class</span> <span class="nc">_FileLikeOutputObject</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> A file-like parent class.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">exceptions</span>
|
||||
<span class="kn">import</span> <span class="nn">time</span> <span class="kn">as</span> <span class="nn">_time</span>
|
||||
<span class="n">defaults</span> <span class="o">=</span> <span class="bp">None</span>
|
||||
<span class="n">starttime</span> <span class="o">=</span> <span class="bp">None</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="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Creates an instance of a file-like object.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `args`: all non-keyword arguments.</span>
|
||||
<span class="sd"> - `kwargs`: all keyword arguments.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">ConfigParser</span>
|
||||
<span class="kn">import</span> <span class="nn">os.path</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">_FileLikeOutputObject</span><span class="o">.</span><span class="n">defaults</span> <span class="ow">is</span> <span class="bp">None</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">expanduser</span><span class="p">(</span><span class="s">"~/.taboot.conf"</span><span class="p">):</span>
|
||||
<span class="n">_FileLikeOutputObject</span><span class="o">.</span><span class="n">defaults</span> <span class="o">=</span> <span class="n">ConfigParser</span><span class="o">.</span><span class="n">ConfigParser</span><span class="p">()</span>
|
||||
<span class="n">_FileLikeOutputObject</span><span class="o">.</span><span class="n">defaults</span><span class="o">.</span><span class="n">read</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="s">"~/.taboot.conf"</span><span class="p">))</span>
|
||||
|
||||
<span class="c"># Only set the start time once, not for each logger instance</span>
|
||||
<span class="k">if</span> <span class="n">_FileLikeOutputObject</span><span class="o">.</span><span class="n">starttime</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
|
||||
<span class="kn">import</span> <span class="nn">datetime</span>
|
||||
<span class="n">_FileLikeOutputObject</span><span class="o">.</span><span class="n">starttime</span> <span class="o">=</span> <span class="n">datetime</span><span class="o">.</span><span class="n">datetime</span><span class="o">.</span><span class="n">today</span><span class="p">()</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_pos</span> <span class="o">=</span> <span class="il">0L</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_closed</span> <span class="o">=</span> <span class="bp">False</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_setup</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_setup</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Implementation specific setup.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `args`: all non-keyword arguments.</span>
|
||||
<span class="sd"> - `kwargs`: all keyword arguments.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">flush</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> We are not buffering so we always just return None.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="bp">None</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">read</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> We are an output only file-like object. Raise exception.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `args`: all non-keyword arguments.</span>
|
||||
<span class="sd"> - `kwargs`: all keyword arguments.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">raise</span> <span class="bp">self</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">NotImplementedError</span><span class="p">(</span><span class="s">'Object for output only.'</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">tell</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Returns the position of the file-like object.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pos</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">truncate</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">size</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> We are an output only file-like object. Raise exception.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `size`: size to truncate to.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">raise</span> <span class="bp">self</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">NotImplementedError</span><span class="p">(</span>
|
||||
<span class="s">'This does not support truncate.'</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">writelines</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sequence</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Writes a sequence of lines.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `sequence`: iterable sequence of data to write.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">sequence</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Writer wrapper (not rapper, beav). Simply calls _write which is</span>
|
||||
<span class="sd"> implementation specific and updates the position.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `item`: the item to write.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_write</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_pos</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Implementation of writing data.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `item`: the item to write.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">raise</span> <span class="bp">self</span><span class="o">.</span><span class="n">exceptions</span><span class="o">.</span><span class="n">NotImplementedError</span><span class="p">(</span>
|
||||
<span class="s">'_write must be overriden.'</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Close wrapper (again, not rapper, beav). Simply calls _close which</span>
|
||||
<span class="sd"> is implementation specific and updates the closed property.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</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">_closed</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_close</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Implementation of closing the file-like object.</span>
|
||||
<span class="sd"> By default nothing occurs.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="c"># Read aliases</span>
|
||||
<span class="n">readline</span> <span class="o">=</span> <span class="n">read</span>
|
||||
<span class="n">readlines</span> <span class="o">=</span> <span class="n">read</span>
|
||||
<span class="n">xreadlines</span> <span class="o">=</span> <span class="n">read</span>
|
||||
<span class="n">seek</span> <span class="o">=</span> <span class="n">read</span>
|
||||
|
||||
<span class="c"># Read-only Properties</span>
|
||||
<span class="n">closed</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_closed</span><span class="p">)</span>
|
||||
<span class="n">timestamp</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="k">lambda</span> <span class="bp">self</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_time</span><span class="o">.</span><span class="n">strftime</span><span class="p">(</span>
|
||||
<span class="s">"%Y-%m-</span><span class="si">%d</span><span class="s"> %H:%M:%S"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_time</span><span class="o">.</span><span class="n">localtime</span><span class="p">()))</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="CLIOutput"><a class="viewcode-back" href="../../code.html#taboot.output.CLIOutput">[docs]</a><span class="k">class</span> <span class="nc">CLIOutput</span><span class="p">(</span><span class="n">_FileLikeOutputObject</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Output a :class:`taboot.tasks.TaskResult` to the command line</span>
|
||||
<span class="sd"> with pretty formatting and colors.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_setup</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">task</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Implementation specific setup for outputting to the CLI.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `host`: name of the host</span>
|
||||
<span class="sd"> - `task`: name of the task</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">Colors</span>
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span> <span class="o">=</span> <span class="n">Colors</span><span class="o">.</span><span class="n">Colors</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span> <span class="o">=</span> <span class="n">sys</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">'</span><span class="si">%s</span><span class="s">:</span><span class="se">\n</span><span class="s">'</span> <span class="o">%</span> <span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="s">'blue'</span><span class="p">)))</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">'</span><span class="si">%s</span><span class="s"> Starting Task[</span><span class="si">%s</span><span class="s">]</span><span class="se">\n</span><span class="s">'</span> <span class="o">%</span> <span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">task</span><span class="p">,</span> <span class="s">'white'</span><span class="p">)))</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Implementation of writing to the CLI.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `result`: result object to inspect and write</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">types</span>
|
||||
|
||||
<span class="c"># Set output color</span>
|
||||
<span class="n">output_color</span> <span class="o">=</span> <span class="s">'red'</span>
|
||||
<span class="k">if</span> <span class="n">result</span><span class="o">.</span><span class="n">success</span><span class="p">:</span>
|
||||
<span class="n">output_color</span> <span class="o">=</span> <span class="s">'green'</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s">:</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">host</span><span class="p">,</span> <span class="s">'blue'</span><span class="p">)))</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s"> Finished Task[</span><span class="si">%s</span><span class="s">]:</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span>
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">task</span><span class="p">,</span> <span class="n">output_color</span><span class="p">)))</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">PuppetTaskResult</span><span class="p">):</span>
|
||||
<span class="c"># If result is an instance of PuppetTaskResult,</span>
|
||||
<span class="c"># colorize the puppet output</span>
|
||||
<span class="n">lines</span> <span class="o">=</span> <span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="o">.</span><span class="n">splitlines</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="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">'info:'</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span>
|
||||
<span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> <span class="s">'green'</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">'notice:'</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span>
|
||||
<span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> <span class="s">'blue'</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">'warning:'</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span>
|
||||
<span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> <span class="s">'yellow'</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">'err:'</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span>
|
||||
<span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> <span class="s">'red'</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">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span>
|
||||
<span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> <span class="s">'normal'</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">RPMTaskResult</span><span class="p">):</span>
|
||||
<span class="c"># If result is an instance of RPMTaskResult,</span>
|
||||
<span class="c"># colorize the rpm.PostManifest output</span>
|
||||
<span class="n">lines</span> <span class="o">=</span> <span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="o">.</span><span class="n">splitlines</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="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">'-'</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span>
|
||||
<span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> <span class="s">'red'</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">'+'</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span>
|
||||
<span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> <span class="s">'green'</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">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span>
|
||||
<span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> <span class="s">'normal'</span><span class="p">))</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c"># Use standard pass/fall coloring for output</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="p">,</span> <span class="n">types</span><span class="o">.</span><span class="n">ListType</span><span class="p">):</span>
|
||||
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span>
|
||||
<span class="n">r</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span> <span class="n">output_color</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">_sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span>
|
||||
<span class="n">result</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="n">output_color</span><span class="p">))</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="LogOutput"><a class="viewcode-back" href="../../code.html#taboot.output.LogOutput">[docs]</a><span class="k">class</span> <span class="nc">LogOutput</span><span class="p">(</span><span class="n">_FileLikeOutputObject</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Output a :class:`taboot.tasks.TaskResult` to a logfile.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_setup</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">task</span><span class="p">,</span> <span class="n">logfile</span><span class="o">=</span><span class="s">'taboot.log'</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Implementation specific setup for outputting to a log.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `logfile`: name of the logfile to write to.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_logfile</span> <span class="o">=</span> <span class="n">logfile</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_logfile</span> <span class="ow">in</span> <span class="p">(</span><span class="s">'-'</span><span class="p">,</span> <span class="s">'stdout'</span><span class="p">,</span> <span class="s">'1'</span><span class="p">):</span>
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span> <span class="o">=</span> <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">logfile</span><span class="p">,</span> <span class="s">'a'</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">'</span><span class="si">%s</span><span class="s">:</span><span class="se">\n</span><span class="si">%s</span><span class="s"> Starting Task[</span><span class="si">%s</span><span class="s">]</span><span class="se">\n\n</span><span class="s">'</span> <span class="o">%</span> <span class="p">(</span>
|
||||
<span class="n">host</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span> <span class="n">task</span><span class="p">))</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Implementation of writing to a log.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `result`: result object to inspect and write</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">types</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">result</span><span class="o">.</span><span class="n">success</span><span class="p">:</span>
|
||||
<span class="n">success_str</span> <span class="o">=</span> <span class="s">'OK'</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">success_str</span> <span class="o">=</span> <span class="s">'FAIL'</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s">:</span><span class="se">\n</span><span class="si">%s</span><span class="s"> Finished Task[</span><span class="si">%s</span><span class="s">]: </span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span>
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">host</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span> <span class="n">result</span><span class="o">.</span><span class="n">task</span><span class="p">,</span> <span class="n">success_str</span><span class="p">))</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="p">,</span> <span class="n">types</span><span class="o">.</span><span class="n">ListType</span><span class="p">):</span>
|
||||
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n\n</span><span class="s">"</span> <span class="o">%</span> <span class="n">r</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="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="se">\n\n</span><span class="s">"</span> <span class="o">%</span> <span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="o">.</span><span class="n">strip</span><span class="p">())</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="EmailOutput"><a class="viewcode-back" href="../../code.html#taboot.output.EmailOutput">[docs]</a><span class="k">class</span> <span class="nc">EmailOutput</span><span class="p">(</span><span class="n">_FileLikeOutputObject</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Output a :class:`taboot.tasks.TaskResult` to a logfile.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_setup</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">to_addr</span><span class="p">,</span> <span class="n">from_addr</span><span class="o">=</span><span class="s">'taboot@redhat.com'</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Implementation specific setup for outputting to a log.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `to_addr`: who to send the email to.</span>
|
||||
<span class="sd"> - `from_addr`: who the email is from.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="kn">import</span> <span class="nn">cStringIO</span> <span class="kn">as</span> <span class="nn">StringIO</span>
|
||||
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">,</span> <span class="n">ie</span><span class="p">:</span>
|
||||
<span class="kn">import</span> <span class="nn">StringIO</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_to_addr</span> <span class="o">=</span> <span class="n">to_addr</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_from_addr</span> <span class="o">=</span> <span class="n">from_addr</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_buffer</span> <span class="o">=</span> <span class="n">StringIO</span><span class="o">.</span><span class="n">StringIO</span><span class="p">()</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Implementation of writing out to an email.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `result`: result object to inspect and write</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="n">result</span><span class="o">.</span><span class="n">success</span><span class="p">:</span>
|
||||
<span class="n">success_str</span> <span class="o">=</span> <span class="s">'OK'</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">success_str</span> <span class="o">=</span> <span class="s">'FAIL'</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_buffer</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">task_result</span><span class="o">.</span><span class="n">task</span><span class="p">,</span> <span class="n">success_str</span><span class="p">))</span>
|
||||
|
||||
<div class="viewcode-block" id="EmailOutput.flush"><a class="viewcode-back" href="../../code.html#taboot.output.EmailOutput.flush">[docs]</a> <span class="k">def</span> <span class="nf">flush</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Flushing sends the email with the buffer.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">smtplib</span>
|
||||
<span class="kn">from</span> <span class="nn">email.mime.text</span> <span class="kn">import</span> <span class="n">MIMEText</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_buffer</span><span class="o">.</span><span class="n">flush</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">MIMEText</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_buffer</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
|
||||
<span class="n">msg</span><span class="p">[</span><span class="s">'Subject'</span><span class="p">]</span> <span class="o">=</span> <span class="n">task_result</span><span class="o">.</span><span class="n">host</span>
|
||||
<span class="n">msg</span><span class="p">[</span><span class="s">'From'</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_from_addr</span>
|
||||
<span class="n">msg</span><span class="p">[</span><span class="s">'To'</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_to_addr</span>
|
||||
|
||||
<span class="n">smtp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">smtplib</span><span class="o">.</span><span class="n">SMTP</span><span class="p">()</span>
|
||||
<span class="n">smtp</span><span class="o">.</span><span class="n">connect</span><span class="p">()</span>
|
||||
<span class="n">smtp</span><span class="o">.</span><span class="n">sendmail</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_from_addr</span><span class="p">,</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_to_addr</span><span class="p">],</span> <span class="n">msg</span><span class="o">.</span><span class="n">as_string</span><span class="p">())</span>
|
||||
<span class="n">smtp</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
|
||||
</div>
|
||||
<span class="k">def</span> <span class="nf">__del__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> If the buffer is not empty before destroying, flush.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_buffer</span><span class="o">.</span><span class="n">pos</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">_buffer</span><span class="o">.</span><span class="n">len</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="HTMLOutput"><a class="viewcode-back" href="../../code.html#taboot.output.HTMLOutput">[docs]</a><span class="k">class</span> <span class="nc">HTMLOutput</span><span class="p">(</span><span class="n">_FileLikeOutputObject</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Output a :class:`taboot.tasks.TaskResult` to the command line</span>
|
||||
<span class="sd"> with pretty formatting and colors.</span>
|
||||
|
||||
<span class="sd"> .. document private functions</span>
|
||||
<span class="sd"> .. automethod:: _write</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">logfile_path</span> <span class="o">=</span> <span class="bp">None</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_expand_starttime</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Expand any instances of "%s" in `param`</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="s">'</span><span class="si">%s</span><span class="s">'</span> <span class="ow">in</span> <span class="n">param</span><span class="p">:</span>
|
||||
<span class="n">p</span> <span class="o">=</span> <span class="n">param</span> <span class="o">%</span> <span class="n">HTMLOutput</span><span class="o">.</span><span class="n">starttime</span>
|
||||
<span class="k">return</span> <span class="n">p</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s">" "</span><span class="p">,</span> <span class="s">"-"</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_setup</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">host</span><span class="p">,</span> <span class="n">task</span><span class="p">,</span> <span class="n">logfile</span><span class="o">=</span><span class="s">"taboot-</span><span class="si">%s</span><span class="s">.html"</span><span class="p">,</span> <span class="n">destdir</span><span class="o">=</span><span class="s">"."</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Implementation specific setup for outputting to an HTML file.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `host`: name of the host</span>
|
||||
<span class="sd"> - `task`: name of the task</span>
|
||||
<span class="sd"> - `logfile`: name of the file to log to, '%s' is substituted</span>
|
||||
<span class="sd"> with a datestamp</span>
|
||||
<span class="sd"> - `destdir`: directory in which to save the log file to</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">Colors</span>
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="kn">import</span> <span class="nn">os.path</span>
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
|
||||
<span class="n">_default_logfile</span> <span class="o">=</span> <span class="s">"taboot-</span><span class="si">%s</span><span class="s">.html"</span>
|
||||
<span class="n">_default_destdir</span> <span class="o">=</span> <span class="s">"."</span>
|
||||
|
||||
<span class="c"># Pick if the parameter is changed</span>
|
||||
<span class="c"># Pick if above is false and logfile is set in defaults</span>
|
||||
<span class="c"># Else, use parameter</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">logfile</span> <span class="o">==</span> <span class="n">_default_logfile</span><span class="p">:</span>
|
||||
<span class="n">_logfile</span> <span class="o">=</span> <span class="n">logfile</span>
|
||||
<span class="k">elif</span> <span class="n">HTMLOutput</span><span class="o">.</span><span class="n">defaults</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span> \
|
||||
<span class="n">HTMLOutput</span><span class="o">.</span><span class="n">defaults</span><span class="o">.</span><span class="n">has_option</span><span class="p">(</span><span class="s">"HTMLOutput"</span><span class="p">,</span> <span class="s">"logfile"</span><span class="p">):</span>
|
||||
<span class="n">_logfile</span> <span class="o">=</span> <span class="n">HTMLOutput</span><span class="o">.</span><span class="n">defaults</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"HTMLOutput"</span><span class="p">,</span> <span class="s">"logfile"</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">_logfile</span> <span class="o">=</span> <span class="n">logfile</span>
|
||||
|
||||
<span class="c"># Expand %s into a time stamp if necessary</span>
|
||||
<span class="n">_logfile</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_expand_starttime</span><span class="p">(</span><span class="n">_logfile</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">destdir</span> <span class="o">==</span> <span class="n">_default_destdir</span><span class="p">:</span>
|
||||
<span class="n">_destdir</span> <span class="o">=</span> <span class="n">destdir</span>
|
||||
<span class="k">elif</span> <span class="n">HTMLOutput</span><span class="o">.</span><span class="n">defaults</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span> \
|
||||
<span class="n">HTMLOutput</span><span class="o">.</span><span class="n">defaults</span><span class="o">.</span><span class="n">has_option</span><span class="p">(</span><span class="s">"HTMLOutput"</span><span class="p">,</span> <span class="s">"destdir"</span><span class="p">):</span>
|
||||
<span class="n">_destdir</span> <span class="o">=</span> <span class="n">HTMLOutput</span><span class="o">.</span><span class="n">defaults</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s">"HTMLOutput"</span><span class="p">,</span> <span class="s">"destdir"</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">_destdir</span> <span class="o">=</span> <span class="n">destdir</span>
|
||||
|
||||
<span class="c"># Figured it all out, now we join them together!</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_logfile_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">_destdir</span><span class="p">,</span> <span class="n">_logfile</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">_destdir</span><span class="p">):</span>
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">makedirs</span><span class="p">(</span><span class="n">_destdir</span><span class="p">,</span> <span class="mo">0755</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span> <span class="o">=</span> <span class="n">Colors</span><span class="o">.</span><span class="n">HTMLColors</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_logfile_path</span><span class="p">,</span> <span class="s">'a'</span><span class="p">)</span>
|
||||
|
||||
<span class="c"># Lets only print this when it is set or changed</span>
|
||||
<span class="k">if</span> <span class="n">HTMLOutput</span><span class="o">.</span><span class="n">logfile_path</span> <span class="ow">is</span> <span class="bp">None</span> <span class="ow">or</span> \
|
||||
<span class="ow">not</span> <span class="n">HTMLOutput</span><span class="o">.</span><span class="n">logfile_path</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">_logfile_path</span><span class="p">:</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"Logging HTML Output to </span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> \
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_logfile_path</span><span class="p">)</span>
|
||||
<span class="n">HTMLOutput</span><span class="o">.</span><span class="n">logfile_path</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_logfile_path</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span>
|
||||
|
||||
<span class="c"># Log the start of this task</span>
|
||||
<span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fmt_anchor</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fmt_hostname</span><span class="p">(</span><span class="n">host</span><span class="p">))</span>
|
||||
<span class="n">start_msg</span> <span class="o">=</span> <span class="s">"""<p><tt></span><span class="si">%s</span><span class="s">:</tt></p></span>
|
||||
<span class="s"><p><tt></span><span class="si">%s</span><span class="s"> Starting Task[</span><span class="si">%s</span><span class="s">]</span><span class="se">\n</span><span class="s"></tt>"""</span> <span class="o">%</span> <span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span> <span class="n">task</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">start_msg</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">flush</span><span class="p">()</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_fmt_anchor</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">text</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Format an #anchor and a clickable link to it</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">h</span> <span class="o">=</span> <span class="nb">hash</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span><span class="p">)</span>
|
||||
<span class="n">anchor_str</span> <span class="o">=</span> <span class="s">"<a name='</span><span class="si">%s</span><span class="s">' href='#</span><span class="si">%s</span><span class="s">'></span><span class="si">%s</span><span class="s"></a>"</span> <span class="o">%</span> <span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">h</span><span class="p">,</span> <span class="n">text</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">anchor_str</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_fmt_hostname</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Standardize the hostname formatting</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="s">"<b></span><span class="si">%s</span><span class="s"></b>"</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">n</span><span class="p">,</span> <span class="s">'blue'</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="HTMLOutput._write"><a class="viewcode-back" href="../../code.html#taboot.output.HTMLOutput._write">[docs]</a> <span class="k">def</span> <span class="nf">_write</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Write a tasks `result` out to HTML. Handles enhanced stylizing</span>
|
||||
<span class="sd"> for task results that support such as:</span>
|
||||
|
||||
<span class="sd"> - :py:mod:`taboot.tasks.puppet.PuppetTaskResult`</span>
|
||||
<span class="sd"> - :py:mod:`taboot.tasks.rpm.RPMTaskResult`</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">types</span>
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="kn">import</span> <span class="nn">cgi</span>
|
||||
|
||||
<span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fmt_hostname</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">host</span><span class="p">)</span>
|
||||
|
||||
<span class="c"># escape any html in result.output</span>
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">output</span> <span class="o">=</span> <span class="n">cgi</span><span class="o">.</span><span class="n">escape</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">result</span><span class="o">.</span><span class="n">success</span><span class="p">:</span>
|
||||
<span class="n">success_str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="s">'<b>OK</b>'</span><span class="p">,</span> <span class="s">'green'</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">success_str</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="s">'<b>FAIL</b>'</span><span class="p">,</span> <span class="s">'red'</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"<p><tt></span><span class="si">%s</span><span class="s">:</span><span class="se">\n</span><span class="s"></tt></p></span><span class="se">\n</span><span class="s"><p><tt></span><span class="si">%s</span><span class="s"> "</span>\
|
||||
<span class="s">"Finished Task[</span><span class="si">%s</span><span class="s">]: </span><span class="si">%s</span><span class="s"></tt></p></span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span> <span class="n">result</span><span class="o">.</span><span class="n">task</span><span class="p">,</span> <span class="n">success_str</span><span class="p">))</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">PuppetTaskResult</span><span class="p">):</span>
|
||||
<span class="c"># If result is an instance of PuppetTaskResult,</span>
|
||||
<span class="c"># colorize the puppet output</span>
|
||||
<span class="n">lines</span> <span class="o">=</span> <span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="o">.</span><span class="n">splitlines</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="k">if</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">'info:'</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s"><br /></span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span>
|
||||
<span class="s">'green'</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">'notice:'</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s"><br /></span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span>
|
||||
<span class="s">'blue'</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">'warning:'</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s"><br /></span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span>
|
||||
<span class="s">'yellow'</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="s">'err:'</span><span class="p">,</span> <span class="n">line</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s"><br /></span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span>
|
||||
<span class="s">'red'</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">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s"><br /></span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span>
|
||||
<span class="s">'normal'</span><span class="p">))</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"<br /><br /></span><span class="se">\n</span><span class="s">"</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">result</span><span class="p">,</span> <span class="n">RPMTaskResult</span><span class="p">):</span>
|
||||
<span class="c"># If result is an instance of RPMTaskResult,</span>
|
||||
<span class="c"># colorize the rpm.PostManifest output</span>
|
||||
<span class="n">lines</span> <span class="o">=</span> <span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="o">.</span><span class="n">splitlines</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="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">'-'</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s"><br /></span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span>
|
||||
<span class="s">'red'</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="n">line</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">'+'</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s"><br /></span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span>
|
||||
<span class="s">'green'</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">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"</span><span class="si">%s</span><span class="s"><br /></span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_c</span><span class="o">.</span><span class="n">format_string</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">strip</span><span class="p">(),</span>
|
||||
<span class="s">'normal'</span><span class="p">))</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"<br /><br /></span><span class="se">\n</span><span class="s">"</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c"># Use standard pass/fall coloring for output</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="p">,</span> <span class="n">types</span><span class="o">.</span><span class="n">ListType</span><span class="p">):</span>
|
||||
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"<pre></span><span class="si">%s</span><span class="s"></pre></span><span class="se">\n</span><span class="s"><br /><br /></span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="n">r</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="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="s">"<pre></span><span class="si">%s</span><span class="s"></pre></span><span class="se">\n</span><span class="s"><br /><br /></span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="n">result</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="bp">self</span><span class="o">.</span><span class="n">_log_fd</span><span class="o">.</span><span class="n">flush</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" size="18" />
|
||||
<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><a href="../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../index.html" >Module code</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,369 +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>taboot.runner — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 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><a href="../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../index.html" accesskey="U">Module code</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.runner</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2009-2011, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">threading</span>
|
||||
<span class="kn">from</span> <span class="nn">taboot.util</span> <span class="kn">import</span> <span class="n">instantiator</span>
|
||||
<span class="kn">from</span> <span class="nn">log</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="Runner"><a class="viewcode-back" href="../../code.html#taboot.runner.Runner">[docs]</a><span class="k">class</span> <span class="nc">Runner</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> The Runner, responsible for running a taboot job.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">threading</span>
|
||||
<span class="kn">import</span> <span class="nn">taboot.output</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">script</span><span class="p">,</span> <span class="n">config</span><span class="p">,</span> <span class="n">expand_globs</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `script`: an instance of tabootScript</span>
|
||||
|
||||
<span class="sd"> - `expand_globs`: whether to expand the globs or just leave</span>
|
||||
<span class="sd"> them as is.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_config</span> <span class="o">=</span> <span class="n">config</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span> <span class="o">=</span> <span class="n">script</span><span class="o">.</span><span class="n">getHosts</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_tasks</span> <span class="o">=</span> <span class="n">script</span><span class="o">.</span><span class="n">getTaskTypes</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_output</span> <span class="o">=</span> <span class="n">script</span><span class="o">.</span><span class="n">getOutputTypes</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_task_q</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_fail_event</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">threading</span><span class="o">.</span><span class="n">Event</span><span class="p">()</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">expand_globs</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="bp">self</span><span class="o">.</span><span class="n">_expand_globs</span><span class="p">()</span>
|
||||
<span class="n">log_debug</span><span class="p">(</span><span class="s">"Will operate on </span><span class="si">%s</span><span class="s"> host(s)."</span><span class="p">,</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="c"># Prefight threading</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_preflight_tasks</span> <span class="o">=</span> <span class="n">script</span><span class="o">.</span><span class="n">getPreflightTypes</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_preflight_semaphore</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">threading</span><span class="o">.</span><span class="n">Semaphore</span><span class="p">(</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="bp">self</span><span class="o">.</span><span class="n">_preflight_tasks_q</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="c"># Main task-body threading</span>
|
||||
<span class="k">if</span> <span class="n">script</span><span class="o">.</span><span class="n">getConcurrency</span><span class="p">()</span> <span class="o">==</span> <span class="s">"all"</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_concurrency</span> <span class="o">=</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="k">else</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_concurrency</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">script</span><span class="o">.</span><span class="n">getConcurrency</span><span class="p">())</span>
|
||||
<span class="n">log_debug</span><span class="p">(</span><span class="s">"Setting task-body concurrency to </span><span class="si">%s</span><span class="s">."</span><span class="p">,</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_concurrency</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_semaphore</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">threading</span><span class="o">.</span><span class="n">Semaphore</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_concurrency</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_run_preflight</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Run the jobs in a prefilght section.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">signal</span>
|
||||
|
||||
<span class="n">rdy_msg</span> <span class="o">=</span> <span class="s">"</span><span class="se">\n</span><span class="s">Pre-Flight complete, press enter to continue: "</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="n">t</span> <span class="o">=</span> <span class="n">TaskRunner</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_preflight_tasks</span><span class="p">,</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_preflight_semaphore</span><span class="p">,</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_output</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fail_event</span><span class="p">)</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_preflight_tasks_q</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
|
||||
<span class="n">signal</span><span class="o">.</span><span class="n">signal</span><span class="p">(</span><span class="n">signal</span><span class="o">.</span><span class="n">SIGINT</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">__sighandler</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">task</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_task_q</span><span class="p">:</span>
|
||||
<span class="k">while</span> <span class="n">task</span><span class="o">.</span><span class="n">isAlive</span><span class="p">():</span>
|
||||
<span class="n">task</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="mf">0.1</span><span class="p">)</span>
|
||||
|
||||
<span class="k">while</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">threading</span><span class="o">.</span><span class="n">enumerate</span><span class="p">())</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="c"># Even though all the threads may have been joined we</span>
|
||||
<span class="c"># should still wait for them to terminate. If we don't</span>
|
||||
<span class="c"># wait for that we will likely see the 'continue?' prompt</span>
|
||||
<span class="c"># before the preflight output gets a chance to print.</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config</span><span class="p">[</span><span class="s">"onlypreflight"</span><span class="p">]:</span>
|
||||
<span class="n">ready</span> <span class="o">=</span> <span class="nb">raw_input</span><span class="p">(</span><span class="n">rdy_msg</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fail_event</span><span class="o">.</span><span class="n">isSet</span><span class="p">():</span>
|
||||
<span class="k">return</span> <span class="bp">False</span>
|
||||
<span class="k">return</span> <span class="bp">True</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_run_tasks</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Run a task body.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">signal</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="n">t</span> <span class="o">=</span> <span class="n">TaskRunner</span><span class="p">(</span><span class="n">host</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tasks</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_semaphore</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_output</span><span class="p">,</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_fail_event</span><span class="p">)</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">start</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_task_q</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
|
||||
<span class="n">signal</span><span class="o">.</span><span class="n">signal</span><span class="p">(</span><span class="n">signal</span><span class="o">.</span><span class="n">SIGINT</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">__sighandler</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">task</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_task_q</span><span class="p">:</span>
|
||||
<span class="k">while</span> <span class="n">task</span><span class="o">.</span><span class="n">isAlive</span><span class="p">():</span>
|
||||
<span class="n">task</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="mf">0.1</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fail_event</span><span class="o">.</span><span class="n">isSet</span><span class="p">():</span>
|
||||
<span class="k">return</span> <span class="bp">False</span>
|
||||
<span class="k">return</span> <span class="bp">True</span>
|
||||
|
||||
<div class="viewcode-block" id="Runner.run"><a class="viewcode-back" href="../../code.html#taboot.runner.Runner.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="sd">"""</span>
|
||||
<span class="sd"> Run the preflight/tasks-body</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_preflight_tasks</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</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">_run_preflight</span><span class="p">():</span>
|
||||
<span class="k">return</span> <span class="bp">False</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_config</span><span class="p">[</span><span class="s">"onlypreflight"</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">self</span><span class="o">.</span><span class="n">_run_tasks</span><span class="p">()</span>
|
||||
</div>
|
||||
<span class="k">def</span> <span class="nf">_expand_globs</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Returns the hosts that expand out from globs.</span>
|
||||
|
||||
<span class="sd"> This is kind of a dirty hack around how Func returns minions</span>
|
||||
<span class="sd"> in an arbitrary order.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">func.overlord.client</span> <span class="kn">as</span> <span class="nn">fc</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</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="p">[]</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</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="nb">basestring</span><span class="p">):</span>
|
||||
<span class="n">glob</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_hosts</span>
|
||||
<span class="n">c</span> <span class="o">=</span> <span class="n">fc</span><span class="o">.</span><span class="n">Client</span><span class="p">(</span><span class="n">glob</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">c</span><span class="o">.</span><span class="n">list_minions</span><span class="p">()</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c"># Iterate over each given item, expand it, and then push</span>
|
||||
<span class="c"># it onto our list. But only if it doesn't exist already!</span>
|
||||
<span class="n">found_hosts</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">h</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">c</span> <span class="o">=</span> <span class="n">fc</span><span class="o">.</span><span class="n">Client</span><span class="p">(</span><span class="n">h</span><span class="p">)</span>
|
||||
<span class="n">new_hosts</span> <span class="o">=</span> <span class="nb">filter</span><span class="p">(</span><span class="k">lambda</span> <span class="n">h</span><span class="p">:</span> <span class="n">h</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">found_hosts</span><span class="p">,</span>
|
||||
<span class="n">c</span><span class="o">.</span><span class="n">list_minions</span><span class="p">())</span>
|
||||
<span class="n">found_hosts</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">new_hosts</span><span class="p">)</span>
|
||||
<span class="c"># for found_host in c.list_minions():</span>
|
||||
<span class="c"># h = filter</span>
|
||||
<span class="c"># if not found_host in found_hosts:</span>
|
||||
<span class="c"># found_hosts.append(found_host)</span>
|
||||
<span class="k">return</span> <span class="n">found_hosts</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__sighandler</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">signal</span><span class="p">,</span> <span class="n">frame</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> If we get SIGINT on the CLI, we need to quit all the threads</span>
|
||||
<span class="sd"> in our process group</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="kn">import</span> <span class="nn">signal</span>
|
||||
|
||||
<span class="n">os</span><span class="o">.</span><span class="n">killpg</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">getpgid</span><span class="p">(</span><span class="mi">0</span><span class="p">),</span> <span class="n">signal</span><span class="o">.</span><span class="n">SIGQUIT</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="TaskRunner"><a class="viewcode-back" href="../../code.html#taboot.runner.TaskRunner">[docs]</a><span class="k">class</span> <span class="nc">TaskRunner</span><span class="p">(</span><span class="n">threading</span><span class="o">.</span><span class="n">Thread</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> TaskRunner is responsible for executing a set of tasks for a</span>
|
||||
<span class="sd"> single host in it's own thread.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks</span> <span class="kn">import</span> <span class="n">TaskResult</span> <span class="k">as</span> <span class="n">_TaskResult</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">host</span><span class="p">,</span> <span class="n">tasks</span><span class="p">,</span> <span class="n">semaphore</span><span class="p">,</span> <span class="n">output</span><span class="p">,</span> <span class="n">fail_event</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `host`: The host to operate on.</span>
|
||||
<span class="sd"> - `tasks`: A list of tasks to perform (see :class:`Runner`)</span>
|
||||
<span class="sd"> - `semaphore`: The :class:`Runner` semaphore to acquire before</span>
|
||||
<span class="sd"> executing</span>
|
||||
<span class="sd"> - `output`: A list of outputters to use. (see :class:`Runner`)</span>
|
||||
<span class="sd"> - `fail_event`: The :class:`Runner` failure event to check before</span>
|
||||
<span class="sd"> executing. If this event is set when the TaskRunner acquires the</span>
|
||||
<span class="sd"> semaphore, then the TaskRunner is effectively a no-op.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">threading</span><span class="o">.</span><span class="n">Thread</span><span class="o">.</span><span class="n">__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">_host</span> <span class="o">=</span> <span class="n">host</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_tasks</span> <span class="o">=</span> <span class="n">tasks</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_semaphore</span> <span class="o">=</span> <span class="n">semaphore</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_output</span> <span class="o">=</span> <span class="n">output</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_fail_event</span> <span class="o">=</span> <span class="n">fail_event</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_state</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_state</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__setitem__</span><span class="p">(</span><span class="bp">self</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="bp">self</span><span class="o">.</span><span class="n">_state</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
|
||||
|
||||
<div class="viewcode-block" id="TaskRunner.run"><a class="viewcode-back" href="../../code.html#taboot.runner.TaskRunner.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="sd">"""</span>
|
||||
<span class="sd"> Run the task(s) for the given host. If the fail_event passed</span>
|
||||
<span class="sd"> from the invoking :class:`Runner` is set, do nothing.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_semaphore</span><span class="o">.</span><span class="n">acquire</span><span class="p">()</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fail_event</span><span class="o">.</span><span class="n">isSet</span><span class="p">():</span>
|
||||
<span class="c"># some other host has bombed</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_semaphore</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
|
||||
<span class="k">return</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">host_success</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
<span class="k">for</span> <span class="n">task</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tasks</span><span class="p">:</span>
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">run_task</span><span class="p">(</span><span class="n">task</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">result</span><span class="o">.</span><span class="n">success</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">result</span><span class="o">.</span><span class="n">ignore_errors</span><span class="p">:</span>
|
||||
<span class="n">host_success</span> <span class="o">=</span> <span class="bp">False</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">except</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_bail_failure</span><span class="p">()</span>
|
||||
<span class="k">raise</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">host_success</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_bail_failure</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">_semaphore</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">host_success</span>
|
||||
</div>
|
||||
<span class="k">def</span> <span class="nf">_bail_failure</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Die nicely :)</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_fail_event</span><span class="o">.</span><span class="n">set</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_semaphore</span><span class="o">.</span><span class="n">release</span><span class="p">()</span>
|
||||
|
||||
<div class="viewcode-block" id="TaskRunner.run_task"><a class="viewcode-back" href="../../code.html#taboot.runner.TaskRunner.run_task">[docs]</a> <span class="k">def</span> <span class="nf">run_task</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">task</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Run a single task. Sets task.host and then invokes the run</span>
|
||||
<span class="sd"> method for the task.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `task`: The task to run</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">ignore_errors</span> <span class="o">=</span> <span class="bp">False</span>
|
||||
<span class="k">if</span> <span class="s">'ignore_errors'</span> <span class="ow">in</span> <span class="n">task</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">task</span><span class="p">[</span><span class="s">'ignore_errors'</span><span class="p">]</span> <span class="ow">in</span> <span class="p">(</span><span class="s">'True'</span><span class="p">,</span> <span class="s">'true'</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span>
|
||||
<span class="n">ignore_errors</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
|
||||
<span class="n">task</span> <span class="o">=</span> <span class="n">instantiator</span><span class="p">(</span><span class="n">task</span><span class="p">,</span> <span class="s">'taboot.tasks'</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">_host</span><span class="p">)</span>
|
||||
|
||||
<span class="n">outputters</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_output</span><span class="p">:</span>
|
||||
<span class="n">instance</span> <span class="o">=</span> <span class="n">instantiator</span><span class="p">(</span><span class="n">o</span><span class="p">,</span> <span class="s">'taboot.output'</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">_host</span><span class="p">,</span>
|
||||
<span class="n">task</span><span class="o">=</span><span class="n">task</span><span class="p">)</span>
|
||||
<span class="n">outputters</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">instance</span><span class="p">)</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="n">task</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span><span class="p">,</span> <span class="n">e</span><span class="p">:</span>
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_TaskResult</span><span class="p">(</span><span class="n">task</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="nb">repr</span><span class="p">(</span><span class="n">e</span><span class="p">))</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">outputters</span><span class="p">:</span>
|
||||
<span class="n">o</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">result</span><span class="p">)</span>
|
||||
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">ignore_errors</span> <span class="o">=</span> <span class="n">ignore_errors</span>
|
||||
<span class="k">return</span> <span class="n">result</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" size="18" />
|
||||
<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><a href="../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../index.html" >Module code</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,263 +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>taboot.tasks — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 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><a href="../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../index.html" accesskey="U">Module code</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.tasks</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2009-2011, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="BaseTask"><a class="viewcode-back" href="../../code.html#taboot.tasks.BaseTask">[docs]</a><span class="k">class</span> <span class="nc">BaseTask</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Base Task. All tasks should inherit from this. It does the</span>
|
||||
<span class="sd"> pretty string representation of a task and allows setting of the</span>
|
||||
<span class="sd"> host attribute.</span>
|
||||
<span class="sd"> """</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="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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="nb">str</span><span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
|
||||
<span class="nb">next</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_name</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="s">"'"</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_name</span><span class="p">[</span><span class="nb">next</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">rindex</span><span class="p">(</span><span class="s">"'"</span><span class="p">)]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_args</span> <span class="o">=</span> <span class="n">args</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">host</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s">'host'</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">concurrentFriendly</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="s">"</span><span class="si">%s%s</span><span class="s">"</span> <span class="o">%</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">_args</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_sethost</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">host</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_host</span> <span class="o">=</span> <span class="n">host</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_gethost</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s">'_host'</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_host</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">None</span>
|
||||
|
||||
<span class="n">host</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="n">_gethost</span><span class="p">,</span> <span class="n">_sethost</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="FuncTask"><a class="viewcode-back" href="../../code.html#taboot.tasks.FuncTask">[docs]</a><span class="k">class</span> <span class="nc">FuncTask</span><span class="p">(</span><span class="n">BaseTask</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> A Func-based task. All tasks that utilize Func should inherit</span>
|
||||
<span class="sd"> from this.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">func.jobthing</span>
|
||||
<span class="kn">from</span> <span class="nn">taboot.errors</span> <span class="kn">import</span> <span class="n">FuncException</span> <span class="k">as</span> <span class="n">_FuncException</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_func_run</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">func_command</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Execute a command via Func.</span>
|
||||
|
||||
<span class="sd"> :Paramaters:</span>
|
||||
<span class="sd"> - `func_command` String representing func command to run</span>
|
||||
<span class="sd"> (e.g. 'command.run')</span>
|
||||
<span class="sd"> - `*args` Argument(s) to be used when invoking the func command</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">time</span>
|
||||
<span class="kn">import</span> <span class="nn">func.overlord.client</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">client</span> <span class="o">=</span> <span class="n">func</span><span class="o">.</span><span class="n">overlord</span><span class="o">.</span><span class="n">client</span><span class="o">.</span><span class="n">Client</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_host</span><span class="p">,</span> <span class="n">async</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
|
||||
<span class="n">job_id</span> <span class="o">=</span> <span class="nb">reduce</span><span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">:</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">),</span>
|
||||
<span class="n">func_command</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">'.'</span><span class="p">),</span>
|
||||
<span class="n">client</span><span class="p">)(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
|
||||
<span class="c"># poll until the job completes</span>
|
||||
<span class="p">(</span><span class="n">status</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span> <span class="o">=</span> <span class="p">(</span><span class="bp">None</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>
|
||||
<span class="k">while</span> <span class="n">status</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">func</span><span class="o">.</span><span class="n">jobthing</span><span class="o">.</span><span class="n">JOB_ID_FINISHED</span><span class="p">:</span>
|
||||
<span class="p">(</span><span class="n">status</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">job_status</span><span class="p">(</span><span class="n">job_id</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">result</span> <span class="o">=</span> <span class="n">result</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_host</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">result</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s">'REMOTE_ERROR'</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="bp">self</span><span class="o">.</span><span class="n">_FuncException</span><span class="p">(</span><span class="n">result</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="bp">True</span><span class="p">,</span> <span class="n">result</span><span class="p">)</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span><span class="p">,</span> <span class="n">ex</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="bp">False</span><span class="p">,</span> <span class="nb">repr</span><span class="p">(</span><span class="n">ex</span><span class="p">))</span>
|
||||
|
||||
<div class="viewcode-block" id="FuncTask.run"><a class="viewcode-back" href="../../code.html#taboot.tasks.FuncTask.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="n">runner</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Run the FuncTask.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `runner` A :class:`taboot.runner.TaskRunner` instance</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s">'_command'</span><span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s">"You MUST set self._command when instantiating "</span> <span class="o">+</span>
|
||||
<span class="s">"a subclass of FuncTask!"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_func_run</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="o">*</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_args</span><span class="p">))</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">result</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
|
||||
<span class="c"># command executed successfully as far as "func success"</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_process_result</span><span class="p">(</span><span class="n">result</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">success</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="n">result</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
|
||||
|
||||
</div></div>
|
||||
<div class="viewcode-block" id="FuncErrorTask"><a class="viewcode-back" href="../../code.html#taboot.tasks.FuncErrorTask">[docs]</a><span class="k">class</span> <span class="nc">FuncErrorTask</span><span class="p">(</span><span class="n">FuncTask</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Explicitly cause a func remote error by calling a bad command.</span>
|
||||
<span class="sd"> Used to verify func exception handling works as expected</span>
|
||||
<span class="sd"> """</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="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">FuncErrorTask</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="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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="s">'thiscommand.DoesntExist'</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="TaskResult"><a class="viewcode-back" href="../../code.html#taboot.tasks.TaskResult">[docs]</a><span class="k">class</span> <span class="nc">TaskResult</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> An encapsulation of the results of a task. This is passed to one</span>
|
||||
<span class="sd"> or more instances of output classes (derived from BaseOutput) in</span>
|
||||
<span class="sd"> order to display to the user.</span>
|
||||
<span class="sd"> """</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">task</span><span class="p">,</span> <span class="n">success</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s">''</span><span class="p">,</span> <span class="n">ignore_errors</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `task`: The task object represented by this result</span>
|
||||
<span class="sd"> - `success`: Whether the task completed successfully or not</span>
|
||||
<span class="sd"> - `output`: Any text output produced by the task</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="n">task</span><span class="p">,</span> <span class="s">'host'</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_host</span> <span class="o">=</span> <span class="n">task</span><span class="o">.</span><span class="n">host</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_task</span> <span class="o">=</span> <span class="nb">repr</span><span class="p">(</span><span class="n">task</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_taskObj</span> <span class="o">=</span> <span class="n">task</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_success</span> <span class="o">=</span> <span class="n">success</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_output</span> <span class="o">=</span> <span class="n">output</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_ignore_errors</span> <span class="o">=</span> <span class="n">ignore_errors</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_gettask</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">_task</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_gettaskObj</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">_taskObj</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_settask</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_task</span> <span class="o">=</span> <span class="nb">repr</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_getsuccess</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">_success</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_setsuccess</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">success</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_success</span> <span class="o">=</span> <span class="n">success</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_getoutput</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">_output</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_setoutput</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">output</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_output</span> <span class="o">=</span> <span class="n">output</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_getignore_errors</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">_ignore_errors</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_setignore_errors</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ignore_errors</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_ignore_errors</span> <span class="o">=</span> <span class="n">ignore_errors</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_gethost</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">_host</span>
|
||||
|
||||
<span class="n">task</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="n">_gettask</span><span class="p">,</span> <span class="n">_settask</span><span class="p">)</span>
|
||||
<span class="n">success</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="n">_getsuccess</span><span class="p">,</span> <span class="n">_setsuccess</span><span class="p">)</span>
|
||||
<span class="n">output</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="n">_getoutput</span><span class="p">,</span> <span class="n">_setoutput</span><span class="p">)</span>
|
||||
<span class="n">ignore_errors</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="n">_getignore_errors</span><span class="p">,</span> <span class="n">_setignore_errors</span><span class="p">)</span>
|
||||
<span class="n">host</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="n">_gethost</span><span class="p">)</span>
|
||||
<span class="n">taskObj</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="n">_gettaskObj</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" size="18" />
|
||||
<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><a href="../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../index.html" >Module code</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,129 +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>taboot.tasks.command — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 documentation" href="../../../index.html" />
|
||||
<link rel="up" title="taboot.tasks" href="../tasks.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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" accesskey="U">taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.tasks.command</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2009,2010, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks</span> <span class="kn">import</span> <span class="n">FuncTask</span><span class="p">,</span> <span class="n">TaskResult</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="Run"><a class="viewcode-back" href="../../../code.html#taboot.tasks.command.Run">[docs]</a><span class="k">class</span> <span class="nc">Run</span><span class="p">(</span><span class="n">FuncTask</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Run arbitrary commands via Func. The arguments passed to __init__</span>
|
||||
<span class="sd"> are used to execute func.overlord.Client.command.run(args).</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `command`: Command to run on the remote host</span>
|
||||
<span class="sd"> """</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">command</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Run</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">command</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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="s">'command.run'</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_process_result</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
|
||||
<span class="n">t</span> <span class="o">=</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">result</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="bp">False</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">output</span> <span class="o">=</span> <span class="n">result</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">return</span> <span class="n">t</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" size="18" />
|
||||
<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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" >taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,190 +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>taboot.tasks.mod_jk — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 documentation" href="../../../index.html" />
|
||||
<link rel="up" title="taboot.tasks" href="../tasks.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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" accesskey="U">taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.tasks.mod_jk</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2009-2011, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks</span> <span class="kn">import</span> <span class="n">BaseTask</span><span class="p">,</span> <span class="n">FuncTask</span><span class="p">,</span> <span class="n">TaskResult</span>
|
||||
|
||||
<span class="n">JK_ENABLE</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="n">JK_DISABLE</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="n">JK_STOP</span> <span class="o">=</span> <span class="mi">2</span>
|
||||
|
||||
|
||||
<span class="k">class</span> <span class="nc">ToggleHost</span><span class="p">(</span><span class="n">FuncTask</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">action</span><span class="p">,</span> <span class="n">proxyhost</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">ToggleHost</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">proxyhost</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_action</span> <span class="o">=</span> <span class="n">action</span>
|
||||
<span class="k">if</span> <span class="n">action</span> <span class="o">==</span> <span class="n">JK_ENABLE</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="s">'taboot.modjk.enable_host'</span>
|
||||
<span class="k">elif</span> <span class="n">action</span> <span class="o">==</span> <span class="n">JK_DISABLE</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="s">'taboot.modjk.disable_host'</span>
|
||||
<span class="k">elif</span> <span class="n">action</span> <span class="o">==</span> <span class="n">JK_STOP</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="s">'taboot.modjk.stop_host'</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="s">"Undefined toggle action"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_process_result</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
|
||||
<span class="n">t</span> <span class="o">=</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">result</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_action</span> <span class="o">==</span> <span class="n">JK_ENABLE</span><span class="p">:</span>
|
||||
<span class="n">verb</span> <span class="o">=</span> <span class="s">'Enabled'</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_action</span> <span class="o">==</span> <span class="n">JK_DISABLE</span><span class="p">:</span>
|
||||
<span class="n">verb</span> <span class="o">=</span> <span class="s">'Disabled'</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">_action</span> <span class="o">==</span> <span class="n">JK_STOP</span><span class="p">:</span>
|
||||
<span class="n">verb</span> <span class="o">=</span> <span class="s">'Stopped'</span>
|
||||
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">output</span> <span class="o">=</span> <span class="s">"</span><span class="si">%s</span><span class="s"> AJP on the following balancer/worker "</span> \
|
||||
<span class="s">"pairs:</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="n">verb</span>
|
||||
<span class="k">for</span> <span class="n">balancer</span><span class="p">,</span> <span class="n">worker</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">output</span> <span class="o">+=</span> <span class="s">"</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">balancer</span><span class="p">,</span> <span class="n">worker</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="bp">False</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">output</span> <span class="o">=</span> <span class="s">"Failed to find worker host"</span>
|
||||
<span class="k">return</span> <span class="n">t</span>
|
||||
|
||||
|
||||
<span class="k">class</span> <span class="nc">JKBaseTask</span><span class="p">(</span><span class="n">BaseTask</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">proxies</span><span class="p">,</span> <span class="n">action</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">JKBaseTask</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="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="kn">from</span> <span class="nn">sys</span> <span class="kn">import</span> <span class="n">modules</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">proxies</span> <span class="o">=</span> <span class="n">proxies</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">jkaction</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">modules</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">__module__</span><span class="p">],</span> <span class="s">"JK_</span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="n">action</span><span class="o">.</span><span class="n">upper</span><span class="p">())</span>
|
||||
|
||||
<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="n">runner</span><span class="p">):</span>
|
||||
<span class="n">output</span> <span class="o">=</span> <span class="s">""</span>
|
||||
<span class="n">success</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
<span class="k">for</span> <span class="n">proxy</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">proxies</span><span class="p">:</span>
|
||||
<span class="n">toggler</span> <span class="o">=</span> <span class="n">ToggleHost</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">jkaction</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_host</span><span class="p">,</span> <span class="n">host</span><span class="o">=</span><span class="n">proxy</span><span class="p">)</span>
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="n">toggler</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">runner</span><span class="p">)</span>
|
||||
<span class="n">output</span> <span class="o">+=</span> <span class="s">"</span><span class="si">%s</span><span class="s">:</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="n">proxy</span>
|
||||
<span class="n">output</span> <span class="o">+=</span> <span class="s">"</span><span class="si">%s</span><span class="se">\n</span><span class="s">"</span> <span class="o">%</span> <span class="n">result</span><span class="o">.</span><span class="n">output</span>
|
||||
<span class="k">if</span> <span class="n">result</span><span class="o">.</span><span class="n">success</span> <span class="o">==</span> <span class="bp">False</span><span class="p">:</span>
|
||||
<span class="n">success</span> <span class="o">=</span> <span class="bp">False</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">return</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">success</span><span class="o">=</span><span class="n">success</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="n">output</span><span class="p">)</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="OutOfRotation"><a class="viewcode-back" href="../../../code.html#taboot.tasks.mod_jk.OutOfRotation">[docs]</a><span class="k">class</span> <span class="nc">OutOfRotation</span><span class="p">(</span><span class="n">JKBaseTask</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Remove an AJP node from rotation on a proxy via modjkapi access on</span>
|
||||
<span class="sd"> the proxy with func.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `proxies`: A list of URLs to AJP jkmanage interfaces</span>
|
||||
<span class="sd"> """</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">proxies</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s">"stop"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">OutOfRotation</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">proxies</span><span class="p">,</span> <span class="n">action</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="InRotation"><a class="viewcode-back" href="../../../code.html#taboot.tasks.mod_jk.InRotation">[docs]</a><span class="k">class</span> <span class="nc">InRotation</span><span class="p">(</span><span class="n">JKBaseTask</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Put an AJP node in rotation on a proxy via modjkapi access on</span>
|
||||
<span class="sd"> the proxy with func.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `proxies`: A list of URLs to AJP jkmanage interfaces</span>
|
||||
<span class="sd"> """</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">proxies</span><span class="p">,</span> <span class="n">action</span><span class="o">=</span><span class="s">"enable"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">InRotation</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">proxies</span><span class="p">,</span> <span class="n">action</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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" size="18" />
|
||||
<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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" >taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,284 +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>taboot.tasks.nagios — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 documentation" href="../../../index.html" />
|
||||
<link rel="up" title="taboot.tasks" href="../tasks.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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" accesskey="U">taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.tasks.nagios</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2009-2011, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks</span> <span class="kn">import</span> <span class="n">BaseTask</span><span class="p">,</span> <span class="n">TaskResult</span><span class="p">,</span> <span class="n">FuncTask</span>
|
||||
<span class="kn">import</span> <span class="nn">taboot.errors</span>
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="NagiosBase"><a class="viewcode-back" href="../../../code.html#taboot.tasks.nagios.NagiosBase">[docs]</a><span class="k">class</span> <span class="nc">NagiosBase</span><span class="p">(</span><span class="n">FuncTask</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> All subsequent Nagios tasks are subclasses of this.</span>
|
||||
|
||||
<span class="sd"> Code note: Because a `FuncTask` expects to make connections to</span>
|
||||
<span class="sd"> `self.host` we need to switch `nagios_url` with `self.host` and</span>
|
||||
<span class="sd"> pass the original `self.host` as an argument.</span>
|
||||
|
||||
<span class="sd"> .. versionchanged:: 0.2.14</span>
|
||||
|
||||
<span class="sd"> The previous version specified the `nagios_url` parameter as a</span>
|
||||
<span class="sd"> URL. To facilitate transitions we automatically correct URLs</span>
|
||||
<span class="sd"> into hostnames.</span>
|
||||
|
||||
<span class="sd"> Previously the `service` key was defined as a scalar, like</span>
|
||||
<span class="sd"> "HTTP" or "JBOSS". This version accepts that key as a scalar OR</span>
|
||||
<span class="sd"> as a list and "does the right thing" in each case.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_fix_nagios_url</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">nagios_url</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> For backwards compatability we accept a Nagios URL that</span>
|
||||
<span class="sd"> identifies an HTTP resource.</span>
|
||||
|
||||
<span class="sd"> This method will take a string like http://foo.com/nagios/cmd.cgi</span>
|
||||
<span class="sd"> and return just the hostname component ("foo.com").</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">re</span>
|
||||
<span class="k">return</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s">r'(https?://)([^/]+)(.*)'</span><span class="p">,</span> <span class="s">r'\2'</span><span class="p">,</span> <span class="n">nagios_url</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_process_result</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
|
||||
<span class="n">t</span> <span class="o">=</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">result</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">"Fail: "</span><span class="p">):</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="bp">False</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">sucess</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">output</span> <span class="o">=</span> <span class="n">result</span>
|
||||
<span class="k">return</span> <span class="n">t</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="DisableAlerts"><a class="viewcode-back" href="../../../code.html#taboot.tasks.nagios.DisableAlerts">[docs]</a><span class="k">class</span> <span class="nc">DisableAlerts</span><span class="p">(</span><span class="n">NagiosBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Disable alerts for a host on a nagios instance</span>
|
||||
<span class="sd"> """</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">nagios_url</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `nagios_url`: Hostname of the Nagios server.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">target_host</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s">'host'</span><span class="p">]</span>
|
||||
<span class="n">kwargs</span><span class="p">[</span><span class="s">'host'</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fix_nagios_url</span><span class="p">(</span><span class="n">nagios_url</span><span class="p">)</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">DisableAlerts</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">target_host</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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="s">'nagios.disable_host_notifications'</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="EnableAlerts"><a class="viewcode-back" href="../../../code.html#taboot.tasks.nagios.EnableAlerts">[docs]</a><span class="k">class</span> <span class="nc">EnableAlerts</span><span class="p">(</span><span class="n">NagiosBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Enable alerts for a host on a nagios instance</span>
|
||||
<span class="sd"> """</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">nagios_url</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `nagios_url`: Hostname of the Nagios server.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">target_host</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s">'host'</span><span class="p">]</span>
|
||||
<span class="n">kwargs</span><span class="p">[</span><span class="s">'host'</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fix_nagios_url</span><span class="p">(</span><span class="n">nagios_url</span><span class="p">)</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">EnableAlerts</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">target_host</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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="s">'nagios.enable_host_notifications'</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="ScheduleDowntime"><a class="viewcode-back" href="../../../code.html#taboot.tasks.nagios.ScheduleDowntime">[docs]</a><span class="k">class</span> <span class="nc">ScheduleDowntime</span><span class="p">(</span><span class="n">NagiosBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Schedule downtime for services on a host in Nagios</span>
|
||||
<span class="sd"> """</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">nagios_url</span><span class="p">,</span> <span class="n">service</span><span class="o">=</span><span class="s">'HOST'</span><span class="p">,</span> <span class="n">minutes</span><span class="o">=</span><span class="mi">30</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `nagios_url`: Hostname of the Nagios server.</span>
|
||||
<span class="sd"> - `service`: Service or list of services to schedule down for.</span>
|
||||
<span class="sd"> - `minutes`: The number of minutes to schedule downtime</span>
|
||||
<span class="sd"> for. Default is 30.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="kn">import</span> <span class="nn">types</span>
|
||||
<span class="n">target_host</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s">'host'</span><span class="p">]</span>
|
||||
<span class="n">kwargs</span><span class="p">[</span><span class="s">'host'</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fix_nagios_url</span><span class="p">(</span><span class="n">nagios_url</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">service</span><span class="p">,</span> <span class="n">types</span><span class="o">.</span><span class="n">StringTypes</span><span class="p">):</span>
|
||||
<span class="n">service</span> <span class="o">=</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="nb">isinstance</span><span class="p">(</span><span class="n">minutes</span><span class="p">,</span> <span class="n">types</span><span class="o">.</span><span class="n">IntType</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">minutes</span><span class="p">,</span> <span class="n">types</span><span class="o">.</span><span class="n">FloatType</span><span class="p">):</span>
|
||||
<span class="n">minutes</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">minutes</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s">"Invalid data given for minutes."</span><span class="p">,</span>
|
||||
<span class="s">"Expecting int type."</span><span class="p">,</span>
|
||||
<span class="s">"Got '</span><span class="si">%s</span><span class="s">'."</span> <span class="o">%</span> <span class="n">minutes</span><span class="p">)</span>
|
||||
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">ScheduleDowntime</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">target_host</span><span class="p">,</span> <span class="n">service</span><span class="p">,</span>
|
||||
<span class="n">minutes</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">service</span> <span class="o">==</span> <span class="s">'HOST'</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="s">"nagios.schedule_host_downtime"</span>
|
||||
<span class="k">else</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="s">'nagios.schedule_svc_downtime'</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_process_result</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
|
||||
<span class="n">t</span> <span class="o">=</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">r</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">"Fail: "</span><span class="p">):</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">&</span> <span class="bp">False</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">sucess</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">&</span> <span class="bp">True</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">output</span> <span class="o">=</span> <span class="n">result</span>
|
||||
<span class="k">return</span> <span class="n">t</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="SilenceHost"><a class="viewcode-back" href="../../../code.html#taboot.tasks.nagios.SilenceHost">[docs]</a><span class="k">class</span> <span class="nc">SilenceHost</span><span class="p">(</span><span class="n">NagiosBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Silence all notifications for a given host</span>
|
||||
<span class="sd"> """</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">nagios_url</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `nagios_url`: Hostname of the Nagios server.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">target_host</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s">'host'</span><span class="p">]</span>
|
||||
<span class="n">kwargs</span><span class="p">[</span><span class="s">'host'</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fix_nagios_url</span><span class="p">(</span><span class="n">nagios_url</span><span class="p">)</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">SilenceHost</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">target_host</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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="s">'nagios.silence_host'</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_process_result</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
|
||||
<span class="n">t</span> <span class="o">=</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">r</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">"Fail: "</span><span class="p">):</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">&</span> <span class="bp">False</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">sucess</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">&</span> <span class="bp">True</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">output</span> <span class="o">=</span> <span class="n">result</span>
|
||||
<span class="k">return</span> <span class="n">t</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="UnsilenceHost"><a class="viewcode-back" href="../../../code.html#taboot.tasks.nagios.UnsilenceHost">[docs]</a><span class="k">class</span> <span class="nc">UnsilenceHost</span><span class="p">(</span><span class="n">NagiosBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Unsilence all notifications for a given host</span>
|
||||
<span class="sd"> """</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">nagios_url</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `nagios_url`: Hostname of the Nagios server.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">target_host</span> <span class="o">=</span> <span class="n">kwargs</span><span class="p">[</span><span class="s">'host'</span><span class="p">]</span>
|
||||
<span class="n">kwargs</span><span class="p">[</span><span class="s">'host'</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fix_nagios_url</span><span class="p">(</span><span class="n">nagios_url</span><span class="p">)</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">UnsilenceHost</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">target_host</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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="s">'nagios.unsilence_host'</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_process_result</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">result</span><span class="p">):</span>
|
||||
<span class="n">t</span> <span class="o">=</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="bp">True</span>
|
||||
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">result</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">r</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">"Fail: "</span><span class="p">):</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">&</span> <span class="bp">False</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">sucess</span> <span class="o">=</span> <span class="n">t</span><span class="o">.</span><span class="n">success</span> <span class="o">&</span> <span class="bp">True</span>
|
||||
<span class="n">t</span><span class="o">.</span><span class="n">output</span> <span class="o">=</span> <span class="n">result</span>
|
||||
<span class="k">return</span> <span class="n">t</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" size="18" />
|
||||
<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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" >taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,149 +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>taboot.tasks.poller — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 documentation" href="../../../index.html" />
|
||||
<link rel="up" title="taboot.tasks" href="../tasks.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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" accesskey="U">taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.tasks.poller</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2009, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks</span> <span class="kn">import</span> <span class="n">BaseTask</span>
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks</span> <span class="kn">import</span> <span class="n">TaskResult</span>
|
||||
<span class="kn">import</span> <span class="nn">time</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="PollTask"><a class="viewcode-back" href="../../../code.html#taboot.tasks.poller.PollTask">[docs]</a><span class="k">class</span> <span class="nc">PollTask</span><span class="p">(</span><span class="n">BaseTask</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> PollTask. A task that will poll a particular task until the task</span>
|
||||
<span class="sd"> succeeds or until max_attempts is reached.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `task` The task to poll.</span>
|
||||
<span class="sd"> - `sleep_interval` The number of seconds to wait before trying</span>
|
||||
<span class="sd"> the task again.</span>
|
||||
<span class="sd"> - `max_attempts` The maximum number of attempts that the task</span>
|
||||
<span class="sd"> should be run.</span>
|
||||
<span class="sd"> - `fail_task` The task to run when max_attempts has been exhausted.</span>
|
||||
<span class="sd"> If no fail_task is provided, then a simple TaskResult</span>
|
||||
<span class="sd"> indicating failure is returned.</span>
|
||||
<span class="sd"> """</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">task</span><span class="p">,</span> <span class="n">sleep_interval</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span> <span class="n">max_attempts</span><span class="o">=</span><span class="mi">6</span><span class="p">,</span>
|
||||
<span class="n">fail_task</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">PollTask</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="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_task</span> <span class="o">=</span> <span class="n">task</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_sleep_interval</span> <span class="o">=</span> <span class="n">sleep_interval</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_max_attempts</span> <span class="o">=</span> <span class="n">max_attempts</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_fail_task</span> <span class="o">=</span> <span class="n">fail_task</span>
|
||||
|
||||
<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="n">runner</span><span class="p">):</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="bp">self</span><span class="o">.</span><span class="n">_max_attempts</span><span class="p">):</span>
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="n">runner</span><span class="o">.</span><span class="n">run_task</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_task</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">result</span><span class="o">.</span><span class="n">success</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">result</span>
|
||||
<span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_sleep_interval</span><span class="p">)</span>
|
||||
|
||||
<span class="c"># exhausted max_attempts</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_fail_task</span> <span class="o">!=</span> <span class="bp">None</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">runner</span><span class="o">.</span><span class="n">run_task</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_fail_task</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c"># return a "failed" TaskResult, stop executing further tasks</span>
|
||||
<span class="k">return</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">success</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
|
||||
<span class="n">output</span><span class="o">=</span><span class="s">"Max attempts of </span><span class="si">%s</span><span class="s"> reached running </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span>
|
||||
<span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_max_attempts</span><span class="p">,</span> <span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_task</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" size="18" />
|
||||
<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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" >taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,196 +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>taboot.tasks.puppet — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 documentation" href="../../../index.html" />
|
||||
<link rel="up" title="taboot.tasks" href="../tasks.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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" accesskey="U">taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.tasks.puppet</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2009-2011, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks</span> <span class="kn">import</span> <span class="n">command</span><span class="p">,</span> <span class="n">TaskResult</span>
|
||||
<span class="kn">import</span> <span class="nn">puppet</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="PuppetBase"><a class="viewcode-back" href="../../../code.html#taboot.tasks.puppet.PuppetBase">[docs]</a><span class="k">class</span> <span class="nc">PuppetBase</span><span class="p">(</span><span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Base class for puppet commands</span>
|
||||
<span class="sd"> """</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">pcmd</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">PuppetBase</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">pcmd</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="Run"><a class="viewcode-back" href="../../../code.html#taboot.tasks.puppet.Run">[docs]</a><span class="k">class</span> <span class="nc">Run</span><span class="p">(</span><span class="n">PuppetBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Run 'puppetd --test || true'</span>
|
||||
|
||||
<span class="sd"> :Optional Parameters:</span>
|
||||
<span class="sd"> - `server`: Puppetmaster to run against</span>
|
||||
<span class="sd"> - `noop`: If this should be a noop run (Boolean)</span>
|
||||
<span class="sd"> - `safe`: Abort if puppet errors (Boolean)</span>
|
||||
|
||||
<span class="sd"> See also: :py:meth:`taboot.tasks.Puppet.SafeRun`</span>
|
||||
<span class="sd"> """</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">server</span><span class="o">=</span><span class="s">""</span><span class="p">,</span> <span class="n">noop</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">safe</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">pcmd</span> <span class="o">=</span> <span class="s">"puppetd --test --color=false"</span>
|
||||
<span class="k">if</span> <span class="n">server</span> <span class="o">!=</span> <span class="s">""</span><span class="p">:</span>
|
||||
<span class="n">pcmd</span> <span class="o">+=</span> <span class="s">" --server=</span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="n">server</span>
|
||||
<span class="k">if</span> <span class="n">noop</span> <span class="o">==</span> <span class="bp">True</span><span class="p">:</span>
|
||||
<span class="n">pcmd</span> <span class="o">+=</span> <span class="s">" --noop"</span>
|
||||
<span class="k">if</span> <span class="n">safe</span> <span class="o">==</span> <span class="bp">False</span><span class="p">:</span>
|
||||
<span class="c"># If safe is False, ignore the return code of the puppet run</span>
|
||||
<span class="n">pcmd</span> <span class="o">+=</span> <span class="s">" || true"</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Run</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">pcmd</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<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="n">runner</span><span class="p">):</span>
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">Run</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">runner</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">PuppetTaskResult</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">taskObj</span><span class="p">,</span> <span class="n">result</span><span class="o">.</span><span class="n">success</span><span class="p">,</span>
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="p">,</span> <span class="n">result</span><span class="o">.</span><span class="n">ignore_errors</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="SafeRun"><a class="viewcode-back" href="../../../code.html#taboot.tasks.puppet.SafeRun">[docs]</a><span class="k">class</span> <span class="nc">SafeRun</span><span class="p">(</span><span class="n">puppet</span><span class="o">.</span><span class="n">Run</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Run 'puppetd --test'.</span>
|
||||
|
||||
<span class="sd"> How is this different from Run? Simple, it will abort everything</span>
|
||||
<span class="sd"> if puppet returns with a non-zero exit status.</span>
|
||||
<span class="sd"> """</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">server</span><span class="o">=</span><span class="s">""</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">SafeRun</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">server</span><span class="p">,</span> <span class="n">safe</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="Enable"><a class="viewcode-back" href="../../../code.html#taboot.tasks.puppet.Enable">[docs]</a><span class="k">class</span> <span class="nc">Enable</span><span class="p">(</span><span class="n">PuppetBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Run 'puppetd --enable'.</span>
|
||||
<span class="sd"> """</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="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Enable</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="s">'puppetd --enable'</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="Disable"><a class="viewcode-back" href="../../../code.html#taboot.tasks.puppet.Disable">[docs]</a><span class="k">class</span> <span class="nc">Disable</span><span class="p">(</span><span class="n">PuppetBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Run 'puppetd --disable'.</span>
|
||||
<span class="sd"> """</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="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Disable</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="s">'puppetd --disable'</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="DeleteLockfile"><a class="viewcode-back" href="../../../code.html#taboot.tasks.puppet.DeleteLockfile">[docs]</a><span class="k">class</span> <span class="nc">DeleteLockfile</span><span class="p">(</span><span class="n">PuppetBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Remove the puppet lock file.</span>
|
||||
<span class="sd"> """</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="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">PUPPET_LOCKFILE</span> <span class="o">=</span> <span class="s">"/var/lib/puppet/state/puppetdlock"</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">DeleteLockfile</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="s">"rm -f </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="n">PUPPET_LOCKFILE</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="PuppetTaskResult"><a class="viewcode-back" href="../../../code.html#taboot.tasks.puppet.PuppetTaskResult">[docs]</a><span class="k">class</span> <span class="nc">PuppetTaskResult</span><span class="p">(</span><span class="n">TaskResult</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Wrapper around TaskResult to be able to differentiate in output class</span>
|
||||
<span class="sd"> """</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">task</span><span class="p">,</span> <span class="n">success</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s">''</span><span class="p">,</span> <span class="n">ignore_errors</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">PuppetTaskResult</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">task</span><span class="p">,</span> <span class="n">success</span><span class="p">,</span> <span class="n">output</span><span class="p">,</span>
|
||||
<span class="n">ignore_errors</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" size="18" />
|
||||
<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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" >taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,189 +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>taboot.tasks.rpm — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 documentation" href="../../../index.html" />
|
||||
<link rel="up" title="taboot.tasks" href="../tasks.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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" accesskey="U">taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.tasks.rpm</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2009,2010, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks</span> <span class="kn">import</span> <span class="n">command</span><span class="p">,</span> <span class="n">TaskResult</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="RPMBase"><a class="viewcode-back" href="../../../code.html#taboot.tasks.rpm.RPMBase">[docs]</a><span class="k">class</span> <span class="nc">RPMBase</span><span class="p">(</span><span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Base class for rpm commands</span>
|
||||
<span class="sd"> """</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">pcmd</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">RPMBase</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">pcmd</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="PreManifest"><a class="viewcode-back" href="../../../code.html#taboot.tasks.rpm.PreManifest">[docs]</a><span class="k">class</span> <span class="nc">PreManifest</span><span class="p">(</span><span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Gather list of installed RPMs. A later invocation of :class:`PostManifest`</span>
|
||||
<span class="sd"> is then used to output the RPMs changed during intermediate tasks.</span>
|
||||
<span class="sd"> """</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="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">PreManifest</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="s">'rpm -qa | sort'</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="PreManifest.run"><a class="viewcode-back" href="../../../code.html#taboot.tasks.rpm.PreManifest.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="n">runner</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Override the default :class:`command.Run` to strip the output</span>
|
||||
<span class="sd"> from the result because we're really not interested in the</span>
|
||||
<span class="sd"> contents of the pre-manifest; we just want to collect it to</span>
|
||||
<span class="sd"> compare later on with PostManifest.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">PreManifest</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">runner</span><span class="p">)</span>
|
||||
<span class="n">runner</span><span class="p">[</span><span class="s">'rpm.PreManifest'</span><span class="p">]</span> <span class="o">=</span> <span class="n">result</span><span class="o">.</span><span class="n">output</span>
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">output</span> <span class="o">=</span> <span class="s">''</span>
|
||||
<span class="k">return</span> <span class="n">result</span>
|
||||
|
||||
</div></div>
|
||||
<div class="viewcode-block" id="PostManifest"><a class="viewcode-back" href="../../../code.html#taboot.tasks.rpm.PostManifest">[docs]</a><span class="k">class</span> <span class="nc">PostManifest</span><span class="p">(</span><span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Gather list of installed RPMs and compare against a previously</span>
|
||||
<span class="sd"> taken :class:`PreManifest`</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">difflib</span> <span class="kn">import</span> <span class="n">Differ</span> <span class="k">as</span> <span class="n">_Differ</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="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">PostManifest</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="s">'rpm -qa | sort'</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="PostManifest.run"><a class="viewcode-back" href="../../../code.html#taboot.tasks.rpm.PostManifest.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="n">runner</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> The runner that gets passed in contains state that can be</span>
|
||||
<span class="sd"> access via dict-like access. PreManifest uses this to write</span>
|
||||
<span class="sd"> to the rpm.Premanifest field. So we'll check to make sure the</span>
|
||||
<span class="sd"> pre-manifest is there by looking for that state.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">pre_manifest</span> <span class="o">=</span> <span class="n">runner</span><span class="p">[</span><span class="s">'rpm.PreManifest'</span><span class="p">]</span>
|
||||
<span class="k">except</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">success</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span>
|
||||
<span class="n">output</span><span class="o">=</span><span class="s">"You must use PreManifest before PostManifest"</span><span class="p">)</span>
|
||||
|
||||
<span class="c"># ok, so now we have something to compare against so we get</span>
|
||||
<span class="c"># new state...</span>
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">run</span><span class="p">(</span><span class="n">runner</span><span class="p">)</span>
|
||||
|
||||
<span class="n">old_list</span> <span class="o">=</span> <span class="n">pre_manifest</span><span class="o">.</span><span class="n">splitlines</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="n">new_list</span> <span class="o">=</span> <span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="o">.</span><span class="n">splitlines</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="n">differ</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Differ</span><span class="p">()</span>
|
||||
<span class="n">diff_output</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">differ</span><span class="o">.</span><span class="n">compare</span><span class="p">(</span><span class="n">old_list</span><span class="p">,</span> <span class="n">new_list</span><span class="p">))</span>
|
||||
<span class="n">diff_output</span> <span class="o">=</span> <span class="p">[</span><span class="n">line</span> <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">diff_output</span> <span class="k">if</span> <span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="p">(</span><span class="s">'+'</span><span class="p">,</span> <span class="s">'-'</span><span class="p">)]</span>
|
||||
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">output</span> <span class="o">=</span> <span class="s">''</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">diff_output</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">RPMTaskResult</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">taskObj</span><span class="p">,</span> <span class="n">result</span><span class="o">.</span><span class="n">success</span><span class="p">,</span>
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">output</span><span class="p">,</span> <span class="n">result</span><span class="o">.</span><span class="n">ignore_errors</span><span class="p">)</span>
|
||||
|
||||
</div></div>
|
||||
<div class="viewcode-block" id="RPMTaskResult"><a class="viewcode-back" href="../../../code.html#taboot.tasks.rpm.RPMTaskResult">[docs]</a><span class="k">class</span> <span class="nc">RPMTaskResult</span><span class="p">(</span><span class="n">TaskResult</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Wrapper around TaskResult to be able to differentiate in output class</span>
|
||||
<span class="sd"> """</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">task</span><span class="p">,</span> <span class="n">success</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">output</span><span class="o">=</span><span class="s">''</span><span class="p">,</span> <span class="n">ignore_errors</span><span class="o">=</span><span class="bp">False</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">RPMTaskResult</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">task</span><span class="p">,</span> <span class="n">success</span><span class="p">,</span> <span class="n">output</span><span class="p">,</span>
|
||||
<span class="n">ignore_errors</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" size="18" />
|
||||
<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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" >taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,149 +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>taboot.tasks.service — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 documentation" href="../../../index.html" />
|
||||
<link rel="up" title="taboot.tasks" href="../tasks.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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" accesskey="U">taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.tasks.service</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2009,2011, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks</span> <span class="kn">import</span> <span class="n">command</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="ServiceBase"><a class="viewcode-back" href="../../../code.html#taboot.tasks.service.ServiceBase">[docs]</a><span class="k">class</span> <span class="nc">ServiceBase</span><span class="p">(</span><span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Base Class for system service tasks</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="Start"><a class="viewcode-back" href="../../../code.html#taboot.tasks.service.Start">[docs]</a><span class="k">class</span> <span class="nc">Start</span><span class="p">(</span><span class="n">ServiceBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Start a service.</span>
|
||||
|
||||
<span class="sd"> Arguments:</span>
|
||||
<span class="sd"> - ``service`` - The service to start.</span>
|
||||
<span class="sd"> """</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">service</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Start</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="s">'service </span><span class="si">%s</span><span class="s"> start'</span> <span class="o">%</span> <span class="n">service</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="Stop"><a class="viewcode-back" href="../../../code.html#taboot.tasks.service.Stop">[docs]</a><span class="k">class</span> <span class="nc">Stop</span><span class="p">(</span><span class="n">ServiceBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Stop a service.</span>
|
||||
|
||||
<span class="sd"> Arguments:</span>
|
||||
<span class="sd"> - ``service`` - The service to stop.</span>
|
||||
<span class="sd"> """</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">service</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Stop</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="s">'service </span><span class="si">%s</span><span class="s"> stop'</span> <span class="o">%</span> <span class="n">service</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="Restart"><a class="viewcode-back" href="../../../code.html#taboot.tasks.service.Restart">[docs]</a><span class="k">class</span> <span class="nc">Restart</span><span class="p">(</span><span class="n">ServiceBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Restart a service.</span>
|
||||
|
||||
<span class="sd"> Arguments:</span>
|
||||
<span class="sd"> - ``service`` - The service to restart.</span>
|
||||
<span class="sd"> """</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">service</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Restart</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="s">'service </span><span class="si">%s</span><span class="s"> restart'</span> <span class="o">%</span> <span class="n">service</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</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" size="18" />
|
||||
<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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" >taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,181 +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>taboot.tasks.sleep — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 documentation" href="../../../index.html" />
|
||||
<link rel="up" title="taboot.tasks" href="../tasks.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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" accesskey="U">taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.tasks.sleep</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2011, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks</span> <span class="kn">import</span> <span class="n">BaseTask</span><span class="p">,</span> <span class="n">TaskResult</span>
|
||||
<span class="kn">from</span> <span class="nn">termios</span> <span class="kn">import</span> <span class="n">tcflush</span><span class="p">,</span> <span class="n">TCIFLUSH</span>
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="SleepBase"><a class="viewcode-back" href="../../../code.html#taboot.tasks.sleep.SleepBase">[docs]</a><span class="k">class</span> <span class="nc">SleepBase</span><span class="p">(</span><span class="n">BaseTask</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Base class for task-queue pausing classes.</span>
|
||||
<span class="sd"> """</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="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">SleepBase</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="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="Seconds"><a class="viewcode-back" href="../../../code.html#taboot.tasks.sleep.Seconds">[docs]</a><span class="k">class</span> <span class="nc">Seconds</span><span class="p">(</span><span class="n">SleepBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Halt task processing on a node for a certain number of seconds.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `seconds`: Number of seconds to halt execution for.</span>
|
||||
<span class="sd"> """</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">seconds</span><span class="o">=</span><span class="mi">60</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Seconds</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="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_seconds</span> <span class="o">=</span> <span class="n">seconds</span>
|
||||
|
||||
<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="n">runner</span><span class="p">):</span>
|
||||
<span class="kn">import</span> <span class="nn">time</span>
|
||||
<span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_seconds</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">success</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span>
|
||||
<span class="n">output</span><span class="o">=</span><span class="s">"Paused for </span><span class="si">%s</span><span class="s"> seconds"</span> <span class="o">%</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_seconds</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="Minutes"><a class="viewcode-back" href="../../../code.html#taboot.tasks.sleep.Minutes">[docs]</a><span class="k">class</span> <span class="nc">Minutes</span><span class="p">(</span><span class="n">SleepBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Halt task processing on a node for a certain number of minutes.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `minutes`: Number of minutes to halt execution for.</span>
|
||||
<span class="sd"> """</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">minutes</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Minutes</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="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_minutes</span> <span class="o">=</span> <span class="n">minutes</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_seconds</span> <span class="o">=</span> <span class="n">minutes</span> <span class="o">*</span> <span class="mi">60</span>
|
||||
|
||||
<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="n">runner</span><span class="p">):</span>
|
||||
<span class="kn">import</span> <span class="nn">time</span>
|
||||
<span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_seconds</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">success</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span>
|
||||
<span class="n">output</span><span class="o">=</span><span class="s">"Paused for </span><span class="si">%s</span><span class="s"> minutes"</span> <span class="o">%</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_minutes</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="WaitOnInput"><a class="viewcode-back" href="../../../code.html#taboot.tasks.sleep.WaitOnInput">[docs]</a><span class="k">class</span> <span class="nc">WaitOnInput</span><span class="p">(</span><span class="n">SleepBase</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Halt task processing on a node until the user presses enter.</span>
|
||||
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `message`: The message to prompt on the CLI.</span>
|
||||
<span class="sd"> """</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="o">=</span><span class="s">"Press enter to continue</span><span class="se">\n</span><span class="s">"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">WaitOnInput</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="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_message</span> <span class="o">=</span> <span class="n">message</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">concurrentFriendly</span> <span class="o">=</span> <span class="bp">False</span>
|
||||
|
||||
<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="n">runner</span><span class="p">):</span>
|
||||
<span class="kn">import</span> <span class="nn">time</span>
|
||||
<span class="n">start</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="n">tcflush</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdin</span><span class="p">,</span> <span class="n">TCIFLUSH</span><span class="p">)</span>
|
||||
<span class="nb">raw_input</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_message</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">TaskResult</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">success</span><span class="o">=</span><span class="bp">True</span><span class="p">,</span>
|
||||
<span class="n">output</span><span class="o">=</span><span class="s">"Paused for </span><span class="si">%s</span><span class="s"> seconds"</span> <span class="o">%</span>
|
||||
<span class="p">(</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="n">start</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" size="18" />
|
||||
<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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" >taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,166 +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>taboot.tasks.yum — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 documentation" href="../../../index.html" />
|
||||
<link rel="up" title="taboot.tasks" href="../tasks.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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" accesskey="U">taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<h1>Source code for taboot.tasks.yum</h1><div class="highlight"><pre>
|
||||
<span class="c"># -*- coding: utf-8 -*-</span>
|
||||
<span class="c"># Taboot - Client utility for performing deployments with Func.</span>
|
||||
<span class="c"># Copyright © 2009, Red Hat, Inc.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is free software: you can redistribute it and/or modify</span>
|
||||
<span class="c"># it under the terms of the GNU General Public License as published by</span>
|
||||
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
|
||||
<span class="c"># (at your option) any later version.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># This program is distributed in the hope that it will be useful,</span>
|
||||
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
|
||||
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
|
||||
<span class="c"># GNU General Public License for more details.</span>
|
||||
<span class="c">#</span>
|
||||
<span class="c"># You should have received a copy of the GNU General Public License</span>
|
||||
<span class="c"># along with this program. If not, see <http://www.gnu.org/licenses/>.</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">taboot.tasks</span> <span class="kn">import</span> <span class="n">command</span><span class="p">,</span> <span class="n">BaseTask</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="YumBase"><a class="viewcode-back" href="../../../code.html#taboot.tasks.yum.YumBase">[docs]</a><span class="k">class</span> <span class="nc">YumBase</span><span class="p">(</span><span class="n">BaseTask</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Base class for all Yum-related tasks.</span>
|
||||
<span class="sd"> """</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">packages</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">packages</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_packages</span> <span class="o">=</span> <span class="n">packages</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_packages_str</span> <span class="o">=</span> <span class="s">' '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">packages</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">_packages</span> <span class="o">=</span> <span class="p">[</span><span class="n">packages</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_packages_str</span> <span class="o">=</span> <span class="n">packages</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="Install"><a class="viewcode-back" href="../../../code.html#taboot.tasks.yum.Install">[docs]</a><span class="k">class</span> <span class="nc">Install</span><span class="p">(</span><span class="n">YumBase</span><span class="p">,</span> <span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Install one or more packages.</span>
|
||||
<span class="sd"> """</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">packages</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `packages`: A list of packages to install</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">YumBase</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">packages</span><span class="p">)</span>
|
||||
<span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s">'yum install -y </span><span class="si">%s</span><span class="s">'</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_packages_str</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="Update"><a class="viewcode-back" href="../../../code.html#taboot.tasks.yum.Update">[docs]</a><span class="k">class</span> <span class="nc">Update</span><span class="p">(</span><span class="n">YumBase</span><span class="p">,</span> <span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Update one or more packages.</span>
|
||||
<span class="sd"> """</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">packages</span><span class="o">=</span><span class="p">[],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `packages`: A list of packages to update. If `packages` is empty,</span>
|
||||
<span class="sd"> update all packages on the system.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">YumBase</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">packages</span><span class="p">)</span>
|
||||
<span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s">'yum update -y </span><span class="si">%s</span><span class="s">'</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_packages_str</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
</div>
|
||||
<div class="viewcode-block" id="Remove"><a class="viewcode-back" href="../../../code.html#taboot.tasks.yum.Remove">[docs]</a><span class="k">class</span> <span class="nc">Remove</span><span class="p">(</span><span class="n">YumBase</span><span class="p">,</span> <span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> Remove one or more packages.</span>
|
||||
<span class="sd"> """</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">packages</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="sd"> :Parameters:</span>
|
||||
<span class="sd"> - `packages`: A list of packages to remove.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">YumBase</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">packages</span><span class="p">)</span>
|
||||
<span class="n">command</span><span class="o">.</span><span class="n">Run</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s">'yum remove -y </span><span class="si">%s</span><span class="s">'</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_packages_str</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</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" size="18" />
|
||||
<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><a href="../../../index.html">Taboot v0.4.0 documentation</a> »</li>
|
||||
<li><a href="../../index.html" >Module code</a> »</li>
|
||||
<li><a href="../tasks.html" >taboot.tasks</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,78 +0,0 @@
|
||||
Code
|
||||
====
|
||||
|
||||
Taboot
|
||||
------
|
||||
.. automodule:: taboot
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
Taboot runner
|
||||
-------------
|
||||
.. automodule:: taboot.runner
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
||||
.. _taboot.tasks:
|
||||
|
||||
Taboot tasks
|
||||
------------
|
||||
.. automodule:: taboot.tasks
|
||||
:members:
|
||||
|
||||
AJP Tasks
|
||||
^^^^^^^^^
|
||||
.. automodule:: taboot.tasks.mod_jk
|
||||
:members:
|
||||
|
||||
Command tasks
|
||||
^^^^^^^^^^^^^
|
||||
.. automodule:: taboot.tasks.command
|
||||
:members:
|
||||
|
||||
Misc tasks
|
||||
^^^^^^^^^^
|
||||
.. automodule:: taboot.tasks.misc
|
||||
:members:
|
||||
|
||||
Nagios tasks
|
||||
^^^^^^^^^^^^
|
||||
.. automodule:: taboot.tasks.nagios
|
||||
:members:
|
||||
|
||||
Polling tasks
|
||||
^^^^^^^^^^^^^
|
||||
.. automodule:: taboot.tasks.poller
|
||||
:members:
|
||||
|
||||
Puppet tasks
|
||||
^^^^^^^^^^^^
|
||||
.. automodule:: taboot.tasks.puppet
|
||||
:members:
|
||||
|
||||
RPM tasks
|
||||
^^^^^^^^^
|
||||
.. automodule:: taboot.tasks.rpm
|
||||
:members:
|
||||
|
||||
Service tasks
|
||||
^^^^^^^^^^^^^
|
||||
.. automodule:: taboot.tasks.service
|
||||
:members:
|
||||
|
||||
Sleep tasks
|
||||
^^^^^^^^^^^
|
||||
.. automodule:: taboot.tasks.sleep
|
||||
:members:
|
||||
|
||||
Yum tasks
|
||||
^^^^^^^^^
|
||||
.. automodule:: taboot.tasks.yum
|
||||
:members:
|
||||
|
||||
Taboot output
|
||||
-------------
|
||||
.. automodule:: taboot.output
|
||||
:members:
|
||||
:undoc-members:
|
||||
|
@ -1,98 +0,0 @@
|
||||
Development
|
||||
===========
|
||||
|
||||
Tools
|
||||
-----
|
||||
|
||||
Taboot uses what is becoming a pretty standard and a quite simple
|
||||
toolset.
|
||||
|
||||
|
||||
Required Tools
|
||||
``````````````
|
||||
#. `python <http://www.python.org>`_ - The python programming language
|
||||
#. `distutils <http://docs.python.org/lib/module-distutils.html>`_ - Python building and packaging library
|
||||
#. `git <http://git.or.cz/>`_ - Source code management
|
||||
#. `Func <https://fedorahosted.org/func/>`_ - The Fedora Unified Network Controller
|
||||
#. `an <http://www.vim.org>`_ `editor <http://www.gnu.org/software/emacs/>`_ or `ide <http://pida.co.uk/>`_ `that <http://scribes.sourceforge.net/>`_ doesn't suck
|
||||
|
||||
|
||||
|
||||
Optional Tools
|
||||
``````````````
|
||||
These should be available via your package manager:
|
||||
|
||||
#. `rpm-build <http://www.rpm.org/max-rpm-snapshot/rpmbuild.8.html>`_ - Should be packaged in your RPM distribution
|
||||
#. `pep8 <https://github.com/jcrocholl/pep8>`_ - Check your patches for pep8 compliance with ``make pep8``
|
||||
|
||||
|
||||
Source
|
||||
------
|
||||
You can clone the repo via :program:`git` through the following command:::
|
||||
|
||||
$ git clone git://git.fedorahosted.org/Taboot.git
|
||||
|
||||
|
||||
:pep:`0008` should be followed. This outlines the highlights that we
|
||||
require above and beyond. Your code must follow this (or note why it
|
||||
can't) before patches will be accepted.
|
||||
|
||||
* global variables should be in ALLCAPPS
|
||||
* attributes should be all lowercase
|
||||
* classes should be ``CamelCased``, filenames should be ``lowercase``.
|
||||
* functions and methods should be lowercase with spaces replaced with _'s::
|
||||
|
||||
def a_test_method(self):
|
||||
pass
|
||||
|
||||
* classes should subclass ``object`` unless it subclasses a different object::
|
||||
|
||||
class Person(object):
|
||||
pass
|
||||
|
||||
class Steve(Person):
|
||||
pass
|
||||
|
||||
* 4 spaces per indent level
|
||||
* max length is 79 chars.
|
||||
* single quotes preferred over double quotes.
|
||||
* avoid ``from x import *`` imports unless a must use
|
||||
* modules, functions, classes, and methods all must have docstrings - doc strings should be descriptive of what objects, functions, and methods do
|
||||
* document any potentially confusing sections of code
|
||||
* functions and methods should be broken down in such a way as to be easily understood and self contained
|
||||
* use descriptive variable names, only use things like x, y, etc.. when doing integer loops and even then see if you can use more descriptive names
|
||||
|
||||
.. note::
|
||||
The ``Makefile`` included in the root of the source distribution
|
||||
includes a target called ``pep8``. Run ``make pep8`` to
|
||||
automatically scan the ``taboot/`` subdirectory for violations.
|
||||
|
||||
|
||||
|
||||
Git
|
||||
---
|
||||
|
||||
The best way to develop on Taboot is to branch feature sets. For
|
||||
instance, if you were to add xml deserialization you would want to
|
||||
branch locally and work on that branch.::
|
||||
|
||||
$ git branch
|
||||
* master
|
||||
$ git status
|
||||
# On branch master
|
||||
nothing to commit (working directory clean)
|
||||
$ git branch xmldeserialization
|
||||
$ git checkout xmldeserialization
|
||||
|
||||
Now we pretend you are all finished and have done at least one commit to the xmldeserialization branch.::
|
||||
|
||||
|
||||
$ git-format-patch master
|
||||
0001-created-initial-classes.patch
|
||||
0002-added-in-documentation.patch
|
||||
$
|
||||
|
||||
|
||||
You now have patch sets which you can send in for perusal and
|
||||
acceptance. Open a new ticket in our issue tracker or attach them to
|
||||
an existing ticket.
|
@ -1,56 +0,0 @@
|
||||
Install
|
||||
=======
|
||||
|
||||
|
||||
From Yum
|
||||
--------
|
||||
|
||||
Taboot is in the Fedora package repositories. Installing it should be as simple as::
|
||||
|
||||
sudo yum install python-taboot
|
||||
|
||||
|
||||
From Source
|
||||
-----------
|
||||
|
||||
You'll need these dependencies to build/install:
|
||||
|
||||
#. `python <http://www.python.org>`_ - The python programming language along with python-setuptools
|
||||
#. `distutils <http://docs.python.org/lib/module-distutils.html>`_ - Python building and packaging library
|
||||
|
||||
Building documentation requires some more deps. These are **required**
|
||||
if you're building RPMs, and optional if you're installing manually:
|
||||
|
||||
#. python-sphinx
|
||||
#. asciidoc
|
||||
#. libxslt
|
||||
|
||||
|
||||
Building RPMs from source
|
||||
`````````````````````````
|
||||
|
||||
This is the recommended installation method if you're pulling Taboot
|
||||
from source::
|
||||
|
||||
make rpm
|
||||
sudo yum localinstall /path/to/rpm
|
||||
|
||||
|
||||
Installing From source
|
||||
``````````````````````
|
||||
|
||||
I **don't** recommend this. But if you're dead set on installing
|
||||
directly from source you still can. This calls the python
|
||||
``distutils`` installer directly::
|
||||
|
||||
sudo make install
|
||||
|
||||
If you wish to build and install the optional documentation you'll
|
||||
need some additional packages so it can be built fully. Install the
|
||||
documentation with this command::
|
||||
|
||||
sudo make installdocs
|
||||
|
||||
Uninstall everything with::
|
||||
|
||||
sudo make uninstall
|
@ -1,16 +0,0 @@
|
||||
.. _tasks:
|
||||
|
||||
Tasks
|
||||
-----
|
||||
|
||||
All the built-in tasks are documented here.
|
||||
|
||||
.. include:: tasks/command.rst
|
||||
.. include:: tasks/service.rst
|
||||
.. include:: tasks/puppet.rst
|
||||
.. include:: tasks/nagios.rst
|
||||
.. include:: tasks/sleep.rst
|
||||
.. include:: tasks/yum.rst
|
||||
.. include:: tasks/rpm.rst
|
||||
.. include:: tasks/mod_jk.rst
|
||||
.. include:: tasks/misc.rst
|
@ -1,853 +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>Code — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 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">Taboot v0.4.0 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="code">
|
||||
<h1>Code<a class="headerlink" href="#code" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="section" id="module-taboot">
|
||||
<span id="taboot"></span><h2>Taboot<a class="headerlink" href="#module-taboot" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The Taboot task library.</p>
|
||||
<p>Taboot was created as a framework to do code deployments which
|
||||
require a repetitive set of tasks to be run in a certain order against
|
||||
certain groups of hosts.</p>
|
||||
</div>
|
||||
<div class="section" id="module-taboot.runner">
|
||||
<span id="taboot-runner"></span><h2>Taboot runner<a class="headerlink" href="#module-taboot.runner" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="class">
|
||||
<dt id="taboot.runner.Runner">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.runner.</tt><tt class="descname">Runner</tt><big>(</big><em>script</em>, <em>config</em>, <em>expand_globs=True</em><big>)</big><a class="reference internal" href="_modules/taboot/runner.html#Runner"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.runner.Runner" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The Runner, responsible for running a taboot job.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>script</cite>: an instance of tabootScript</li>
|
||||
<li><cite>expand_globs</cite>: whether to expand the globs or just leave
|
||||
them as is.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<dl class="method">
|
||||
<dt id="taboot.runner.Runner.run">
|
||||
<tt class="descname">run</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/taboot/runner.html#Runner.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.runner.Runner.run" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Run the preflight/tasks-body</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.runner.TaskRunner">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.runner.</tt><tt class="descname">TaskRunner</tt><big>(</big><em>host</em>, <em>tasks</em>, <em>semaphore</em>, <em>output</em>, <em>fail_event</em><big>)</big><a class="reference internal" href="_modules/taboot/runner.html#TaskRunner"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.runner.TaskRunner" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>TaskRunner is responsible for executing a set of tasks for a
|
||||
single host in it’s own thread.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>host</cite>: The host to operate on.</li>
|
||||
<li><cite>tasks</cite>: A list of tasks to perform (see <a class="reference internal" href="#taboot.runner.Runner" title="taboot.runner.Runner"><tt class="xref py py-class docutils literal"><span class="pre">Runner</span></tt></a>)</li>
|
||||
<li><cite>semaphore</cite>: The <a class="reference internal" href="#taboot.runner.Runner" title="taboot.runner.Runner"><tt class="xref py py-class docutils literal"><span class="pre">Runner</span></tt></a> semaphore to acquire before
|
||||
executing</li>
|
||||
<li><cite>output</cite>: A list of outputters to use. (see <a class="reference internal" href="#taboot.runner.Runner" title="taboot.runner.Runner"><tt class="xref py py-class docutils literal"><span class="pre">Runner</span></tt></a>)</li>
|
||||
<li><cite>fail_event</cite>: The <a class="reference internal" href="#taboot.runner.Runner" title="taboot.runner.Runner"><tt class="xref py py-class docutils literal"><span class="pre">Runner</span></tt></a> failure event to check before
|
||||
executing. If this event is set when the TaskRunner acquires the
|
||||
semaphore, then the TaskRunner is effectively a no-op.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<dl class="method">
|
||||
<dt id="taboot.runner.TaskRunner.run">
|
||||
<tt class="descname">run</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/taboot/runner.html#TaskRunner.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.runner.TaskRunner.run" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Run the task(s) for the given host. If the fail_event passed
|
||||
from the invoking <a class="reference internal" href="#taboot.runner.Runner" title="taboot.runner.Runner"><tt class="xref py py-class docutils literal"><span class="pre">Runner</span></tt></a> is set, do nothing.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="method">
|
||||
<dt id="taboot.runner.TaskRunner.run_task">
|
||||
<tt class="descname">run_task</tt><big>(</big><em>task</em><big>)</big><a class="reference internal" href="_modules/taboot/runner.html#TaskRunner.run_task"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.runner.TaskRunner.run_task" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Run a single task. Sets task.host and then invokes the run
|
||||
method for the task.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>task</cite>: The task to run</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="module-taboot.tasks">
|
||||
<span id="id1"></span><span id="taboot-tasks"></span><h2>Taboot tasks<a class="headerlink" href="#module-taboot.tasks" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.BaseTask">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.</tt><tt class="descname">BaseTask</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks.html#BaseTask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.BaseTask" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Base Task. All tasks should inherit from this. It does the
|
||||
pretty string representation of a task and allows setting of the
|
||||
host attribute.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.FuncErrorTask">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.</tt><tt class="descname">FuncErrorTask</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks.html#FuncErrorTask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.FuncErrorTask" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Explicitly cause a func remote error by calling a bad command.
|
||||
Used to verify func exception handling works as expected</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.FuncTask">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.</tt><tt class="descname">FuncTask</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks.html#FuncTask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.FuncTask" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>A Func-based task. All tasks that utilize Func should inherit
|
||||
from this.</p>
|
||||
<dl class="method">
|
||||
<dt id="taboot.tasks.FuncTask.run">
|
||||
<tt class="descname">run</tt><big>(</big><em>runner</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks.html#FuncTask.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.FuncTask.run" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Run the FuncTask.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>runner</cite> A <a class="reference internal" href="#taboot.runner.TaskRunner" title="taboot.runner.TaskRunner"><tt class="xref py py-class docutils literal"><span class="pre">taboot.runner.TaskRunner</span></tt></a> instance</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.TaskResult">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.</tt><tt class="descname">TaskResult</tt><big>(</big><em>task</em>, <em>success=False</em>, <em>output=''</em>, <em>ignore_errors=False</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks.html#TaskResult"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.TaskResult" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>An encapsulation of the results of a task. This is passed to one
|
||||
or more instances of output classes (derived from BaseOutput) in
|
||||
order to display to the user.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>task</cite>: The task object represented by this result</li>
|
||||
<li><cite>success</cite>: Whether the task completed successfully or not</li>
|
||||
<li><cite>output</cite>: Any text output produced by the task</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<div class="section" id="module-taboot.tasks.mod_jk">
|
||||
<span id="ajp-tasks"></span><h3>AJP Tasks<a class="headerlink" href="#module-taboot.tasks.mod_jk" title="Permalink to this headline">¶</a></h3>
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.mod_jk.InRotation">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.mod_jk.</tt><tt class="descname">InRotation</tt><big>(</big><em>proxies</em>, <em>action='enable'</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/mod_jk.html#InRotation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.mod_jk.InRotation" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Put an AJP node in rotation on a proxy via modjkapi access on
|
||||
the proxy with func.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>proxies</cite>: A list of URLs to AJP jkmanage interfaces</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.mod_jk.OutOfRotation">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.mod_jk.</tt><tt class="descname">OutOfRotation</tt><big>(</big><em>proxies</em>, <em>action='stop'</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/mod_jk.html#OutOfRotation"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.mod_jk.OutOfRotation" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Remove an AJP node from rotation on a proxy via modjkapi access on
|
||||
the proxy with func.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>proxies</cite>: A list of URLs to AJP jkmanage interfaces</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="module-taboot.tasks.command">
|
||||
<span id="command-tasks"></span><h3>Command tasks<a class="headerlink" href="#module-taboot.tasks.command" title="Permalink to this headline">¶</a></h3>
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.command.Run">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.command.</tt><tt class="descname">Run</tt><big>(</big><em>command</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/command.html#Run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.command.Run" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Run arbitrary commands via Func. The arguments passed to __init__
|
||||
are used to execute func.overlord.Client.command.run(args).</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>command</cite>: Command to run on the remote host</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="misc-tasks">
|
||||
<h3>Misc tasks<a class="headerlink" href="#misc-tasks" title="Permalink to this headline">¶</a></h3>
|
||||
</div>
|
||||
<div class="section" id="module-taboot.tasks.nagios">
|
||||
<span id="nagios-tasks"></span><h3>Nagios tasks<a class="headerlink" href="#module-taboot.tasks.nagios" title="Permalink to this headline">¶</a></h3>
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.nagios.DisableAlerts">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.nagios.</tt><tt class="descname">DisableAlerts</tt><big>(</big><em>nagios_url</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/nagios.html#DisableAlerts"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.nagios.DisableAlerts" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Disable alerts for a host on a nagios instance</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>nagios_url</cite>: Hostname of the Nagios server.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.nagios.EnableAlerts">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.nagios.</tt><tt class="descname">EnableAlerts</tt><big>(</big><em>nagios_url</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/nagios.html#EnableAlerts"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.nagios.EnableAlerts" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Enable alerts for a host on a nagios instance</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>nagios_url</cite>: Hostname of the Nagios server.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.nagios.NagiosBase">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.nagios.</tt><tt class="descname">NagiosBase</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/nagios.html#NagiosBase"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.nagios.NagiosBase" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>All subsequent Nagios tasks are subclasses of this.</p>
|
||||
<p>Code note: Because a <cite>FuncTask</cite> expects to make connections to
|
||||
<cite>self.host</cite> we need to switch <cite>nagios_url</cite> with <cite>self.host</cite> and
|
||||
pass the original <cite>self.host</cite> as an argument.</p>
|
||||
<p class="versionchanged">
|
||||
<span class="versionmodified">Changed in version 0.2.14.</span></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.nagios.ScheduleDowntime">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.nagios.</tt><tt class="descname">ScheduleDowntime</tt><big>(</big><em>nagios_url</em>, <em>service='HOST'</em>, <em>minutes=30</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/nagios.html#ScheduleDowntime"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.nagios.ScheduleDowntime" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Schedule downtime for services on a host in Nagios</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>nagios_url</cite>: Hostname of the Nagios server.</li>
|
||||
<li><cite>service</cite>: Service or list of services to schedule down for.</li>
|
||||
<li><cite>minutes</cite>: The number of minutes to schedule downtime
|
||||
for. Default is 30.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.nagios.SilenceHost">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.nagios.</tt><tt class="descname">SilenceHost</tt><big>(</big><em>nagios_url</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/nagios.html#SilenceHost"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.nagios.SilenceHost" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Silence all notifications for a given host</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>nagios_url</cite>: Hostname of the Nagios server.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.nagios.UnsilenceHost">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.nagios.</tt><tt class="descname">UnsilenceHost</tt><big>(</big><em>nagios_url</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/nagios.html#UnsilenceHost"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.nagios.UnsilenceHost" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Unsilence all notifications for a given host</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>nagios_url</cite>: Hostname of the Nagios server.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="module-taboot.tasks.poller">
|
||||
<span id="polling-tasks"></span><h3>Polling tasks<a class="headerlink" href="#module-taboot.tasks.poller" title="Permalink to this headline">¶</a></h3>
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.poller.PollTask">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.poller.</tt><tt class="descname">PollTask</tt><big>(</big><em>task</em>, <em>sleep_interval=5</em>, <em>max_attempts=6</em>, <em>fail_task=None</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/poller.html#PollTask"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.poller.PollTask" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>PollTask. A task that will poll a particular task until the task
|
||||
succeeds or until max_attempts is reached.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last">
|
||||
<li><p class="first"><cite>task</cite> The task to poll.</p>
|
||||
</li>
|
||||
<li><dl class="first docutils">
|
||||
<dt><cite>sleep_interval</cite> The number of seconds to wait before trying</dt>
|
||||
<dd><p class="first last">the task again.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li><dl class="first docutils">
|
||||
<dt><cite>max_attempts</cite> The maximum number of attempts that the task</dt>
|
||||
<dd><p class="first last">should be run.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li><dl class="first docutils">
|
||||
<dt><cite>fail_task</cite> The task to run when max_attempts has been exhausted.</dt>
|
||||
<dd><p class="first last">If no fail_task is provided, then a simple TaskResult
|
||||
indicating failure is returned.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="module-taboot.tasks.puppet">
|
||||
<span id="puppet-tasks"></span><h3>Puppet tasks<a class="headerlink" href="#module-taboot.tasks.puppet" title="Permalink to this headline">¶</a></h3>
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.puppet.DeleteLockfile">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.puppet.</tt><tt class="descname">DeleteLockfile</tt><big>(</big><em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/puppet.html#DeleteLockfile"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.puppet.DeleteLockfile" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Remove the puppet lock file.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.puppet.Disable">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.puppet.</tt><tt class="descname">Disable</tt><big>(</big><em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/puppet.html#Disable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.puppet.Disable" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Run ‘puppetd –disable’.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.puppet.Enable">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.puppet.</tt><tt class="descname">Enable</tt><big>(</big><em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/puppet.html#Enable"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.puppet.Enable" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Run ‘puppetd –enable’.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.puppet.PuppetBase">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.puppet.</tt><tt class="descname">PuppetBase</tt><big>(</big><em>pcmd</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/puppet.html#PuppetBase"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.puppet.PuppetBase" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Base class for puppet commands</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.puppet.PuppetTaskResult">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.puppet.</tt><tt class="descname">PuppetTaskResult</tt><big>(</big><em>task</em>, <em>success=False</em>, <em>output=''</em>, <em>ignore_errors=False</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/puppet.html#PuppetTaskResult"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.puppet.PuppetTaskResult" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Wrapper around TaskResult to be able to differentiate in output class</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.puppet.Run">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.puppet.</tt><tt class="descname">Run</tt><big>(</big><em>server=''</em>, <em>noop=False</em>, <em>safe=False</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/puppet.html#Run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.puppet.Run" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Run ‘puppetd –test || true’</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name" colspan="2">Optional Parameters:</th></tr>
|
||||
<tr><td> </td><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>server</cite>: Puppetmaster to run against</li>
|
||||
<li><cite>noop</cite>: If this should be a noop run (Boolean)</li>
|
||||
<li><cite>safe</cite>: Abort if puppet errors (Boolean)</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>See also: <tt class="xref py py-meth docutils literal"><span class="pre">taboot.tasks.Puppet.SafeRun()</span></tt></p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.puppet.SafeRun">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.puppet.</tt><tt class="descname">SafeRun</tt><big>(</big><em>server=''</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/puppet.html#SafeRun"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.puppet.SafeRun" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Run ‘puppetd –test’.</p>
|
||||
<p>How is this different from Run? Simple, it will abort everything
|
||||
if puppet returns with a non-zero exit status.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="module-taboot.tasks.rpm">
|
||||
<span id="rpm-tasks"></span><h3>RPM tasks<a class="headerlink" href="#module-taboot.tasks.rpm" title="Permalink to this headline">¶</a></h3>
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.rpm.PostManifest">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.rpm.</tt><tt class="descname">PostManifest</tt><big>(</big><em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/rpm.html#PostManifest"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.rpm.PostManifest" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Gather list of installed RPMs and compare against a previously
|
||||
taken <a class="reference internal" href="#taboot.tasks.rpm.PreManifest" title="taboot.tasks.rpm.PreManifest"><tt class="xref py py-class docutils literal"><span class="pre">PreManifest</span></tt></a></p>
|
||||
<dl class="method">
|
||||
<dt id="taboot.tasks.rpm.PostManifest.run">
|
||||
<tt class="descname">run</tt><big>(</big><em>runner</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/rpm.html#PostManifest.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.rpm.PostManifest.run" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>The runner that gets passed in contains state that can be
|
||||
access via dict-like access. PreManifest uses this to write
|
||||
to the rpm.Premanifest field. So we’ll check to make sure the
|
||||
pre-manifest is there by looking for that state.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.rpm.PreManifest">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.rpm.</tt><tt class="descname">PreManifest</tt><big>(</big><em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/rpm.html#PreManifest"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.rpm.PreManifest" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Gather list of installed RPMs. A later invocation of <a class="reference internal" href="#taboot.tasks.rpm.PostManifest" title="taboot.tasks.rpm.PostManifest"><tt class="xref py py-class docutils literal"><span class="pre">PostManifest</span></tt></a>
|
||||
is then used to output the RPMs changed during intermediate tasks.</p>
|
||||
<dl class="method">
|
||||
<dt id="taboot.tasks.rpm.PreManifest.run">
|
||||
<tt class="descname">run</tt><big>(</big><em>runner</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/rpm.html#PreManifest.run"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.rpm.PreManifest.run" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Override the default <tt class="xref py py-class docutils literal"><span class="pre">command.Run</span></tt> to strip the output
|
||||
from the result because we’re really not interested in the
|
||||
contents of the pre-manifest; we just want to collect it to
|
||||
compare later on with PostManifest.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.rpm.RPMBase">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.rpm.</tt><tt class="descname">RPMBase</tt><big>(</big><em>pcmd</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/rpm.html#RPMBase"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.rpm.RPMBase" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Base class for rpm commands</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.rpm.RPMTaskResult">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.rpm.</tt><tt class="descname">RPMTaskResult</tt><big>(</big><em>task</em>, <em>success=False</em>, <em>output=''</em>, <em>ignore_errors=False</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/rpm.html#RPMTaskResult"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.rpm.RPMTaskResult" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Wrapper around TaskResult to be able to differentiate in output class</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="module-taboot.tasks.service">
|
||||
<span id="service-tasks"></span><h3>Service tasks<a class="headerlink" href="#module-taboot.tasks.service" title="Permalink to this headline">¶</a></h3>
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.service.Restart">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.service.</tt><tt class="descname">Restart</tt><big>(</big><em>service</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/service.html#Restart"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.service.Restart" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Restart a service.</p>
|
||||
<dl class="docutils">
|
||||
<dt>Arguments:</dt>
|
||||
<dd><ul class="first last simple">
|
||||
<li><tt class="docutils literal"><span class="pre">service</span></tt> - The service to restart.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.service.ServiceBase">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.service.</tt><tt class="descname">ServiceBase</tt><big>(</big><em>command</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/service.html#ServiceBase"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.service.ServiceBase" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Base Class for system service tasks</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.service.Start">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.service.</tt><tt class="descname">Start</tt><big>(</big><em>service</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/service.html#Start"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.service.Start" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Start a service.</p>
|
||||
<dl class="docutils">
|
||||
<dt>Arguments:</dt>
|
||||
<dd><ul class="first last simple">
|
||||
<li><tt class="docutils literal"><span class="pre">service</span></tt> - The service to start.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.service.Stop">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.service.</tt><tt class="descname">Stop</tt><big>(</big><em>service</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/service.html#Stop"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.service.Stop" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Stop a service.</p>
|
||||
<dl class="docutils">
|
||||
<dt>Arguments:</dt>
|
||||
<dd><ul class="first last simple">
|
||||
<li><tt class="docutils literal"><span class="pre">service</span></tt> - The service to stop.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
</dl>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="module-taboot.tasks.sleep">
|
||||
<span id="sleep-tasks"></span><h3>Sleep tasks<a class="headerlink" href="#module-taboot.tasks.sleep" title="Permalink to this headline">¶</a></h3>
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.sleep.Minutes">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.sleep.</tt><tt class="descname">Minutes</tt><big>(</big><em>minutes=1</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/sleep.html#Minutes"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.sleep.Minutes" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Halt task processing on a node for a certain number of minutes.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>minutes</cite>: Number of minutes to halt execution for.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.sleep.Seconds">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.sleep.</tt><tt class="descname">Seconds</tt><big>(</big><em>seconds=60</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/sleep.html#Seconds"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.sleep.Seconds" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Halt task processing on a node for a certain number of seconds.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>seconds</cite>: Number of seconds to halt execution for.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.sleep.SleepBase">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.sleep.</tt><tt class="descname">SleepBase</tt><big>(</big><em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/sleep.html#SleepBase"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.sleep.SleepBase" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Base class for task-queue pausing classes.</p>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.sleep.WaitOnInput">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.sleep.</tt><tt class="descname">WaitOnInput</tt><big>(</big><em>message='Press enter to continuen'</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/sleep.html#WaitOnInput"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.sleep.WaitOnInput" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Halt task processing on a node until the user presses enter.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>message</cite>: The message to prompt on the CLI.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
<div class="section" id="module-taboot.tasks.yum">
|
||||
<span id="yum-tasks"></span><h3>Yum tasks<a class="headerlink" href="#module-taboot.tasks.yum" title="Permalink to this headline">¶</a></h3>
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.yum.Install">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.yum.</tt><tt class="descname">Install</tt><big>(</big><em>packages</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/yum.html#Install"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.yum.Install" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Install one or more packages.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>packages</cite>: A list of packages to install</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.yum.Remove">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.yum.</tt><tt class="descname">Remove</tt><big>(</big><em>packages</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/yum.html#Remove"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.yum.Remove" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Remove one or more packages.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>packages</cite>: A list of packages to remove.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.yum.Update">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.yum.</tt><tt class="descname">Update</tt><big>(</big><em>packages=</em><span class="optional">[</span><span class="optional">]</span>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/yum.html#Update"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.yum.Update" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Update one or more packages.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last">
|
||||
<li><dl class="first docutils">
|
||||
<dt><cite>packages</cite>: A list of packages to update. If <cite>packages</cite> is empty,</dt>
|
||||
<dd><p class="first last">update all packages on the system.</p>
|
||||
</dd>
|
||||
</dl>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.tasks.yum.YumBase">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.tasks.yum.</tt><tt class="descname">YumBase</tt><big>(</big><em>packages</em><big>)</big><a class="reference internal" href="_modules/taboot/tasks/yum.html#YumBase"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.tasks.yum.YumBase" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Base class for all Yum-related tasks.</p>
|
||||
</dd></dl>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="module-taboot.output">
|
||||
<span id="taboot-output"></span><h2>Taboot output<a class="headerlink" href="#module-taboot.output" title="Permalink to this headline">¶</a></h2>
|
||||
<dl class="class">
|
||||
<dt id="taboot.output.CLIOutput">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.output.</tt><tt class="descname">CLIOutput</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/output.html#CLIOutput"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.output.CLIOutput" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Output a <a class="reference internal" href="#taboot.tasks.TaskResult" title="taboot.tasks.TaskResult"><tt class="xref py py-class docutils literal"><span class="pre">taboot.tasks.TaskResult</span></tt></a> to the command line
|
||||
with pretty formatting and colors.</p>
|
||||
<p>Creates an instance of a file-like object.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>args</cite>: all non-keyword arguments.</li>
|
||||
<li><cite>kwargs</cite>: all keyword arguments.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.output.EmailOutput">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.output.</tt><tt class="descname">EmailOutput</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/output.html#EmailOutput"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.output.EmailOutput" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Output a <a class="reference internal" href="#taboot.tasks.TaskResult" title="taboot.tasks.TaskResult"><tt class="xref py py-class docutils literal"><span class="pre">taboot.tasks.TaskResult</span></tt></a> to a logfile.</p>
|
||||
<p>Creates an instance of a file-like object.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>args</cite>: all non-keyword arguments.</li>
|
||||
<li><cite>kwargs</cite>: all keyword arguments.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<dl class="method">
|
||||
<dt id="taboot.output.EmailOutput.flush">
|
||||
<tt class="descname">flush</tt><big>(</big><big>)</big><a class="reference internal" href="_modules/taboot/output.html#EmailOutput.flush"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.output.EmailOutput.flush" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Flushing sends the email with the buffer.</p>
|
||||
</dd></dl>
|
||||
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.output.HTMLOutput">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.output.</tt><tt class="descname">HTMLOutput</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/output.html#HTMLOutput"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.output.HTMLOutput" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Output a <a class="reference internal" href="#taboot.tasks.TaskResult" title="taboot.tasks.TaskResult"><tt class="xref py py-class docutils literal"><span class="pre">taboot.tasks.TaskResult</span></tt></a> to the command line
|
||||
with pretty formatting and colors.</p>
|
||||
<dl class="method">
|
||||
<dt id="taboot.output.HTMLOutput._write">
|
||||
<tt class="descname">_write</tt><big>(</big><em>result</em><big>)</big><a class="reference internal" href="_modules/taboot/output.html#HTMLOutput._write"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.output.HTMLOutput._write" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Write a tasks <cite>result</cite> out to HTML. Handles enhanced stylizing
|
||||
for task results that support such as:</p>
|
||||
<ul class="simple">
|
||||
<li><a class="reference internal" href="#taboot.tasks.puppet.PuppetTaskResult" title="taboot.tasks.puppet.PuppetTaskResult"><tt class="xref py py-mod docutils literal"><span class="pre">taboot.tasks.puppet.PuppetTaskResult</span></tt></a></li>
|
||||
<li><a class="reference internal" href="#taboot.tasks.rpm.RPMTaskResult" title="taboot.tasks.rpm.RPMTaskResult"><tt class="xref py py-mod docutils literal"><span class="pre">taboot.tasks.rpm.RPMTaskResult</span></tt></a></li>
|
||||
</ul>
|
||||
</dd></dl>
|
||||
|
||||
<p>Creates an instance of a file-like object.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>args</cite>: all non-keyword arguments.</li>
|
||||
<li><cite>kwargs</cite>: all keyword arguments.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
<dl class="class">
|
||||
<dt id="taboot.output.LogOutput">
|
||||
<em class="property">class </em><tt class="descclassname">taboot.output.</tt><tt class="descname">LogOutput</tt><big>(</big><em>*args</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="_modules/taboot/output.html#LogOutput"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#taboot.output.LogOutput" title="Permalink to this definition">¶</a></dt>
|
||||
<dd><p>Output a <a class="reference internal" href="#taboot.tasks.TaskResult" title="taboot.tasks.TaskResult"><tt class="xref py py-class docutils literal"><span class="pre">taboot.tasks.TaskResult</span></tt></a> to a logfile.</p>
|
||||
<p>Creates an instance of a file-like object.</p>
|
||||
<table class="docutils field-list" frame="void" rules="none">
|
||||
<col class="field-name" />
|
||||
<col class="field-body" />
|
||||
<tbody valign="top">
|
||||
<tr class="field"><th class="field-name">Parameters :</th><td class="field-body"><ul class="first last simple">
|
||||
<li><cite>args</cite>: all non-keyword arguments.</li>
|
||||
<li><cite>kwargs</cite>: all keyword arguments.</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</dd></dl>
|
||||
|
||||
</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="#">Code</a><ul>
|
||||
<li><a class="reference internal" href="#module-taboot">Taboot</a></li>
|
||||
<li><a class="reference internal" href="#module-taboot.runner">Taboot runner</a></li>
|
||||
<li><a class="reference internal" href="#module-taboot.tasks">Taboot tasks</a><ul>
|
||||
<li><a class="reference internal" href="#module-taboot.tasks.mod_jk">AJP Tasks</a></li>
|
||||
<li><a class="reference internal" href="#module-taboot.tasks.command">Command tasks</a></li>
|
||||
<li><a class="reference internal" href="#misc-tasks">Misc tasks</a></li>
|
||||
<li><a class="reference internal" href="#module-taboot.tasks.nagios">Nagios tasks</a></li>
|
||||
<li><a class="reference internal" href="#module-taboot.tasks.poller">Polling tasks</a></li>
|
||||
<li><a class="reference internal" href="#module-taboot.tasks.puppet">Puppet tasks</a></li>
|
||||
<li><a class="reference internal" href="#module-taboot.tasks.rpm">RPM tasks</a></li>
|
||||
<li><a class="reference internal" href="#module-taboot.tasks.service">Service tasks</a></li>
|
||||
<li><a class="reference internal" href="#module-taboot.tasks.sleep">Sleep tasks</a></li>
|
||||
<li><a class="reference internal" href="#module-taboot.tasks.yum">Yum tasks</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#module-taboot.output">Taboot output</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="_sources/code.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" size="18" />
|
||||
<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">Taboot v0.4.0 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,216 +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>Development — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 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">Taboot v0.4.0 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="development">
|
||||
<h1>Development<a class="headerlink" href="#development" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="section" id="tools">
|
||||
<h2>Tools<a class="headerlink" href="#tools" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Taboot uses what is becoming a pretty standard and a quite simple
|
||||
toolset.</p>
|
||||
<div class="section" id="required-tools">
|
||||
<h3>Required Tools<a class="headerlink" href="#required-tools" title="Permalink to this headline">¶</a></h3>
|
||||
<blockquote>
|
||||
<div><ol class="arabic simple">
|
||||
<li><a class="reference external" href="http://www.python.org">python</a> - The python programming language</li>
|
||||
<li><a class="reference external" href="http://docs.python.org/lib/module-distutils.html">distutils</a> - Python building and packaging library</li>
|
||||
<li><a class="reference external" href="http://git.or.cz/">git</a> - Source code management</li>
|
||||
<li><a class="reference external" href="https://fedorahosted.org/func/">Func</a> - The Fedora Unified Network Controller</li>
|
||||
<li><a class="reference external" href="http://www.vim.org">an</a> <a class="reference external" href="http://www.gnu.org/software/emacs/">editor</a> or <a class="reference external" href="http://pida.co.uk/">ide</a> <a class="reference external" href="http://scribes.sourceforge.net/">that</a> doesn’t suck</li>
|
||||
</ol>
|
||||
</div></blockquote>
|
||||
</div>
|
||||
<div class="section" id="optional-tools">
|
||||
<h3>Optional Tools<a class="headerlink" href="#optional-tools" title="Permalink to this headline">¶</a></h3>
|
||||
<p>These should be available via your package manager:</p>
|
||||
<blockquote>
|
||||
<div><ol class="arabic simple">
|
||||
<li><a class="reference external" href="http://www.rpm.org/max-rpm-snapshot/rpmbuild.8.html">rpm-build</a> - Should be packaged in your RPM distribution</li>
|
||||
<li><a class="reference external" href="https://github.com/jcrocholl/pep8">pep8</a> - Check your patches for pep8 compliance with <tt class="docutils literal"><span class="pre">make</span> <span class="pre">pep8</span></tt></li>
|
||||
</ol>
|
||||
</div></blockquote>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="source">
|
||||
<h2>Source<a class="headerlink" href="#source" title="Permalink to this headline">¶</a></h2>
|
||||
<p>You can clone the repo via <strong class="program">git</strong> through the following command::</p>
|
||||
<div class="highlight-python"><pre>$ git clone git://git.fedorahosted.org/Taboot.git</pre>
|
||||
</div>
|
||||
<p><span class="target" id="index-0"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0008"><strong>PEP 0008</strong></a> should be followed. This outlines the highlights that we
|
||||
require above and beyond. Your code must follow this (or note why it
|
||||
can’t) before patches will be accepted.</p>
|
||||
<blockquote>
|
||||
<div><ul>
|
||||
<li><p class="first">global variables should be in ALLCAPPS</p>
|
||||
</li>
|
||||
<li><p class="first">attributes should be all lowercase</p>
|
||||
</li>
|
||||
<li><p class="first">classes should be <tt class="docutils literal"><span class="pre">CamelCased</span></tt>, filenames should be <tt class="docutils literal"><span class="pre">lowercase</span></tt>.</p>
|
||||
</li>
|
||||
<li><p class="first">functions and methods should be lowercase with spaces replaced with _’s:</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="k">def</span> <span class="nf">a_test_method</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">pass</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</li>
|
||||
<li><p class="first">classes should subclass <tt class="docutils literal"><span class="pre">object</span></tt> unless it subclasses a different object:</p>
|
||||
<div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">Person</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="k">pass</span>
|
||||
|
||||
<span class="k">class</span> <span class="nc">Steve</span><span class="p">(</span><span class="n">Person</span><span class="p">):</span>
|
||||
<span class="k">pass</span>
|
||||
</pre></div>
|
||||
</div>
|
||||
</li>
|
||||
<li><p class="first">4 spaces per indent level</p>
|
||||
</li>
|
||||
<li><p class="first">max length is 79 chars.</p>
|
||||
</li>
|
||||
<li><p class="first">single quotes preferred over double quotes.</p>
|
||||
</li>
|
||||
<li><p class="first">avoid <tt class="docutils literal"><span class="pre">from</span> <span class="pre">x</span> <span class="pre">import</span> <span class="pre">*</span></tt> imports unless a must use</p>
|
||||
</li>
|
||||
<li><p class="first">modules, functions, classes, and methods all must have docstrings - doc strings should be descriptive of what objects, functions, and methods do</p>
|
||||
</li>
|
||||
<li><p class="first">document any potentially confusing sections of code</p>
|
||||
</li>
|
||||
<li><p class="first">functions and methods should be broken down in such a way as to be easily understood and self contained</p>
|
||||
</li>
|
||||
<li><p class="first">use descriptive variable names, only use things like x, y, etc.. when doing integer loops and even then see if you can use more descriptive names</p>
|
||||
</li>
|
||||
</ul>
|
||||
</div></blockquote>
|
||||
<div class="admonition note">
|
||||
<p class="first admonition-title">Note</p>
|
||||
<p class="last">The <tt class="docutils literal"><span class="pre">Makefile</span></tt> included in the root of the source distribution
|
||||
includes a target called <tt class="docutils literal"><span class="pre">pep8</span></tt>. Run <tt class="docutils literal"><span class="pre">make</span> <span class="pre">pep8</span></tt> to
|
||||
automatically scan the <tt class="docutils literal"><span class="pre">taboot/</span></tt> subdirectory for violations.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="id1">
|
||||
<h2>Git<a class="headerlink" href="#id1" title="Permalink to this headline">¶</a></h2>
|
||||
<p>The best way to develop on Taboot is to branch feature sets. For
|
||||
instance, if you were to add xml deserialization you would want to
|
||||
branch locally and work on that branch.:</p>
|
||||
<div class="highlight-python"><pre> $ git branch
|
||||
* master
|
||||
$ git status
|
||||
# On branch master
|
||||
nothing to commit (working directory clean)
|
||||
$ git branch xmldeserialization
|
||||
$ git checkout xmldeserialization</pre>
|
||||
</div>
|
||||
<p>Now we pretend you are all finished and have done at least one commit to the xmldeserialization branch.:</p>
|
||||
<div class="highlight-python"><pre>$ git-format-patch master
|
||||
0001-created-initial-classes.patch
|
||||
0002-added-in-documentation.patch
|
||||
$</pre>
|
||||
</div>
|
||||
<p>You now have patch sets which you can send in for perusal and
|
||||
acceptance. Open a new ticket in our issue tracker or attach them to
|
||||
an existing ticket.</p>
|
||||
</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="#">Development</a><ul>
|
||||
<li><a class="reference internal" href="#tools">Tools</a><ul>
|
||||
<li><a class="reference internal" href="#required-tools">Required Tools</a></li>
|
||||
<li><a class="reference internal" href="#optional-tools">Optional Tools</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><a class="reference internal" href="#source">Source</a></li>
|
||||
<li><a class="reference internal" href="#id1">Git</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="_sources/development.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" size="18" />
|
||||
<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">Taboot v0.4.0 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -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>Install — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 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">Taboot v0.4.0 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body">
|
||||
|
||||
<div class="section" id="install">
|
||||
<h1>Install<a class="headerlink" href="#install" title="Permalink to this headline">¶</a></h1>
|
||||
<div class="section" id="from-yum">
|
||||
<h2>From Yum<a class="headerlink" href="#from-yum" title="Permalink to this headline">¶</a></h2>
|
||||
<p>Taboot is in the Fedora package repositories. Installing it should be as simple as:</p>
|
||||
<div class="highlight-python"><pre>sudo yum install python-taboot</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="from-source">
|
||||
<h2>From Source<a class="headerlink" href="#from-source" title="Permalink to this headline">¶</a></h2>
|
||||
<p>You’ll need these dependencies to build/install:</p>
|
||||
<blockquote>
|
||||
<div><ol class="arabic simple">
|
||||
<li><a class="reference external" href="http://www.python.org">python</a> - The python programming language along with python-setuptools</li>
|
||||
<li><a class="reference external" href="http://docs.python.org/lib/module-distutils.html">distutils</a> - Python building and packaging library</li>
|
||||
</ol>
|
||||
</div></blockquote>
|
||||
<p>Building documentation requires some more deps. These are <strong>required</strong>
|
||||
if you’re building RPMs, and optional if you’re installing manually:</p>
|
||||
<blockquote>
|
||||
<div><ol class="arabic simple">
|
||||
<li>python-sphinx</li>
|
||||
<li>asciidoc</li>
|
||||
<li>libxslt</li>
|
||||
</ol>
|
||||
</div></blockquote>
|
||||
<div class="section" id="building-rpms-from-source">
|
||||
<h3>Building RPMs from source<a class="headerlink" href="#building-rpms-from-source" title="Permalink to this headline">¶</a></h3>
|
||||
<p>This is the recommended installation method if you’re pulling Taboot
|
||||
from source:</p>
|
||||
<div class="highlight-python"><pre>make rpm
|
||||
sudo yum localinstall /path/to/rpm</pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="section" id="installing-from-source">
|
||||
<h3>Installing From source<a class="headerlink" href="#installing-from-source" title="Permalink to this headline">¶</a></h3>
|
||||
<p>I <strong>don’t</strong> recommend this. But if you’re dead set on installing
|
||||
directly from source you still can. This calls the python
|
||||
<tt class="docutils literal"><span class="pre">distutils</span></tt> installer directly:</p>
|
||||
<div class="highlight-python"><pre>sudo make install</pre>
|
||||
</div>
|
||||
<p>If you wish to build and install the optional documentation you’ll
|
||||
need some additional packages so it can be built fully. Install the
|
||||
documentation with this command:</p>
|
||||
<div class="highlight-python"><pre>sudo make installdocs</pre>
|
||||
</div>
|
||||
<p>Uninstall everything with:</p>
|
||||
<div class="highlight-python"><pre>sudo make uninstall</pre>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<h3><a href="index.html">Table Of Contents</a></h3>
|
||||
<ul>
|
||||
<li><a class="reference internal" href="#">Install</a><ul>
|
||||
<li><a class="reference internal" href="#from-yum">From Yum</a></li>
|
||||
<li><a class="reference internal" href="#from-source">From Source</a><ul>
|
||||
<li><a class="reference internal" href="#building-rpms-from-source">Building RPMs from source</a></li>
|
||||
<li><a class="reference internal" href="#installing-from-source">Installing From source</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h3>This Page</h3>
|
||||
<ul class="this-page-menu">
|
||||
<li><a href="_sources/install.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" size="18" />
|
||||
<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">Taboot v0.4.0 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,169 +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 — Taboot v0.4.0 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: '0.4.0',
|
||||
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="Taboot v0.4.0 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">Taboot v0.4.0 documentation</a> »</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-t"><strong>t</strong></a>
|
||||
</div>
|
||||
|
||||
<table class="indextable modindextable" cellspacing="0" cellpadding="2">
|
||||
<tr class="pcap"><td></td><td> </td><td></td></tr>
|
||||
<tr class="cap" id="cap-t"><td></td><td>
|
||||
<strong>t</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="code.html#module-taboot"><tt class="xref">taboot</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.output"><tt class="xref">taboot.output</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.runner"><tt class="xref">taboot.runner</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.tasks"><tt class="xref">taboot.tasks</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.tasks.command"><tt class="xref">taboot.tasks.command</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.tasks.mod_jk"><tt class="xref">taboot.tasks.mod_jk</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.tasks.nagios"><tt class="xref">taboot.tasks.nagios</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.tasks.poller"><tt class="xref">taboot.tasks.poller</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.tasks.puppet"><tt class="xref">taboot.tasks.puppet</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.tasks.rpm"><tt class="xref">taboot.tasks.rpm</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.tasks.service"><tt class="xref">taboot.tasks.service</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.tasks.sleep"><tt class="xref">taboot.tasks.sleep</tt></a></td><td>
|
||||
<em></em></td></tr>
|
||||
<tr class="cg-1">
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="code.html#module-taboot.tasks.yum"><tt class="xref">taboot.tasks.yum</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" size="18" />
|
||||
<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">Taboot v0.4.0 documentation</a> »</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer">
|
||||
© Copyright 2009-2011 Red Hat, Inc.
|
||||
Last updated on Mar 07, 2012.
|
||||
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.7.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -1,15 +1,12 @@
|
||||
---
|
||||
layout: default
|
||||
title: Ansible - Multi-node SSH Command & Control
|
||||
---
|
||||
|
||||
<div id="home">
|
||||
|
||||
<h1>About Ansible</h1>
|
||||
<ul class="posts">
|
||||
<p>
|
||||
Page under construction: See <A HREF="http://github.com/ansible/ansible">github.com/ansible</A>.
|
||||
</p>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<html>
|
||||
<head>
|
||||
<title>Redirecting to the Ansible Documentation...</title>
|
||||
<meta http-equiv="Refresh" content="0; url=./html/index.html" />
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
Click <a href="http://www.example.com/">this link</a> if you are
|
||||
not automatically forwarded.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue