root / docs / examplesdir / configuration.rst @ f6822a26
History | View | Annotate | Download (10.8 kB)
1 |
Configuration |
---|---|
2 |
============= |
3 |
|
4 |
The following refers to the configuration version 0.9 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 authenticate |
26 |
. Config file format version >= 9.0 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 |
. ... DONE |
41 |
. The following information will NOT be preserved: |
42 |
. global.account = AccountName |
43 |
. user.url = https://accounts.example.com |
44 |
. user.account = UserAccountName |
45 |
. compute.url = https://cyclades.example.com/api/v1.1 |
46 |
. file.url = https://pithos.example.com/v1 |
47 |
. image.url = https://cyclades.example.com/plankton |
48 |
. store.account = OldForgotenAccountName |
49 |
. Kamaki is ready to convert the config file |
50 |
. Create (overwrite) file .kamakirc ? [y/N] |
51 |
. |
52 |
<y is pressed> |
53 |
. |
54 |
. No cloud "default" is configured |
55 |
. | To configure a new cloud "default", find and set the |
56 |
. | single authentication URL and token: |
57 |
. | kamaki config set cloud.default.url <URL> |
58 |
. | kamaki config set cloud.default.token <t0k3n> |
59 |
$ |
60 |
|
61 |
.. warning:: A new cloud configuration with the name "default" is created. The |
62 |
global token that was set in the old configuration file, is preserved as |
63 |
the token of the "default" cloud. Still, kamaki needs a url for the cloud |
64 |
and it encourages you to reset the token as well. |
65 |
|
66 |
.. note:: Some options are discarded. Among them, are the service urls, like |
67 |
user.url, compute.url, image.url and file.url . These settings are obsolete |
68 |
since Synnefo 0.14 and kamaki 0.9 so you do not need to recover them. The |
69 |
same is true for user accounts (retrieved automatically) |
70 |
|
71 |
.. note:: You can safely remove the global.XXX_cli options from kamaki |
72 |
configuration file. Kamaki can automatically resolve the default values for |
73 |
these internal options. These options are usefull when overloading the |
74 |
default command behaviors, but are not needed otherwise. |
75 |
|
76 |
Attempt to create a new configuration |
77 |
------------------------------------- |
78 |
|
79 |
Ask kamaki to load from a non-existing configuration file |
80 |
|
81 |
.. code-block:: console |
82 |
|
83 |
$ kamaki -c nonexisting.cnf user authenticate |
84 |
. No cloud is configured |
85 |
. | To configure a new cloud "<cloud name>", find and set the |
86 |
. | single authentication URL and token: |
87 |
. | kamaki config set cloud.<cloud name>.url <URL> |
88 |
. | kamaki config set cloud.<cloud name>.token <t0k3n> |
89 |
$ ls -l nonexisting.cnf |
90 |
. ls: cannot access nonexisting.cnf: No such file or directory |
91 |
$ |
92 |
|
93 |
.. note:: configuration file is not created, but it will be when we set the |
94 |
first configuration value in it, as shown in the following subsection. |
95 |
|
96 |
Configure a cloud and create a new configuration |
97 |
------------------------------------------------ |
98 |
|
99 |
Set the URL for new cloud "mytest" |
100 |
|
101 |
.. code-block:: console |
102 |
|
103 |
$ kamaki -c nonexisting.cnf config set cloud.mytest.url https://accounts.example.com/identity/v2.0/ |
104 |
|
105 |
Try to connect |
106 |
|
107 |
.. code-block:: console |
108 |
|
109 |
$ kamaki -c nonexisting.cnf user authenticate |
110 |
. No authentication token provided for cloud "mytest" |
111 |
. | Set a token for cloud mytest: |
112 |
. | kamaki config set cloud.mytest.token <token> |
113 |
|
114 |
Set token to cloud "mytest" |
115 |
|
116 |
.. code-block:: console |
117 |
|
118 |
$ kamaki -c nonexisting.cnf config set cloud.mytest.token myt35t70k3n== |
119 |
|
120 |
Check that the file is created, everything is set up correctly and working |
121 |
|
122 |
.. code-block:: console |
123 |
|
124 |
$ ls -l nonexisting.cnf |
125 |
. -rw======- 1 someuser someuser 491 Jun 17 13:39 nonexisting.cnf |
126 |
$ kamaki -c nonexisting.cnf config get cloud |
127 |
. cloud.mytest.url = https://accounts.example.com/identity/v2.0/ |
128 |
. cloud.mytest.token = myt35t70k3n== |
129 |
$ kamaki -c nonexisting.cnf user autenticate |
130 |
. ... |
131 |
. user: |
132 |
. id: s0me-3x4mp13-u53r-1d |
133 |
. name: Some User |
134 |
. roles: |
135 |
. id: 1 |
136 |
. name: default |
137 |
. roles_links: |
138 |
$ |
139 |
|
140 |
Failed or incomplete cloud configurations |
141 |
----------------------------------------- |
142 |
|
143 |
Now let kamaki use the default configuration (*${HOME}/.kamakirc*). Let the old |
144 |
token be `my0ld70k3n==` and let it be invalid. |
145 |
|
146 |
Check for clouds and attempt to authenticate |
147 |
|
148 |
.. code-block:: console |
149 |
|
150 |
$ kamaki config get cloud |
151 |
. cloud.default.token = my0ld70k3n== |
152 |
$ kamaki user authenticate |
153 |
. No authentication URL provided for cloud "mytest" |
154 |
. | Set a URL for cloud mytest: |
155 |
. | kamaki config set cloud.mytest.url <URL> |
156 |
$ |
157 |
|
158 |
Set a non-existing URL for cloud.default and attempt authentication |
159 |
|
160 |
.. code-block:: console |
161 |
|
162 |
$ kamaki config set cloud.default.url https://nonexisting.example.com |
163 |
$ kamaki user authenticate |
164 |
. Failed while http-connecting to https://nonexisting.example.com |
165 |
$ |
166 |
|
167 |
Set the URL from the previous example and attempt authentication |
168 |
|
169 |
.. code-block:: console |
170 |
|
171 |
$ kamaki config set cloud.default.url https://accounts.example.com/identity/v2.0/ |
172 |
$ kamaki user authenticate |
173 |
. (401) Authorization failed for token gZH99orgkfYHmGksZKvHJw== |
174 |
. | UNAUTHORIZED unauthorized (Invalid token) |
175 |
$ |
176 |
|
177 |
After some searching at the deployments UI, you find out that the URL/token |
178 |
pair you need is:: |
179 |
|
180 |
URL: https://accounts.deploymentexample.com/identity/v2.0 |
181 |
TOKEN: myd3pl0ym3nt70k3n== |
182 |
|
183 |
Set up the correct values and attempt authentication |
184 |
|
185 |
.. code-block:: console |
186 |
|
187 |
$ kamaki config set cloud.default.url https://accounts.deploymentexample.com/identity/v2.0 |
188 |
$ kamaki config set cloud.default.token myd3pl0ym3nt70k3n== |
189 |
$ kamaki user authenticate |
190 |
. ... |
191 |
. user: |
192 |
. id: my-d3pl0ym3nt-u53r-1d |
193 |
. name: Example Username |
194 |
$ |
195 |
|
196 |
Multiple clouds in a single configuration |
197 |
----------------------------------------- |
198 |
|
199 |
We now have two configurations:: |
200 |
|
201 |
Configuration file: ${HOME}/.kamakirc (default) |
202 |
Clouds: |
203 |
ALIAS: default |
204 |
URL: https://accounts.deploymentexample.com/identity/v2.0 |
205 |
TOKEN: myd3pl0ym3nt70k3n== |
206 |
|
207 |
Copnfiguration file: nonexisting.cnf |
208 |
Clouds: |
209 |
ALIAS: mytest |
210 |
URL: https://accounts.example.com/identity/v2.0/ |
211 |
TOKEN: myt35t70k3n== |
212 |
|
213 |
Obviously the default configuration handles only one cloud, aliased as |
214 |
"default". We will add the second cloud as well. |
215 |
|
216 |
.. code-block:: console |
217 |
|
218 |
$ kamaki config set cloud.mytest.url https://accounts.example.com/identity/v2.0/ |
219 |
$ kamaki config set cloud.mytest.token myt35t70k3n== |
220 |
$ |
221 |
|
222 |
Check all clouds |
223 |
|
224 |
.. code-block:: console |
225 |
|
226 |
$ kamaki config get cloud |
227 |
. cloud.default.url = https://accounts.deploymentexample.com/identity/v2.0/ |
228 |
. cloud.default.token = myd3pl0ym3nt70k3n== |
229 |
. cloud.mytest.url = https://accounts.example.com/identity/v2.0/ |
230 |
. cloud.mytest.token = myt35t70k3n== |
231 |
$ |
232 |
|
233 |
Check if kamaki is confused (is there a default cloud setup?) |
234 |
|
235 |
.. code-block:: console |
236 |
|
237 |
$ kamaki config get default_cloud |
238 |
. default |
239 |
$ |
240 |
|
241 |
Authenticate against different clouds |
242 |
|
243 |
.. code-block:: console |
244 |
|
245 |
$ kamaki user authenticate |
246 |
. ... |
247 |
. <response from deploymentexample.com> |
248 |
. ... |
249 |
$ kamaki --cloud=mytest user authenticate |
250 |
. ... |
251 |
. <response from example.com> |
252 |
. ... |
253 |
$ kamaki --cloud=default user authenticate |
254 |
. ... |
255 |
. <response from deploymentexample.com, same as default behavior> |
256 |
. ... |
257 |
$ kamaki --cloud=nonexistingcloud user authenticate |
258 |
. No cloud "nonexistingcloud" is configured |
259 |
. | To configure a new cloud "nonexistingcloud", find and set the |
260 |
. | single authentication URL and token: |
261 |
. | kamaki config set cloud.nonexistingcloud.url <URL> |
262 |
. | kamaki config set cloud.nonexistingcloud.token <t0k3n> |
263 |
$ |
264 |
|
265 |
Confuse kamaki by removing the default_cloud option, set mytest as default |
266 |
|
267 |
.. code-block:: console |
268 |
|
269 |
$ kamaki config delete default_cloud |
270 |
$ kamaki user authenticate |
271 |
. Found 2 clouds but none of them is set as default |
272 |
. | Please, choose one of the following cloud names: |
273 |
. | default, mytest |
274 |
. | To set a default cloud: |
275 |
. | kamaki config set default_cloud <cloud name> |
276 |
$ kamaki config set default_cloud mytest |
277 |
$ kamaki user authenticate |
278 |
. ... |
279 |
. <response from example.com> |
280 |
. ... |
281 |
$ |
282 |
|
283 |
`Question`: What will happen if the "default" cloud alias **and** the |
284 |
default_cloud option are removed? |
285 |
|
286 |
.. code-block:: console |
287 |
|
288 |
$ kamaki config delete cloud.default |
289 |
$ kamaki config delete default_cloud |
290 |
$ kamaki user authenticate |
291 |
. ... |
292 |
. <response from example.com> |
293 |
. ... |
294 |
$ |
295 |
|
296 |
`Answer`: kamaki doesn't have a default_cloud option, but there is only one |
297 |
cloud configuration (`mytest`), therefore there is no ambiguity in resolving |
298 |
the default cloud. |
299 |
|
300 |
Multiple configurations |
301 |
----------------------- |
302 |
|
303 |
In the following example, we experiment with the higher number of threads when |
304 |
uploading and downloading. The plan is to contact a set of tests with 3 threads |
305 |
at most and another one with 5. All experiments will be run against the same |
306 |
Synnefo cloud (the "mytest" cloud from the previous example). |
307 |
|
308 |
Let's create the 3-threaded configuration first |
309 |
|
310 |
.. code-block:: console |
311 |
|
312 |
$ kamaki -c 3thread config set cloud.test.url https://accounts.example.com/identity/v2.0/ |
313 |
$ kamaki -c 3thread config set cloud.test.token myt35t70k3n== |
314 |
$ |
315 |
|
316 |
Let's set the max_thread option to 3 as well as a seperate file for logs. |
317 |
|
318 |
.. code-block:: console |
319 |
|
320 |
$ kamaki -c 3thread config set max_thread 3 |
321 |
$ kamaki -c 3thread config log_file ./logs/kamaki.3threads.log |
322 |
$ |
323 |
|
324 |
Now, let's create the 5-threaded configuration by modifying a copy of 3thread |
325 |
|
326 |
.. code-block:: console |
327 |
|
328 |
$ cp 3thread 5thread |
329 |
$ kamaki -c 5thread config set max_thread 5 |
330 |
$ kamaki -c 5thread config log_file ./logs/kamaki.5threads.log |
331 |
$ |
332 |
|
333 |
Use kamaki to upload with 3 threads and 5 threads respectively |
334 |
|
335 |
.. code-block:: console |
336 |
|
337 |
$ kamaki -c 3thread file upload testfiles/test1 testcontainer |
338 |
$ kamaki -c 5thread file upload testfiles/test1 testcontainer |
339 |
$ |