Merge lp:~marcoceppi/juju-core/sentry-docs into lp:juju-core/docs

Proposed by Marco Ceppi
Status: Merged
Approved by: Nick Veitch
Approved revision: no longer in the source branch.
Merged at revision: 221
Proposed branch: lp:~marcoceppi/juju-core/sentry-docs
Merge into: lp:juju-core/docs
Diff against target: 273 lines (+125/-29)
1 file modified
htmldocs/tools-amulet.html (+125/-29)
To merge this branch: bzr merge lp:~marcoceppi/juju-core/sentry-docs
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+202522@code.launchpad.net

Description of the change

Add sentry documentation

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'htmldocs/tools-amulet.html'
--- htmldocs/tools-amulet.html 2014-01-09 17:58:56 +0000
+++ htmldocs/tools-amulet.html 2014-01-21 18:21:00 +0000
@@ -21,16 +21,8 @@
21 </head>21 </head>
22<!--End-Head-->22<!--End-Head-->
2323
24
25
26
27
28
29
30 <body class="resources">24 <body class="resources">
31
32<!--Header-->25<!--Header-->
33
34 <header class="banner global" role="banner">26 <header class="banner global" role="banner">
35 <nav role="navigation" class="nav-primary nav-right">27 <nav role="navigation" class="nav-primary nav-right">
36 <div class="logo">28 <div class="logo">
@@ -108,7 +100,7 @@
108100
109 </div>101 </div>
110 <div data-section="windows">102 <div data-section="windows">
111 <p>Amulet is available via Pip:</p>103 <p>Amulet is available via Pip:</p>
112104
113<pre class="prettyprint lang-bash">pip install amulet</pre>105<pre class="prettyprint lang-bash">pip install amulet</pre>
114 </div>106 </div>
@@ -163,7 +155,7 @@
163<h2 id="functionality">Core functionality</h2>155<h2 id="functionality">Core functionality</h2>
164<p>This section is deigned to outline the core functions of Amulet. Again, please refer to the developer documentation for an exhaustive list of functions and methods.156<p>This section is deigned to outline the core functions of Amulet. Again, please refer to the developer documentation for an exhaustive list of functions and methods.
165157
166<h3>amulet.deployer</h3>158<h3 id="amulet.deployer">amulet.deployer</h3>
167159
168<p>The Deployer module houses several classes for interacting and setting up an environment. These classes and methods are outlined below160<p>The Deployer module houses several classes for interacting and setting up an environment. These classes and methods are outlined below
169161
@@ -186,11 +178,11 @@
186</p>178</p>
187<p>Once an environment has been set up, deployer can still drive the environment outside of of juju-deployer. So the same commands (add, relate, configure, expose) will instead interact directly with the environment by using either the Juju API or the juju commands.</p>179<p>Once an environment has been set up, deployer can still drive the environment outside of of juju-deployer. So the same commands (add, relate, configure, expose) will instead interact directly with the environment by using either the Juju API or the juju commands.</p>
188180
189<h4 id="object">Class:</h4>181<h4 id="Deployment">Class:</h4>
190<p><code>Deployment(juju_env=None, series='precise', sentries=True, juju_deployer='juju-deployer', sentry_template=None)</code></p>182<p><code>Deployment(juju_env=None, series='precise', sentries=True, juju_deployer='juju-deployer', sentry_template=None)</code></p>
191183
192<h4>Methods:</h4>184<h4>Methods:</h4>
193<details><summary><code class="method">Deployment.add(service, charm=None, units=1)</code>185<details id="Deployment.add"><summary><code class="method">Deployment.add(service, charm=None, units=1)</code>
194186
195<p>Add a new service to the deployment schema.</p></summary>187<p>Add a new service to the deployment schema.</p></summary>
196188
@@ -205,29 +197,29 @@
205d.add('personal-wp', charm='~marcoceppi/wordpress', units=2)197d.add('personal-wp', charm='~marcoceppi/wordpress', units=2)
206</pre>198</pre>
207</details> 199</details>
208<details><summary><code class="method">Deployment.build_relations()</code>200<details id="Deployment.build_relations"><summary><code class="method">Deployment.build_relations()</code>
209201
210<p>Private method invoked during deployer_map. Creates relation mapping.</p></summary></details>202<p>Private method invoked during deployer_map. Creates relation mapping.</p></summary></details>
211203
212<details><summary><code class="method">Deployment.build_sentries()</code>204<details id="Deployment.build_sentries"><summary><code class="method">Deployment.build_sentries()</code>
213205
214<p>Private method invoked during deployer_map. Creates sentries for services.</p>206<p>Private method invoked during deployer_map. Creates sentries for services.</p>
215 </summary></details>207 </summary></details>
216<details><summary><code class="method">Deployment.configure(service, **options)</code>208<details id="Deployment.configure"><summary><code class="method">Deployment.configure(service, **options)</code>
217209
218<p>Change configuration options for a service.</p></summary>210<p>Change configuration options for a service.</p></summary>
219211
220<ul><li><code>service</code> The service to configure.</li>212<ul><li><code>service</code> The service to configure.</li>
221<li><code>**options</code> Seed with key=val.</li></ul>213<li><code>options</code> Dict of configuration options.</li></ul>
222<pre class="prettyprint lang-python"> 214<pre class="prettyprint lang-python">
223import amulet215import amulet
224216
225d = amulet.Deployment()217d = amulet.Deployment()
226d.add('postgresql')218d.add('postgresql')
227d.configure('postgresql', autovacuum=True, cluster_name='cname')219d.configure('postgresql', {'autovacuum': True, 'cluster_name': 'cname'})
228</pre>220</pre>
229</details>221</details>
230<details><summary><code class="method">Deployment.deployer_map(services, relations)</code>222<details id="Deployment.deployer_map"><summary><code class="method">Deployment.deployer_map(services, relations)</code>
231223
232<p>Create deployer file from provided services and relations.</p>224<p>Create deployer file from provided services and relations.</p>
233</summary>225</summary>
@@ -236,7 +228,7 @@
236<li><code>relations</code> List of relations to map.</li>228<li><code>relations</code> List of relations to map.</li>
237</ul>229</ul>
238</details>230</details>
239<details><summary><code class="method">Deployment.expose(service)</code>231<details id="Deployment.expose"><summary><code class="method">Deployment.expose(service)</code>
240232
241<p>Indicate if a service should be exposed after deployment.</p></summary>233<p>Indicate if a service should be exposed after deployment.</p></summary>
242234
@@ -248,13 +240,13 @@
248d.add('varnish')240d.add('varnish')
249d.expose('varnish')241d.expose('varnish')
250</pre></details>242</pre></details>
251<details><summary><code class="method">Deployment.load(deploy_cfg)</code>243<details id="Deployment.load"><summary><code class="method">Deployment.load(deploy_cfg)</code>
252244
253<p>Import an existing deployer object.</p>245<p>Import an existing deployer object.</p>
254</summary>246</summary>
255<ul><li><code>deploy_cfg</code> Already parsed deployer yaml/json file.</li></ul>247<ul><li><code>deploy_cfg</code> Already parsed deployer yaml/json file.</li></ul>
256</details> 248</details>
257<details><summary><code class="method">Deployment.relate(*args)</code>249<details id="Deployment.relate"><summary><code class="method">Deployment.relate(*args)</code>
258250
259<p>Relate two services together.</p></summary>251<p>Relate two services together.</p></summary>
260252
@@ -274,7 +266,7 @@
274</pre>266</pre>
275</details>267</details>
276 268
277<details><summary><code class="method">Deployment.setup(timeout=600)</code>269<details id="Deployment.setup"><summary><code class="method">Deployment.setup(timeout=600)</code>
278270
279<p>This will create the deployer mapping, create any sentries that are required, and execute juju-deployer with the generated mapping.</p></summary>271<p>This will create the deployer mapping, create any sentries that are required, and execute juju-deployer with the generated mapping.</p></summary>
280272
@@ -294,7 +286,7 @@
294 pass286 pass
295287
296</pre></details>288</pre></details>
297<h3>amulet.sentry</h3>289<h3 id="amulet.sentry">amulet.sentry</h3>
298<p>Sentries are an additional service built in to the Deployment tool which allow an author the ability to dig deeper in to a deployment environment. This is done by adding a set of tools to each service/unit deployed via a subordinate charm and a final "relation sentry" charm is deployed which all relations are proxied through. In doing so you can inspect on each service/unit deployed as well as receive detailed information about what data is being sent by which units/service during a relation.</p>290<p>Sentries are an additional service built in to the Deployment tool which allow an author the ability to dig deeper in to a deployment environment. This is done by adding a set of tools to each service/unit deployed via a subordinate charm and a final "relation sentry" charm is deployed which all relations are proxied through. In doing so you can inspect on each service/unit deployed as well as receive detailed information about what data is being sent by which units/service during a relation.</p>
299291
300<p>Sentries can be accessed from within your deployment using the sentry object. Using the above example from ## Deployer, each service and unit can be accessed using the following:</p>292<p>Sentries can be accessed from within your deployment using the sentry object. Using the above example from ## Deployer, each service and unit can be accessed using the following:</p>
@@ -306,11 +298,120 @@
306d.add('mysql')298d.add('mysql')
307d.setup()299d.setup()
308300
301d.sentry.wait()
302
309d.sentry.unit['mysql/0']303d.sentry.unit['mysql/0']
310d.sentry.unit['mediawiki/0']304d.sentry.unit['mediawiki/0']
311</pre>305</pre>
312<p>Sentries provide several methods for which you can use to gather information about an environment. The following are a few examples.</p>306<p>Sentries provide several methods for which you can use to gather information about an environment. The following are a few examples.</p>
313307
308<h4>Methods</h4>
309
310<details id="amulet.sentry.wait"><summary><code class="method">wait(timeout=300)</code>
311
312<p>Wait for all hooks to finish execution on deployment</p>
313</summary>
314<ul><li><code>timeout</code> Duration in seconds to wait before raising exception, default 300 seconds</li></ul>
315
316<p>If timeout is met prior to ready state, <code>TimeoutError</code> is raised.</p>
317</details>
318
319<h3 id="amulet.sentry.unit">amulet.sentry.unit</h3>
320<p>Each unit is assigned a <a href="#UnitSentry.from_unitdata">UnitSentry</a></p>
321
322<h4 id="UnitSentry.from_unitdata">Class:</h4>
323<p><code>UnitSentry.from_unitdata(unit, unit_data, port=9001, sentry=None)</code></p>
324
325<ul>
326 <li><code>unit</code> - <code>service/#</code> formatted string of unit name</li>
327 <li><code>unit_data</code> - Object of unit status output</li>
328 <li><code>port</code> - Sentry port</li>
329 <li><code>sentry</code> - RelationSentry</li>
330</ul>
331
332<h4>Methods:</h4>
333<details id="UnitSentry.directory"><summary><code class="method">UnitSentry.directory(dir)</code>
334
335<p>See <a href='#UnitSentry.directory_stat'>UnitSentry.directory_stat()</a></p>
336</summary></details>
337
338<details id="UnitSentry.directory_contents"><summary><code class="method">UnitSentry.directory_contents(dir)</code>
339
340<p>Return files and directories of directory</p>
341</summary>
342<ul><li><code>dir</code> Directory on remote machine</li></ul>
343
344<p>Example of output</p>
345
346<pre class="prettyprint">{'files': []
347 'directories': []}</pre>
348</details>
349
350<details id="UnitSentry.directory_stat"><summary><code class="method">UnitSentry.directory_stat(dir)</code>
351
352<p>Return stat of directory</p>
353</summary>
354<ul><li><code>dir</code> Directory on remote machine</li></ul>
355
356<p>Example of output</p>
357
358<pre class="prettyprint">{'mtime': fs_stat.st_mtime,
359 'size': fs_stat.st_size,
360 'uid': fs_stat.st_uid,
361 'gid': fs_stat.st_gid,
362 'mode': fs_stat.st_mode}</pre>
363</details>
364
365<details id="UnitSentry.file"><summary><code class="method">UnitSentry.file(filename)</code>
366
367<p>See <a href='#UnitSentry.file_stat'>UnitSentry.file_stat()</a></p>
368</summary>
369</details>
370
371<details id="UnitSentry.file_contents"><summary><code class="method">UnitSentry.file_contents(filename)</code>
372
373<p>Return contents of filename</p>
374</summary>
375<ul><li><code>filename</code> File on remote machine</li></ul>
376</details>
377
378<details id="UnitSentry.file_stat"><summary><code class="method">UnitSentry.file_stat(filename)</code>
379
380<p>Return stat of path</p>
381</summary>
382<ul><li><code>filename</code> File on remote machine</li></ul>
383
384<p>Example of output</p>
385
386<pre class="prettyprint">{'mtime': fs_stat.st_mtime,
387 'size': fs_stat.st_size,
388 'uid': fs_stat.st_uid,
389 'gid': fs_stat.st_gid,
390 'mode': fs_stat.st_mode}</pre>
391</details>
392
393<details id="UnitSentry.relation"><summary><code class="method">UnitSentry.relation(from_rel, to_rel)</code>
394
395<p>Return stat of path</p>
396</summary>
397<ul><li><code>from_rel</code> The relation of the unit eg <code>rel</code></li>
398<li><code>to_rel</code> Service and relation connection, eg: <code>service:rel</code></li></ul>
399
400<p>Output is an object of key, val relation data</p>
401</details>
402
403<details id="UnitSentry.run"><summary><code class="method">UnitSentry.run(command)</code>
404
405<p>Execute specified command as root on remote machine</p>
406</summary>
407<ul><li><code>command</code> Shell command to execute</li></ul>
408
409<p>Returns a tuple of output string and exit code</p>
410
411<pre class="prettyprint">>>> d.sentry.unit['ubuntu/0'].run('whoami')
412('root', 0)</pre>
413</details>
414
314<h2 id="examples">Examples</h2>415<h2 id="examples">Examples</h2>
315<p>Here are a few examples of Amulet tests</p>416<p>Here are a few examples of Amulet tests</p>
316417
@@ -320,7 +421,7 @@
320<pre class="prettyprint lang-python">421<pre class="prettyprint lang-python">
321#!/bin/bash422#!/bin/bash
322423
323sudo apt-get install install amulet python-requests424sudo apt-get install amulet python-requests
324</pre>425</pre>
325<h4>tests/01-simple</h4>426<h4>tests/01-simple</h4>
326<pre class="prettyprint lang-python">427<pre class="prettyprint lang-python">
@@ -476,10 +577,5 @@
476 </script>577 </script>
477<!--End-Scripts-->578<!--End-Scripts-->
478579
479
480
481
482
483
484</body></html>580</body></html>
485 581
486\ No newline at end of file582\ No newline at end of file

Subscribers

People subscribed via source and target branches