Merge lp:~evilnick/juju-core/doc-interfaces into lp:juju-core/docs

Proposed by Nick Veitch
Status: Merged
Merged at revision: 160
Proposed branch: lp:~evilnick/juju-core/doc-interfaces
Merge into: lp:juju-core/docs
Diff against target: 243 lines (+220/-1)
2 files modified
htmldocs/css/main.css (+2/-1)
htmldocs/interface-mysql.html (+218/-0)
To merge this branch: bzr merge lp:~evilnick/juju-core/doc-interfaces
Reviewer Review Type Date Requested Status
charmers Pending
Review via email: mp+194174@code.launchpad.net

Description of the change

Implementing the mysql interface example

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
1=== modified file 'htmldocs/css/main.css'
2--- htmldocs/css/main.css 2013-09-27 22:50:26 +0000
3+++ htmldocs/css/main.css 2013-11-06 15:48:33 +0000
4@@ -279,6 +279,7 @@
5
6 .doc-content h3{
7 font-size: 18px;
8+ color: #dd4814;
9 }
10 /**
11 * Walkthrough steps
12@@ -486,7 +487,7 @@
13 }
14
15 #content h2 {
16- font-size: 20px;
17+ font-size: 24px;
18 }
19
20 #content h3 {
21
22=== added file 'htmldocs/interface-mysql.html'
23--- htmldocs/interface-mysql.html 1970-01-01 00:00:00 +0000
24+++ htmldocs/interface-mysql.html 2013-11-06 15:48:33 +0000
25@@ -0,0 +1,218 @@
26+<!DOCTYPE html>
27+<html>
28+<!--Head-->
29+ <head>
30+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
31+ <title>Juju Documentation</title>
32+ <script src="/wp-content/themes/ubuntu/library/js/all-yui.js"></script>
33+ <link href="https://fonts.googleapis.com/css?family=Ubuntu:400,300,300italic,400italic,700,700italic|Ubuntu+Mono" rel="stylesheet" type="text/css">
34+ <link rel="stylesheet" type="text/css" media="screen" href="https://juju.ubuntu.com/wp-content/themes/juju-website/css/reset.css">
35+ <link rel="shortcut icon" href="//assets.ubuntu.com/sites/ubuntu/latest/u/img/favicon.ico" />
36+ <link rel="stylesheet" type="text/css" media="screen" href="//assets.ubuntu.com/sites/guidelines/css/latest/ubuntu-styles.css" />
37+ <link rel="stylesheet" type="text/css" media="screen" href="//assets.ubuntu.com/sites/ubuntu/latest/u/css/global.css" />
38+ <link rel="stylesheet" type="text/css" media="screen" href="https://juju.ubuntu.com/wp-content/themes/juju-website/css/960.css">
39+ <link rel="stylesheet" type="text/css" media="screen" href="https://juju.ubuntu.com/wp-content/themes/juju-website/css/home-new.css">
40+ <link rel="stylesheet" id="stacktack-css" href="https://juju.ubuntu.com/wp-content/plugins/stacktack/css/stacktack.min.css?ver=3.4.2" type="text/css" media="all">
41+ <link href="./css/main.css" rel="stylesheet" type="text/css">
42+
43+ <!--[if lt IE 9]>
44+ <script type="text/javascript" src="//html5shim.googlecode.com/svn/trunk/html5.js"></script>
45+ <![endif]-->
46+ </head>
47+<!--End-Head-->
48+
49+
50+ <body class="resources">
51+<!--Header-->
52+
53+ <header class="banner global" role="banner">
54+ <nav role="navigation" class="nav-primary nav-right">
55+ <div class="logo">
56+ <a class="logo-ubuntu" href="https://juju.ubuntu.com/">
57+ <img width="118" height="27" src="//assets.ubuntu.com/sites/ubuntu/latest/u/img/logo.png" alt="Juju logo" />
58+ <span>Juju</span>
59+ </a>
60+ </div>
61+ <ul>
62+ <li class="accessibility-aid"><a accesskey="s" href="#main-content">Jump to content</a></li>
63+ <li class="page_item page-item-8"><a href="https://juju.ubuntu.com/charms/">Charms</a></li>
64+ <li class="page_item page-item-10"><a href="https://juju.ubuntu.com/features/">Features</a></li>
65+ <li class="page_item page-item-12"><a href="https://juju.ubuntu.com/deployment/">Deploy</a></li>
66+ <li class="page_item page-item-14"><a href="https://juju.ubuntu.com/resources/">Resources</a></li>
67+ <li class="page_item page-item-16"><a href="https://juju.ubuntu.com/community/">Community</a></li>
68+ <li class="page_item page-item-18"><a href="https://juju.ubuntu.com/download/">Install Juju</a></li>
69+ </ul>
70+ <div id="box-search">
71+ <form class="search-form" method="get" id="searchform" action="https://juju.ubuntu.com/">
72+ <label class="off-left" for="s">Search:</label>
73+ <input class="form-text" type="text" value="" name="s" id="s" />
74+ <button class="off-left form-submit" type="submit" id="searchsubmit">Search</button>
75+ </form>
76+ </div>
77+ </nav>
78+ </header>
79+<!--End-Header-->
80+<!--Preamble-->
81+<div class="wrapper">
82+ <div id="main-content" class="inner-wrapper" role="main">
83+ <div class="row no-border">
84+ <div class="header-navigation-secondary"></div>
85+ <h2 class="pagetitle">Juju documentation</h2>
86+ </div>
87+ <section id="content" class="container-12">
88+ <div class="grid-12 doc-container">
89+ <div id="navlinks" class="grid-3 doc-navigation">LINKS</div>
90+ <div class="grid-9 doc-content">
91+<!--End-Preamble-->
92+<article>
93+<section id="mysql-interface">
94+<h1>mysql interface</h1>
95+
96+<p>The mysql interface is provided by the mysql charm, and is required by a number of charms currently in the Charm Store and elsewhere which would like to use or actually require a MySQL database.
97+</p>
98+
99+<h2>Hook Implementation: relation-joined</h2>
100+
101+<h3>In theory</h3>
102+
103+<p>When the mysql charm is notified of a “relation joined” event, it creates a database. String values are generated for the credentials needed to authenticate a connection to this database: the database name, a username and password. The mysql charm will also check the instance’s hostname and pass that value too, as well as a string containing “True” or “False” to indicate whether this unit is a slave.
104+</p>
105+<p>A charm joining this relationship will typically have a relationship-joined hook which will wait to see when the mysql charm has set one of the expected values (all values are set simultaneously, so the availability of one indicates that all are available).
106+</p>
107+
108+
109+<h3>In practice</h3>
110+
111+<p>Upon relation joined, mysql sets the following:</p>
112+<ul> <li>database (string)</li>
113+ <li>user (string)</li>
114+ <li>password (string)</li>
115+ <li>host (string)</li>
116+ <li>slave (string)</li></ul>
117+
118+<p>The corresponding <code>relation-joined</code> hook in any charm connecting to the mysql charm should fetch any or all of these values.
119+</p>
120+<h3 id="mysql-interface-example">Reference examples:</h3>
121+
122+<p>Implementation in <code>bash</code>:</p>
123+<pre class="prettyprint lang-bash">#!/bin/sh
124+# db-relation-joined example
125+
126+set -ex # -x for verbose logging to juju debug-log
127+juju-log "Joining database at $JUJU_REMOTE_UNIT"
128+hostname=`unit-get public-address`
129+juju-log "from host: $hostname"
130+
131+# Check to see if 'database' has been set, and loop until it is
132+database=`relation-get database`
133+if [ -z "$database" ] ; then
134+ exit 0
135+fi
136+# retrieve the remaining values which have been set by the mysql charm
137+user=`relation-get user`
138+password=`relation-get password`
139+host=`relation-get private-address`
140+slave=`relation-get slave`
141+
142+# do something with these values
143+juju-log "Database acquired"
144+juju-log "database: $database username: $user host: $host"
145+
146+</pre>
147+
148+
149+<h2>
150+Other relation hooks</h2>
151+
152+<p>The only other hook actually implemented for this interface by the mysql charm is relation-broken. This does not actually interact with connected charms using the interface, but performs some housekeeping for the mysql charm.
153+However, this does not mean that other event driven hooks should not be created for requirer charms to do whatever they may need.</p>
154+</section>
155+</article>
156+<!--Postamble-->
157+ </div>
158+ </div>
159+ </section>
160+ </div>
161+</div>
162+<!--End-Postamble-->
163+<!--Footer-->
164+ <footer class="global clearfix" role="contentinfo">
165+ <nav role="navigation">
166+ <div class="footer-a">
167+ <div class="clearfix">
168+ <ul>
169+ <li>
170+ <h2><a href="/">Juju</a></h2>
171+ <ul>
172+ <li><a href="/charms">Charms</a></li>
173+ <li><a href="/features">Features</a></li>
174+ <li><a href="/deployment">Deployment</a></li>
175+ </ul>
176+ </li>
177+ <li>
178+ <h2><a href="/resources">Resources</a></h2>
179+ <ul>
180+ <li><a href="/resources/juju-overview/">Overview</a></li>
181+ <li><a href="/docs/">Documentation</a></li>
182+ <li><a href="/resources/the-juju-gui/">The Juju web UI</a></li>
183+ <li><a href="/docs/authors-charm-store.html">The charm store</a></li>
184+ <li><a href="/docs/getting-started.html#test">Tutorial</a></li>
185+ <li><a href="/resources/videos/">Videos</a></li>
186+ <li><a href="/resources/easy-tasks-for-new-developers/">Easy tasks for new developers</a></li>
187+ </ul>
188+ </li>
189+ <li>
190+ <h2><a href="/community">Community</a></h2>
191+ <ul>
192+ <li><a href="/community/blog/">Juju Blog</a></li>
193+ <li><a href="/events/">Events</a></li>
194+ <li><a href="/community/weekly-charm-meeting/">Weekly charm meeting</a></li>
195+ <li><a href="/community/charmers/">Charmers</a></li>
196+ <li><a href="/docs/authors-charm-writing.html">Write a charm</a></li>
197+ <li><a href="/docs/contributing.html">Help with documentation</a></li>
198+ <li><a href="https://bugs.launchpad.net/juju-website/+filebug">File a bug</a></li> <li><a href="/labs/">Juju Labs</a></li>
199+ </ul>
200+ </li>
201+ <li>
202+ <h2><a href="https://jujucharms.com/sidebar/">Try Juju</a></h2>
203+ <ul>
204+ <li><a href="https://jujucharms.com/">Charm store</a></li>
205+ <li><a href="/download/">Download Juju</a></li>
206+ </ul>
207+ </li>
208+ </ul>
209+ </div>
210+ </div>
211+ </nav>
212+ <div class="legal clearfix">
213+ <p>&copy; 2013 Canonical Ltd. Ubuntu and Canonical are registered trademarks of <a href="http://canonical.com">Canonical Ltd</a>.</p>
214+ </div>
215+ </footer>
216+
217+<!--End-Footer-->
218+<!--Scripts-->
219+ <script src="//google-code-prettify.googlecode.com/svn/loader/run_prettify.js?skin=sunburst"></script>
220+ <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
221+ <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jqueryui/1.8.14/jquery-ui.min.js"></script>
222+ <script src="//d38yea5fb4e2oh.cloudfront.net/jquery.stacktack.min.js"></script>
223+ <script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
224+ <script type="text/javascript" src="./js/main.js"></script>
225+ <script type="text/javascript" src="./js/jquery.details.js"></script>
226+ <script src="//assets.ubuntu.com/sites/ubuntu/latest/u/js/core.js"></script>
227+ <script src="//assets.ubuntu.com/sites/ubuntu/latest/u/js/global.js"></script>
228+ <!-- google analytics -->
229+ <script>
230+ var _gaq = _gaq || [];
231+ _gaq.push(['_setAccount', 'UA-1018242-41']);
232+ _gaq.push(['_trackPageview']);
233+
234+ (function() {
235+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
236+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
237+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
238+ })();
239+ </script>
240+<!--End-Scripts-->
241+
242+
243+</body></html>

Subscribers

People subscribed via source and target branches