~jorge/juju-core/review-configs-for-bundles

« back to all changes in this revision

Viewing changes to htmldocs/interface-mysql.html

  • Committer: Nick Veitch
  • Date: 2013-11-06 15:36:33 UTC
  • Revision ID: nick.veitch@canonical.com-20131106153633-othgf12ouo931x5n
added mysql interface doc

Show diffs side-by-side

added added

removed removed

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