This file is indexed.

/usr/share/doc/python-castellan-doc/html/usage.html is in python-castellan-doc 0.4.0-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<!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>Usage &#8212; castellan  documentation</title>
    
    <link rel="stylesheet" href="_static/nature.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <link rel="stylesheet" href="_static/tweaks.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    './',
        VERSION:     '',
        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="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="top" title="castellan  documentation" href="index.html" />
    <link rel="next" title="Testing" href="testing.html" />
    <link rel="prev" title="Installation" href="installation.html" /> 
  </head>
  <body role="document">
  <div id="header">
    <h1 id="logo"><a href="http://www.openstack.org/">OpenStack</a></h1>
    <ul id="navigation">
      
      <li><a href="http://www.openstack.org/" title="Go to the Home page" class="link">Home</a></li>
      <li><a href="http://www.openstack.org/projects/" title="Go to the OpenStack Projects page">Projects</a></li>
      <li><a href="http://www.openstack.org/user-stories/" title="Go to the User Stories page" class="link">User Stories</a></li>
      <li><a href="http://www.openstack.org/community/" title="Go to the Community page" class="link">Community</a></li>
      <li><a href="http://www.openstack.org/blog/" title="Go to the OpenStack Blog">Blog</a></li>
      <li><a href="http://wiki.openstack.org/" title="Go to the OpenStack Wiki">Wiki</a></li>
      <li><a href="http://docs.openstack.org/" title="Go to OpenStack Documentation" class="current">Documentation</a></li>
      
    </ul>
  </div>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="usage">
<h1>Usage<a class="headerlink" href="#usage" title="Permalink to this headline"></a></h1>
<p>This document describes some of the common usage patterns for Castellan. When
incorporating this package into your applications, care should be taken to
consider the key manager behavior you wish to encapsulate and the OpenStack
deployments on which your application will run.</p>
<div class="section" id="authentication">
<h2>Authentication<a class="headerlink" href="#authentication" title="Permalink to this headline"></a></h2>
<p>A fundamental concept to using Castellan is the credential context object.
Castellan supports the following credentials for authentication:</p>
<ul class="simple">
<li>Token</li>
<li>Password</li>
<li>Keystone Token</li>
<li>Keystone Password</li>
</ul>
<p>In order to use these credentials, valid configuration parameters must be
provided.</p>
<div class="code ini highlight-default"><div class="highlight"><pre><span></span><span class="c1"># token credential</span>
<span class="c1"># token variable not required, token can be obtained from context</span>
<span class="p">[</span><span class="n">castellan</span><span class="p">]</span>
<span class="n">auth_type</span> <span class="o">=</span> <span class="s1">&#39;token&#39;</span>
<span class="n">token</span> <span class="o">=</span> <span class="s1">&#39;5b4de0bb77064f289f7cc58e33bea8c7&#39;</span>

<span class="c1"># password credential</span>
<span class="p">[</span><span class="n">castellan</span><span class="p">]</span>
<span class="n">auth_type</span> <span class="o">=</span> <span class="s1">&#39;password&#39;</span>
<span class="n">username</span> <span class="o">=</span> <span class="s1">&#39;admin&#39;</span>
<span class="n">password</span> <span class="o">=</span> <span class="s1">&#39;passw0rd1&#39;</span>

<span class="c1"># keystone token credential</span>
<span class="p">[</span><span class="n">castellan</span><span class="p">]</span>
<span class="n">auth_type</span> <span class="o">=</span> <span class="s1">&#39;keystone_token&#39;</span>
<span class="n">token</span> <span class="o">=</span> <span class="s1">&#39;5b4de0bb77064f289f7cc58e33bea8c7&#39;</span>
<span class="n">project_id</span> <span class="o">=</span> <span class="s1">&#39;a1e19934af81420d980a5d02b4afe9fb&#39;</span>

<span class="c1"># keystone password credential</span>
<span class="p">[</span><span class="n">castellan</span><span class="p">]</span>
<span class="n">auth_type</span> <span class="o">=</span> <span class="s1">&#39;keystone_password&#39;</span>
<span class="n">username</span> <span class="o">=</span> <span class="s1">&#39;admin&#39;</span>
<span class="n">password</span> <span class="o">=</span> <span class="s1">&#39;passw0rd1&#39;</span>
<span class="n">project_id</span> <span class="o">=</span> <span class="s1">&#39;1099302ec608486f9879ba2466c60720&#39;</span>
<span class="n">user_domain_name</span> <span class="o">=</span> <span class="s1">&#39;default&#39;</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Keystone Token and Password authentication is achieved using
keystoneclient.auth.identity.v3 Token and Password auth plugins.
There are a variety of different variables which can be set for the
keystone credential options.</p>
</div>
<p>The configuration must be passed to a credential factory which will
generate the appropriate context.</p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">castellan.common</span> <span class="k">import</span> <span class="n">utils</span>

<span class="n">CONF</span> <span class="o">=</span> <span class="o">&lt;</span><span class="n">your_configuration</span><span class="o">&gt;</span>
<span class="n">context</span> <span class="o">=</span> <span class="n">utils</span><span class="o">.</span><span class="n">credential_factory</span><span class="p">(</span><span class="n">conf</span><span class="o">=</span><span class="n">CONF</span><span class="p">,</span> <span class="n">context</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span>
</pre></div>
</div>
<p>Now you can go ahead and pass the context and use it for authentication.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">There is a special case for a token. Since a user may not want to store a
token in the configuration, the user can pass a context object containing
an &#8216;auth_token&#8217; as well as a configuration file with &#8216;token&#8217; as the
auth type.</p>
</div>
<p>An oslo context object can also be used for authentication, it is
frequently inherited from <code class="docutils literal"><span class="pre">oslo.context.RequestContext</span></code>. This object
represents information that is contained in the current request, and is
usually populated in the WSGI pipeline. The information contained in this
object will be used by Castellan to interact with the specific key manager
that is being abstracted.</p>
<p><strong>Example. Creating RequestContext from Keystone Client</strong></p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">keystoneclient.v3</span> <span class="k">import</span> <span class="n">client</span>
<span class="kn">from</span> <span class="nn">oslo_context</span> <span class="k">import</span> <span class="n">context</span>

<span class="n">username</span> <span class="o">=</span> <span class="s1">&#39;admin&#39;</span>
<span class="n">password</span> <span class="o">=</span> <span class="s1">&#39;openstack&#39;</span>
<span class="n">project_name</span> <span class="o">=</span> <span class="s1">&#39;admin&#39;</span>
<span class="n">auth_url</span> <span class="o">=</span> <span class="s1">&#39;http://localhost:5000/v3&#39;</span>
<span class="n">keystone_client</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="n">username</span><span class="o">=</span><span class="n">username</span><span class="p">,</span>
                                <span class="n">password</span><span class="o">=</span><span class="n">password</span><span class="p">,</span>
                                <span class="n">project_name</span><span class="o">=</span><span class="n">project_name</span><span class="p">,</span>
                                <span class="n">auth_url</span><span class="o">=</span><span class="n">auth_url</span><span class="p">,</span>
                                <span class="n">project_domain_id</span><span class="o">=</span><span class="s1">&#39;default&#39;</span><span class="p">)</span>

<span class="n">project_list</span> <span class="o">=</span> <span class="n">keystone_client</span><span class="o">.</span><span class="n">projects</span><span class="o">.</span><span class="n">list</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">project_name</span><span class="p">)</span>

<span class="n">ctxt</span> <span class="o">=</span> <span class="n">context</span><span class="o">.</span><span class="n">RequestContext</span><span class="p">(</span><span class="n">auth_token</span><span class="o">=</span><span class="n">keystone_client</span><span class="o">.</span><span class="n">auth_token</span><span class="p">,</span>
                              <span class="n">tenant</span><span class="o">=</span><span class="n">project_list</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">id</span><span class="p">)</span>
</pre></div>
</div>
<p>ctxt can then be passed into any key_manager api call.</p>
</div>
<div class="section" id="basic-usage">
<h2>Basic usage<a class="headerlink" href="#basic-usage" title="Permalink to this headline"></a></h2>
<p>Castellan works on the principle of providing an abstracted key manager based
on your configuration. In this manner, several different management services
can be supported through a single interface.</p>
<p>In addition to the key manager, Castellan also provides primitives for
various types of secrets (for example, asymmetric keys, simple passphrases,
and certificates). These primitives are used in conjunction with the key
manager to create, store, retrieve, and destroy managed secrets.</p>
<p><strong>Example. Creating and storing a key.</strong></p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">myapp</span>
<span class="kn">from</span> <span class="nn">castellan.common.objects</span> <span class="k">import</span> <span class="n">passphrase</span>
<span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">key_manager</span>

<span class="n">key</span> <span class="o">=</span> <span class="n">passphrase</span><span class="o">.</span><span class="n">Passphrase</span><span class="p">(</span><span class="s1">&#39;super_secret_password&#39;</span><span class="p">)</span>
<span class="n">manager</span> <span class="o">=</span> <span class="n">key_manager</span><span class="o">.</span><span class="n">API</span><span class="p">()</span>
<span class="n">stored_key_id</span> <span class="o">=</span> <span class="n">manager</span><span class="o">.</span><span class="n">store</span><span class="p">(</span><span class="n">myapp</span><span class="o">.</span><span class="n">context</span><span class="p">(),</span> <span class="n">key</span><span class="p">)</span>
</pre></div>
</div>
<p>To begin with, we&#8217;d like to create a key to manage. We create a simple
passphrase key, then instantiate the key manager, and finally store it to
the manager service. We record the key identifier for later usage.</p>
<p><strong>Example. Retrieving a key and checking the contents.</strong></p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">myapp</span>
<span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">key_manager</span>

<span class="n">manager</span> <span class="o">=</span> <span class="n">key_manager</span><span class="o">.</span><span class="n">API</span><span class="p">()</span>
<span class="n">key</span> <span class="o">=</span> <span class="n">manager</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">myapp</span><span class="o">.</span><span class="n">context</span><span class="p">(),</span> <span class="n">stored_key_id</span><span class="p">)</span>
<span class="k">if</span> <span class="n">key</span><span class="o">.</span><span class="n">get_encoded</span><span class="p">()</span> <span class="o">==</span> <span class="s1">&#39;super_secret_password&#39;</span><span class="p">:</span>
    <span class="n">myapp</span><span class="o">.</span><span class="n">do_secret_stuff</span><span class="p">()</span>
</pre></div>
</div>
<p>This example demonstrates retrieving a stored key from the key manager service
and checking its contents. First we instantiate the key manager, then
retrieve the key using a previously stored identifier, and finally we check
the validity of key before performing our restricted actions.</p>
<p><strong>Example. Deleting a key.</strong></p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="kn">import</span> <span class="nn">myapp</span>
<span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">key_manager</span>

<span class="n">manager</span> <span class="o">=</span> <span class="n">key_manager</span><span class="o">.</span><span class="n">API</span><span class="p">()</span>
<span class="n">manager</span><span class="o">.</span><span class="n">delete</span><span class="p">(</span><span class="n">myapp</span><span class="o">.</span><span class="n">context</span><span class="p">(),</span> <span class="n">stored_key_id</span><span class="p">)</span>
</pre></div>
</div>
<p>Having finished our work with the key, we can now delete it from the key
manager service. We once again instantiate a key manager, then we simply
delete the key by using its identifier. Under normal conditions, this call
will not return anything but may raise exceptions if there are communication,
identification, or authorization issues.</p>
</div>
<div class="section" id="configuring-castellan">
<h2>Configuring castellan<a class="headerlink" href="#configuring-castellan" title="Permalink to this headline"></a></h2>
<p>Castellan contains several options which control the key management
service usage and the configuration of that service. It also contains
functions to help configure the defaults and produce listings for use
with the <code class="docutils literal"><span class="pre">oslo-config-generator</span></code> application.</p>
<p>In general, castellan configuration is handled by passing an
<code class="docutils literal"><span class="pre">oslo_config.cfg.ConfigOpts</span></code> object into the
<code class="docutils literal"><span class="pre">castellan.key_manager.API</span></code> call when creating your key manager. By
default, when no <code class="docutils literal"><span class="pre">ConfigOpts</span></code> object is provided, the key manager will
use the global <code class="docutils literal"><span class="pre">oslo_config.cfg.CONF</span></code> object.</p>
<p><strong>Example. Using the global CONF object for configuration.</strong></p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">key_manager</span>

<span class="n">manager</span> <span class="o">=</span> <span class="n">key_manager</span><span class="o">.</span><span class="n">API</span><span class="p">()</span>
</pre></div>
</div>
<p><strong>Example. Using a predetermined configuration object.</strong></p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">oslo_config</span> <span class="k">import</span> <span class="n">cfg</span>
<span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">key_manager</span>

<span class="n">conf</span> <span class="o">=</span> <span class="n">cfg</span><span class="o">.</span><span class="n">ConfigOpts</span><span class="p">()</span>
<span class="n">manager</span> <span class="o">=</span> <span class="n">key_manager</span><span class="o">.</span><span class="n">API</span><span class="p">(</span><span class="n">configuration</span><span class="o">=</span><span class="n">conf</span><span class="p">)</span>
</pre></div>
</div>
<div class="section" id="controlling-default-options">
<h3>Controlling default options<a class="headerlink" href="#controlling-default-options" title="Permalink to this headline"></a></h3>
<p>To change the default behavior of castellan, and the key management service
it uses, the <code class="docutils literal"><span class="pre">castellan.options</span></code> module provides the <code class="docutils literal"><span class="pre">set_defaults</span></code>
function. This function can be used at run-time to change the behavior of
the library or the key management service provider.</p>
<p><strong>Example. Changing the barbican endpoint.</strong></p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">oslo_config</span> <span class="k">import</span> <span class="n">cfg</span>
<span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">options</span>
<span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">key_manager</span>

<span class="n">conf</span> <span class="o">=</span> <span class="n">cfg</span><span class="o">.</span><span class="n">ConfigOpts</span><span class="p">()</span>
<span class="n">options</span><span class="o">.</span><span class="n">set_defaults</span><span class="p">(</span><span class="n">conf</span><span class="p">,</span> <span class="n">barbican_endpoint</span><span class="o">=</span><span class="s1">&#39;http://192.168.0.1:9311/&#39;</span><span class="p">)</span>
<span class="n">manager</span> <span class="o">=</span> <span class="n">key_manager</span><span class="o">.</span><span class="n">API</span><span class="p">(</span><span class="n">conf</span><span class="p">)</span>
</pre></div>
</div>
<p><strong>Example. Changing the key manager provider while using the global
configuration.</strong></p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">oslo_config</span> <span class="k">import</span> <span class="n">cfg</span>
<span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">options</span>
<span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">key_manager</span>

<span class="n">options</span><span class="o">.</span><span class="n">set_defaults</span><span class="p">(</span><span class="n">cfg</span><span class="o">.</span><span class="n">CONF</span><span class="p">,</span> <span class="n">api_class</span><span class="o">=</span><span class="s1">&#39;some.other.KeyManager&#39;</span><span class="p">)</span>
<span class="n">manager</span> <span class="o">=</span> <span class="n">key_manager</span><span class="o">.</span><span class="n">API</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="logging-from-within-castellan">
<h3>Logging from within Castellan<a class="headerlink" href="#logging-from-within-castellan" title="Permalink to this headline"></a></h3>
<p>Castellan uses <code class="docutils literal"><span class="pre">oslo_log</span></code> for logging. Log information will be generated
if your application has configured the <code class="docutils literal"><span class="pre">oslo_log</span></code> module. If your
application does not use <code class="docutils literal"><span class="pre">oslo_log</span></code> then you can enable default logging
using <code class="docutils literal"><span class="pre">enable_logging</span></code> in the <code class="docutils literal"><span class="pre">castellan.options</span></code> module.</p>
<p><strong>Example. Enabling default logging.</strong></p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">options</span>
<span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">key_manager</span>

<span class="n">options</span><span class="o">.</span><span class="n">enable_logging</span><span class="p">()</span>
<span class="n">manager</span> <span class="o">=</span> <span class="n">key_manager</span><span class="o">.</span><span class="n">API</span><span class="p">()</span>
</pre></div>
</div>
</div>
<div class="section" id="generating-sample-configuration-files">
<h3>Generating sample configuration files<a class="headerlink" href="#generating-sample-configuration-files" title="Permalink to this headline"></a></h3>
<p>Castellan includes a tox configuration for creating a sample configuration
file. This file will contain only the values that will be used by
castellan. To produce this file, run the following command from the
root of the castellan project directory:</p>
<div class="code console highlight-default"><div class="highlight"><pre><span></span>$ tox -e genconfig
</pre></div>
</div>
</div>
<div class="section" id="parsing-the-configuration-files">
<h3>Parsing the configuration files<a class="headerlink" href="#parsing-the-configuration-files" title="Permalink to this headline"></a></h3>
<p>Castellan does not parse the configuration files by default. When you create
the files and occupy them, you still need to manipulate the
<code class="docutils literal"><span class="pre">oslo_config.cfg.ConfigOpts</span></code> object before passing it to the
<code class="docutils literal"><span class="pre">castellan.key_manager.API</span></code> object. You can create a list of locations where
the configuration files reside. If multiple configuration files are
specified, the variables will be used from the most recently parsed file and
overwrite any previous variables. In the example below, the configuration
file in the <code class="docutils literal"><span class="pre">/etc/castellan</span></code> directory will overwrite the values found in
the file in the user&#8217;s home directory. If a file is not found in one of the
specified locations, then a file not found error will occur.</p>
<p><strong>Example. Parsing the config files.</strong></p>
<div class="code python highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">oslo_config</span> <span class="k">import</span> <span class="n">cfg</span>
<span class="kn">from</span> <span class="nn">castellan</span> <span class="k">import</span> <span class="n">key_manager</span>

<span class="n">conf</span> <span class="o">=</span> <span class="n">cfg</span><span class="o">.</span><span class="n">ConfigOpts</span><span class="p">()</span>
<span class="n">conf</span><span class="p">([</span><span class="s1">&#39;~/castellan.conf&#39;</span><span class="p">,</span> <span class="s1">&#39;/etc/castellan/castellan.conf&#39;</span><span class="p">])</span>
<span class="n">manager</span> <span class="o">=</span> <span class="n">key_manager</span><span class="o">.</span><span class="n">API</span><span class="p">(</span><span class="n">configuration</span><span class="o">=</span><span class="n">conf</span><span class="p">)</span>
</pre></div>
</div>
<p>There are two options for parsing the Castellan values from a
configuration file:</p>
<ul class="simple">
<li>The values can be placed in a separate file.</li>
<li>You can include the values in a configuration file you already use.</li>
</ul>
<p>In order to see all of the default values used by Castellan, generate a
sample configuration by referring to the section directly above.</p>
</div>
<div class="section" id="adding-castellan-to-configuration-files">
<h3>Adding castellan to configuration files<a class="headerlink" href="#adding-castellan-to-configuration-files" title="Permalink to this headline"></a></h3>
<p>One common task for OpenStack projects is to create project configuration
files. Castellan provides a <code class="docutils literal"><span class="pre">list_opts</span></code> function in the
<code class="docutils literal"><span class="pre">castellan.options</span></code> module to aid in generating these files when using
the <code class="docutils literal"><span class="pre">oslo-config-generator</span></code>. This function can be specified in the
<code class="file docutils literal"><span class="pre">setup.cfg</span></code> file of your project to inform oslo of the
configuration options. <em>Note, this will use the default values supplied
by the castellan package.</em></p>
<p><strong>Example. Adding castellan to the oslo.config entry point.</strong></p>
<div class="code ini highlight-default"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">entry_points</span><span class="p">]</span>
<span class="n">oslo</span><span class="o">.</span><span class="n">config</span><span class="o">.</span><span class="n">opts</span> <span class="o">=</span>
    <span class="n">castellan</span><span class="o">.</span><span class="n">config</span> <span class="o">=</span> <span class="n">castellan</span><span class="o">.</span><span class="n">options</span><span class="p">:</span><span class="n">list_opts</span>
</pre></div>
</div>
<p>For more information on the oslo configuration generator, please see
<a class="reference external" href="http://docs.openstack.org/developer/oslo.config/generator.html">http://docs.openstack.org/developer/oslo.config/generator.html</a></p>
</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="#">Usage</a><ul>
<li><a class="reference internal" href="#authentication">Authentication</a></li>
<li><a class="reference internal" href="#basic-usage">Basic usage</a></li>
<li><a class="reference internal" href="#configuring-castellan">Configuring castellan</a><ul>
<li><a class="reference internal" href="#controlling-default-options">Controlling default options</a></li>
<li><a class="reference internal" href="#logging-from-within-castellan">Logging from within Castellan</a></li>
<li><a class="reference internal" href="#generating-sample-configuration-files">Generating sample configuration files</a></li>
<li><a class="reference internal" href="#parsing-the-configuration-files">Parsing the configuration files</a></li>
<li><a class="reference internal" href="#adding-castellan-to-configuration-files">Adding castellan to configuration files</a></li>
</ul>
</li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="installation.html"
                                  title="previous chapter">Installation</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="testing.html"
                                  title="next chapter">Testing</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/usage.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" role="navigation" aria-label="related navigation">
      <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="testing.html" title="Testing"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="installation.html" title="Installation"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">castellan  documentation</a> &#187;</li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2016, OpenStack Foundation.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.4.8.
    </div>
<script type="text/javascript">
try {
//Tracking docs.openstack.org/developer/<projectname> only
//The URL is built from the project variable in conf.py
var pageTracker = _gat._getTracker("UA-17511903-1");
pageTracker._setCookiePath("/developer/castellan");
pageTracker._trackPageview();
} catch(err) {}</script>

  </body>
</html>