Revision f1ea703e
b/docs/developers/config.rst | ||
---|---|---|
3 | 3 |
|
4 | 4 |
Kamaki CLI offers a configuration module named *config*. It features: |
5 | 5 |
|
6 |
* The global dict *DEFAULTS* with all the configuration settings needed to run
|
|
7 |
a kamaki CLI and their default values
|
|
6 |
* The global dict *DEFAULTS* with all the configuration settings and default
|
|
7 |
values for running a kamaki CLI
|
|
8 | 8 |
|
9 | 9 |
* The class *Config* is a ConfigParser extension adjusted to offer |
10 | 10 |
kamaki-specific functionalities (e.g., cloud management) |
11 | 11 |
|
12 |
Instances of *kamaki.cli.config.Config* always store data at a local file, |
|
13 |
the path of which, is usually given by user as a constructor parameter. If the |
|
14 |
path of the configuration file is not specified explicitly, the value at |
|
15 |
*kamaki.cli.config.CONFIG_PATH* is used instead. |
|
16 |
|
|
12 | 17 |
Types of configuration options |
13 | 18 |
------------------------------ |
14 | 19 |
|
... | ... | |
96 | 101 |
my_config = Config('/some/local/file.cnf') |
97 | 102 |
config_without_default_values = Config(with_defaults=False) |
98 | 103 |
|
104 |
.. note:: If no file path is given, the Config instance is initialized |
|
99 | 105 |
.. note:: The *with_defaults* flag can be used to omit all default settings |
100 | 106 |
from a kamaki Config instance e.g., in case of an external application that |
101 | 107 |
does not need any of the kamaki globals. |
... | ... | |
105 | 111 |
* get(section, option): get the *value* of an *option* in the specified |
106 | 112 |
*section* e.g., |
107 | 113 |
|
108 |
.. code-block:: python |
|
114 |
.. code-block:: python__
|
|
109 | 115 |
|
110 | 116 |
# Example: get the default cloud (global.default_cloud option) |
111 | 117 |
|
... | ... | |
220 | 226 |
|
221 | 227 |
List all clouds with their URLs, let the user pick one |
222 | 228 |
"""""""""""""""""""""""""""""""""""""""""""""""""""""" |
223 |
.. note:: In this example, the default kamaki config file path will be used. |
|
224 |
This is stored at *kamaki.cli.config.CONFIG_PATH* |
|
225 | 229 |
|
226 | 230 |
.. code-block:: python |
227 | 231 |
|
Also available in: Unified diff