root / docs / examplesdir / configuration.rst @ 823477e2
History | View | Annotate | Download (9.5 kB)
1 |
Configuration |
---|---|
2 |
============= |
3 |
|
4 |
The following refers to the configuration version 0.12 or better. There is also |
5 |
information on how to convert from older configuration files. |
6 |
|
7 |
In this scenario, we start with an old configuration file at |
8 |
*${HOME}/.kamakirc* that we need to convert. We also create a new one from scratch. In both cases, the second step is the same: set up one or more clouds |
9 |
in a single configuration. Then we examine a case of multiple configuration |
10 |
files. |
11 |
|
12 |
Convert old configuration file |
13 |
------------------------------ |
14 |
|
15 |
First, back up the old file |
16 |
|
17 |
.. code-block:: console |
18 |
|
19 |
$ cp ~/.kamakirc ~/backups/.kamakirc |
20 |
|
21 |
Now, let kamaki do the conversion |
22 |
|
23 |
.. code-block:: console |
24 |
|
25 |
$ kamaki user info |
26 |
. Config file format version >= 0.12 is required |
27 |
. Configuration file: /home/someuser/.kamakirc |
28 |
. Attempting to fix this: |
29 |
. Calculating changes while preserving information |
30 |
. ... rescue global.token => cloud.default.token |
31 |
. ... rescue user.cli => global.user_cli |
32 |
. ... rescue network.cli => global.network_cli |
33 |
. ... rescue file.cli => global.file_cli |
34 |
. ... rescue flavor.cli => global.flavor_cli |
35 |
. ... rescue config.cli => global.config_cli |
36 |
. ... rescue image.cli => global.image_cli |
37 |
. ... rescue server.cli => global.server_cli |
38 |
. ... rescue history.file => global.history_file |
39 |
. ... rescue history.cli => global.history_cli |
40 |
. ... change network_cli value: cyclades => network |
41 |
. ... DONE |
42 |
. The following information will NOT be preserved: |
43 |
. global.account = AccountName |
44 |
. user.url = https://accounts.example.com |
45 |
. user.account = UserAccountName |
46 |
. compute.url = https://cyclades.example.com/api/v1.1 |
47 |
. file.url = https://pithos.example.com/v1 |
48 |
. image.url = https://cyclades.example.com/plankton |
49 |
. store.account = OldForgotenAccountName |
50 |
. Kamaki is ready to convert the config file |
51 |
. Create (overwrite) file .kamakirc ? [y/N] |
52 |
. |
53 |
<y is pressed> |
54 |
. |
55 |
. No cloud "default" is configured |
56 |
. | To configure a new cloud "default", find and set the |
57 |
. | single authentication URL and token: |
58 |
. | kamaki config set cloud.default.url <URL> |
59 |
. | kamaki config set cloud.default.token <t0k3n> |
60 |
$ |
61 |
|
62 |
.. warning:: A new cloud configuration with the name "default" is created. The |
63 |
global token that was set in the old configuration file, is preserved as |
64 |
the token of the "default" cloud. Still, kamaki needs a url for the cloud |
65 |
and it encourages you to reset the token as well. |
66 |
|
67 |
.. note:: Some options are discarded. Among them, are the service urls, like |
68 |
user.url, compute.url, image.url and file.url . These settings are obsolete |
69 |
since Synnefo 0.14 and kamaki 0.9 so you do not need to recover them. The |
70 |
same is true for user accounts (retrieved automatically) |
71 |
|
72 |
.. note:: You can safely remove the global.XXX_cli options from kamaki |
73 |
configuration file. Kamaki can automatically resolve the default values for |
74 |
these internal options. These options are usefull when overloading the |
75 |
default command behaviors, but are not needed otherwise. |
76 |
|
77 |
Attempt to create a new configuration |
78 |
------------------------------------- |
79 |
|
80 |
Ask kamaki to load from a non-existing configuration file |
81 |
|
82 |
.. code-block:: console |
83 |
|
84 |
$ kamaki -c nonexisting.cnf user info |
85 |
. No cloud is configured |
86 |
. | To configure a new cloud "<cloud name>", find and set the |
87 |
. | single authentication URL and token: |
88 |
. | kamaki config set cloud.<cloud name>.url <URL> |
89 |
. | kamaki config set cloud.<cloud name>.token <t0k3n> |
90 |
$ ls -l nonexisting.cnf |
91 |
. ls: cannot access nonexisting.cnf: No such file or directory |
92 |
$ |
93 |
|
94 |
.. note:: configuration file is not created, but it will be when we set the |
95 |
first configuration value in it, as shown in the following subsection. |
96 |
|
97 |
Configure a cloud and create a new configuration |
98 |
------------------------------------------------ |
99 |
|
100 |
Set the URL for new cloud "mytest" |
101 |
|
102 |
.. code-block:: console |
103 |
|
104 |
$ kamaki -c nonexisting.cnf config set cloud.mytest.url https://accounts.example.com/identity/v2.0/ |
105 |
|
106 |
Try to connect |
107 |
|
108 |
.. code-block:: console |
109 |
|
110 |
$ kamaki -c nonexisting.cnf user info |
111 |
. No authentication token provided for cloud "mytest" |
112 |
. | Set a token for cloud mytest: |
113 |
. | kamaki config set cloud.mytest.token <token> |
114 |
|
115 |
Set token to cloud "mytest" |
116 |
|
117 |
.. code-block:: console |
118 |
|
119 |
$ kamaki -c nonexisting.cnf config set cloud.mytest.token myt35t70k3n== |
120 |
|
121 |
Check that the file is created, everything is set up correctly and working |
122 |
|
123 |
.. code-block:: console |
124 |
|
125 |
$ ls -l nonexisting.cnf |
126 |
. -rw======- 1 someuser someuser 491 Jun 17 13:39 nonexisting.cnf |
127 |
$ kamaki -c nonexisting.cnf config get cloud |
128 |
. cloud.mytest.url = https://accounts.example.com/identity/v2.0/ |
129 |
. cloud.mytest.token = myt35t70k3n== |
130 |
$ kamaki -c nonexisting.cnf user autenticate |
131 |
. ... |
132 |
. user: |
133 |
. id: s0me-3x4mp13-u53r-1d |
134 |
. name: Some User |
135 |
. roles: |
136 |
. id: 1 |
137 |
. name: default |
138 |
. roles_links: |
139 |
$ |
140 |
|
141 |
Failed or incomplete cloud configurations |
142 |
----------------------------------------- |
143 |
|
144 |
Now let kamaki use the default configuration (*${HOME}/.kamakirc*). Let the old |
145 |
token be `my0ld70k3n==` and let it be invalid. |
146 |
|
147 |
Check for clouds and attempt to authenticate |
148 |
|
149 |
.. code-block:: console |
150 |
|
151 |
$ kamaki config get cloud |
152 |
. cloud.default.token = my0ld70k3n== |
153 |
$ kamaki user info |
154 |
. No authentication URL provided for cloud "mytest" |
155 |
. | Set a URL for cloud mytest: |
156 |
. | kamaki config set cloud.mytest.url <URL> |
157 |
$ |
158 |
|
159 |
Set a non-existing URL for cloud.default and attempt authentication |
160 |
|
161 |
.. code-block:: console |
162 |
|
163 |
$ kamaki config set cloud.default.url https://nonexisting.example.com |
164 |
$ kamaki user info |
165 |
. Failed while http-connecting to https://nonexisting.example.com |
166 |
$ |
167 |
|
168 |
Set the URL from the previous example and attempt authentication |
169 |
|
170 |
.. code-block:: console |
171 |
|
172 |
$ kamaki config set cloud.default.url https://accounts.example.com/identity/v2.0/ |
173 |
$ kamaki user info |
174 |
. (401) Authorization failed for token gZH99orgkfYHmGksZKvHJw== |
175 |
. | UNAUTHORIZED unauthorized (Invalid token) |
176 |
$ |
177 |
|
178 |
After some searching at the deployments UI, you find out that the URL/token |
179 |
pair you need is:: |
180 |
|
181 |
URL: https://accounts.deploymentexample.com/identity/v2.0 |
182 |
TOKEN: myd3pl0ym3nt70k3n== |
183 |
|
184 |
Set up the correct values and attempt authentication |
185 |
|
186 |
.. code-block:: console |
187 |
|
188 |
$ kamaki config set cloud.default.url https://accounts.deploymentexample.com/identity/v2.0 |
189 |
$ kamaki config set cloud.default.token myd3pl0ym3nt70k3n== |
190 |
$ kamaki user info |
191 |
. ... |
192 |
. user: |
193 |
. id: my-d3pl0ym3nt-u53r-1d |
194 |
. name: Example Username |
195 |
$ |
196 |
|
197 |
Multiple clouds in a single configuration |
198 |
----------------------------------------- |
199 |
|
200 |
We now have two configurations:: |
201 |
|
202 |
Configuration file: ${HOME}/.kamakirc (default) |
203 |
Clouds: |
204 |
ALIAS: default |
205 |
URL: https://accounts.deploymentexample.com/identity/v2.0 |
206 |
TOKEN: myd3pl0ym3nt70k3n== |
207 |
|
208 |
Copnfiguration file: nonexisting.cnf |
209 |
Clouds: |
210 |
ALIAS: mytest |
211 |
URL: https://accounts.example.com/identity/v2.0/ |
212 |
TOKEN: myt35t70k3n== |
213 |
|
214 |
Obviously the default configuration handles only one cloud, aliased as |
215 |
"default". We will add the second cloud as well. |
216 |
|
217 |
.. code-block:: console |
218 |
|
219 |
$ kamaki config set cloud.mytest.url https://accounts.example.com/identity/v2.0/ |
220 |
$ kamaki config set cloud.mytest.token myt35t70k3n== |
221 |
$ |
222 |
|
223 |
Check all clouds |
224 |
|
225 |
.. code-block:: console |
226 |
|
227 |
$ kamaki config get cloud |
228 |
. cloud.default.url = https://accounts.deploymentexample.com/identity/v2.0/ |
229 |
. cloud.default.token = myd3pl0ym3nt70k3n== |
230 |
. cloud.mytest.url = https://accounts.example.com/identity/v2.0/ |
231 |
. cloud.mytest.token = myt35t70k3n== |
232 |
$ |
233 |
|
234 |
Check if kamaki is confused (is there a default cloud setup?) |
235 |
|
236 |
.. code-block:: console |
237 |
|
238 |
$ kamaki config get default_cloud |
239 |
. default |
240 |
$ |
241 |
|
242 |
Authenticate against different clouds |
243 |
|
244 |
.. code-block:: console |
245 |
|
246 |
$ kamaki user info |
247 |
. ... |
248 |
. <response from deploymentexample.com> |
249 |
. ... |
250 |
$ kamaki --cloud=mytest user info |
251 |
. ... |
252 |
. <response from example.com> |
253 |
. ... |
254 |
$ kamaki --cloud=default user info |
255 |
. ... |
256 |
. <response from deploymentexample.com, same as default behavior> |
257 |
. ... |
258 |
$ kamaki --cloud=nonexistingcloud user info |
259 |
. No cloud "nonexistingcloud" is configured |
260 |
. | To configure a new cloud "nonexistingcloud", find and set the |
261 |
. | single authentication URL and token: |
262 |
. | kamaki config set cloud.nonexistingcloud.url <URL> |
263 |
. | kamaki config set cloud.nonexistingcloud.token <t0k3n> |
264 |
$ |
265 |
|
266 |
Confuse kamaki by removing the default_cloud option, set mytest as default |
267 |
|
268 |
.. code-block:: console |
269 |
|
270 |
$ kamaki config delete default_cloud |
271 |
$ kamaki user info |
272 |
. Found 2 clouds but none of them is set as default |
273 |
. | Please, choose one of the following cloud names: |
274 |
. | default, mytest |
275 |
. | To set a default cloud: |
276 |
. | kamaki config set default_cloud <cloud name> |
277 |
$ kamaki config set default_cloud mytest |
278 |
$ kamaki user info |
279 |
. ... |
280 |
. <response from example.com> |
281 |
. ... |
282 |
$ |
283 |
|
284 |
`Question`: What will happen if the "default" cloud alias **and** the |
285 |
default_cloud option are removed? |
286 |
|
287 |
.. code-block:: console |
288 |
|
289 |
$ kamaki config delete cloud.default |
290 |
$ kamaki config delete default_cloud |
291 |
$ kamaki user info |
292 |
. ... |
293 |
. <response from example.com> |
294 |
. ... |
295 |
$ |
296 |
|
297 |
`Answer`: kamaki doesn't have a default_cloud option, but there is only one |
298 |
cloud configuration (`mytest`), therefore there is no ambiguity in resolving |
299 |
the default cloud. |