root / docs / usage.rst @ fc7c3c4c
History | View | Annotate | Download (26.2 kB)
1 |
Usage |
---|---|
2 |
===== |
3 |
|
4 |
Kamaki offers command line interfaces that implement specific command |
5 |
specifications. A detailed list of the command specifications can be found in |
6 |
`Commands <commands.html>`_ section. This guide covers the generic usage of |
7 |
both interfaces. |
8 |
|
9 |
What's more, kamaki offers a clients API that allows the development of |
10 |
external applications for synnefo. The clients API is listed in the |
11 |
`Clients lib <developers/code.html#the-clients-api>`_ section. |
12 |
|
13 |
Quick Setup |
14 |
----------- |
15 |
|
16 |
Kamaki interfaces rely on a list of configuration options. A detailed guide for |
17 |
setting up kamaki can be found in the `Setup <setup.html>`_ section. |
18 |
|
19 |
As rule of the thump, it is enough to set the authentication URL and user token |
20 |
for the cloud kamaki should communicate with by default: |
21 |
|
22 |
.. code-block:: console |
23 |
:emphasize-lines: 1 |
24 |
|
25 |
Example 1.1: Set authentication URL, user token and cloud alias "default" |
26 |
|
27 |
$ kamaki config set cloud.default.url <authentication URL> |
28 |
$ kamaki config set cloud.default.token myt0k3n== |
29 |
|
30 |
.. note:: The term *default* can be replaced by any arbitary term chosen by |
31 |
the user. This term will serve as a cloud alias for kamaki users, and can |
32 |
be easily modified. |
33 |
|
34 |
Shell vs one-command |
35 |
-------------------- |
36 |
Kamaki users can access synnefo services through either the interactive shell |
37 |
or the one-command behaviors. In practice, both systems rely on the same |
38 |
command set implementations and API clients, with identical responses and error |
39 |
messages. Still, there are some differences. |
40 |
|
41 |
In favor of interactive shell behavior: |
42 |
|
43 |
* tab completion for commands (if supported by host command line shell) |
44 |
* session history with ↑ or ↓ keys (if supported by host command line shell) |
45 |
* shorter commands with command context switching |
46 |
* re-run old commands with /history |
47 |
|
48 |
In favor of one-command behavior: |
49 |
|
50 |
* can be used along with advanced shell features (pipelines, redirection, etc.) |
51 |
* can be used in shell scripts |
52 |
* prints debug and verbose messages if needed |
53 |
|
54 |
Run as shell |
55 |
^^^^^^^^^^^^ |
56 |
To use kamaki as a shell, run: |
57 |
|
58 |
* without any parameters or arguments |
59 |
|
60 |
.. code-block:: console |
61 |
:emphasize-lines: 1 |
62 |
|
63 |
Example 2.2.1: Run kamaki shell |
64 |
|
65 |
$ kamaki |
66 |
|
67 |
* with any kind of '-' prefixed arguments, except '-h', '--help'. |
68 |
|
69 |
.. code-block:: console |
70 |
:emphasize-lines: 1 |
71 |
|
72 |
Example 2.2.2: Run kamaki shell with custom configuration file |
73 |
|
74 |
$ kamaki -c myconfig.file |
75 |
|
76 |
|
77 |
Run as one-command |
78 |
^^^^^^^^^^^^^^^^^^ |
79 |
To use kamaki as an one-command tool, run: |
80 |
|
81 |
* with the '-h' or '--help' arguments (help for kamaki one-command) |
82 |
|
83 |
.. code-block:: console |
84 |
:emphasize-lines: 1 |
85 |
|
86 |
Example 2.3.1: Kamaki help |
87 |
|
88 |
$kamaki -h |
89 |
|
90 |
* with one or more command parameters: |
91 |
|
92 |
.. code-block:: console |
93 |
:emphasize-lines: 1 |
94 |
|
95 |
Example 2.3.2: List VMs managed by user |
96 |
|
97 |
$ kamaki server list |
98 |
|
99 |
One-command interface |
100 |
--------------------- |
101 |
|
102 |
Using help |
103 |
^^^^^^^^^^ |
104 |
|
105 |
Kamaki help is used to list available commands with description, syntax and |
106 |
corresponding optional arguments. |
107 |
|
108 |
To see the command groups, use -h or --help like in example 1.3.1. In the same |
109 |
way, help information for command groups and commands is printed. In the |
110 |
following examples, the help messages of kamaki, of a command group (server) |
111 |
and of a command in that group (list) are shown. |
112 |
|
113 |
.. code-block:: console |
114 |
:emphasize-lines: 1 |
115 |
|
116 |
Example 3.1.1: kamaki help shows available parameters and command groups |
117 |
|
118 |
|
119 |
$ kamaki -h |
120 |
usage: kamaki <cmd_group> [<cmd_subbroup> ...] <cmd> |
121 |
[-v] [-s] [-V] [-d] [-i] [-c CONFIG] [-o OPTIONS] [--cloud CLOUD] [-h] |
122 |
|
123 |
optional arguments: |
124 |
-v, --verbose More info at response |
125 |
-s, --silent Do not output anything |
126 |
-V, --version Print current version |
127 |
-d, --debug Include debug output |
128 |
-i, --include Include protocol headers in the output |
129 |
-c CONFIG, --config CONFIG |
130 |
Path to configuration file |
131 |
-o OPTIONS, --options OPTIONS |
132 |
Override a config value |
133 |
--cloud CLOUD Chose a cloud to connect to |
134 |
-h, --help Show help message |
135 |
|
136 |
Options: |
137 |
- - - - |
138 |
config : Kamaki configurations |
139 |
file : Pithos+/Storage API commands |
140 |
flavor : Cyclades/Compute API flavor commands |
141 |
history: Kamaki command history |
142 |
image : Cyclades/Plankton API image commands |
143 |
image compute: Cyclades/Compute API image commands |
144 |
network: Cyclades/Compute API network commands |
145 |
server : Cyclades/Compute API server commands |
146 |
user : Astakos API commands |
147 |
|
148 |
.. code-block:: console |
149 |
:emphasize-lines: 1,2 |
150 |
|
151 |
Example 3.1.2: Cyclades help contains all first-level commands of Cyclades |
152 |
command group |
153 |
|
154 |
$ kamaki server -h |
155 |
usage: kamaki server <...> [-v] [-s] [-V] [-d] [-i] [-c CONFIG] |
156 |
[-o OPTIONS] [--cloud CLOUD] [-h] |
157 |
|
158 |
optional arguments: |
159 |
-v, --verbose More info at response |
160 |
-s, --silent Do not output anything |
161 |
-V, --version Print current version |
162 |
-d, --debug Include debug output |
163 |
-i, --include Include protocol headers in the output |
164 |
-c CONFIG, --config CONFIG |
165 |
Path to configuration file |
166 |
-o OPTIONS, --options OPTIONS |
167 |
Override a config value |
168 |
--cloud CLOUD Chose a cloud to connect to |
169 |
-h, --help Show help message |
170 |
|
171 |
Options: |
172 |
- - - - |
173 |
addr : List the addresses of all network interfaces on a server (VM) |
174 |
console : Get a VNC console to access an existing server (VM) |
175 |
create : Create a server (aka Virtual Machine) |
176 |
delete : Delete a server (VM) |
177 |
firewall: Manage server (VM) firewall profiles for public networks |
178 |
info : Detailed information on a Virtual Machine |
179 |
list : List Virtual Machines accessible by user |
180 |
metadata: Manage Server metadata (key:value pairs of server attributes) |
181 |
reboot : Reboot a server (VM) |
182 |
rename : Set/update a server (VM) name |
183 |
shutdown: Shutdown an active server (VM) |
184 |
start : Start an existing server (VM) |
185 |
stats : Get server (VM) statistics |
186 |
resize : Set a different flavor for an existing server |
187 |
wait : Wait for server to finish [BUILD, STOPPED, REBOOT, ACTIVE] |
188 |
|
189 |
.. code-block:: console |
190 |
:emphasize-lines: 1,2 |
191 |
|
192 |
Example 3.1.3: Help for command "server list" with syntax, description and |
193 |
available user options |
194 |
|
195 |
$ kamaki server list -h |
196 |
usage: kamaki server list [-v] [-s] [-V] [-d] [-i] [-c CONFIG] [-o OPTIONS] |
197 |
[--cloud CLOUD] [-h] [--since SINCE] [--enumerate] |
198 |
[-l] [--more] [-n LIMIT] [-j] |
199 |
|
200 |
List Virtual Machines accessible by user |
201 |
User Authentication: |
202 |
* to check authentication: /user authenticate |
203 |
* to set authentication token: /config set cloud.default.token <token> |
204 |
|
205 |
optional arguments: |
206 |
-v, --verbose More info at response |
207 |
-s, --silent Do not output anything |
208 |
-V, --version Print current version |
209 |
-d, --debug Include debug output |
210 |
-i, --include Include raw connection data in the output |
211 |
-c CONFIG, --config CONFIG |
212 |
Path to configuration file |
213 |
-o OPTIONS, --options OPTIONS |
214 |
Override a config value |
215 |
--cloud CLOUD Chose a cloud to connect to |
216 |
-h, --help Show help message |
217 |
--since SINCE show only items since date (' d/m/Y H:M:S ') |
218 |
--enumerate Enumerate results |
219 |
-l, --details show detailed output |
220 |
--more output results in pages (-n to set items per page, |
221 |
default 10) |
222 |
-n LIMIT, --number LIMIT |
223 |
limit number of listed VMs |
224 |
-j, --json show headers in json |
225 |
|
226 |
.. _using-history-ref: |
227 |
|
228 |
Using history |
229 |
^^^^^^^^^^^^^ |
230 |
|
231 |
Kamaki command history is stored in a file at user home (".kamaki.history" by default). To set a custom history file path users must set the history.file config option (see `available config options <setup.html#editing-options>`_). |
232 |
|
233 |
Every syntactically correct command is appended at the end of that file. In order to see how to use history, use the kamaki help system: |
234 |
|
235 |
.. code-block:: console |
236 |
:emphasize-lines: 1 |
237 |
|
238 |
Example 3.2.1: Available history options |
239 |
|
240 |
|
241 |
$ kamaki history -h |
242 |
Options: |
243 |
- - - - |
244 |
clean: Clean up history (permanent) |
245 |
run : Run previously executed command(s) |
246 |
show : Show intersession command history |
247 |
|
248 |
The following example showcases how to use history in kamaki |
249 |
|
250 |
.. code-block:: console |
251 |
:emphasize-lines: 1 |
252 |
|
253 |
Example 3.2.2: Clean up everything, run a kamaki command, show full and filtered history |
254 |
|
255 |
|
256 |
$ kamaki history clean |
257 |
$ kamaki server list |
258 |
... |
259 |
$ kamaki history show |
260 |
1. kamaki server list |
261 |
2. kamaki history show |
262 |
$ kamaki history show --match server |
263 |
1. kamaki server list |
264 |
3. kamaki history show --match server |
265 |
|
266 |
Debug and logging |
267 |
^^^^^^^^^^^^^^^^^ |
268 |
|
269 |
Debug |
270 |
""""" |
271 |
|
272 |
In case of errors, kamaki in debug mode shows useful debug information, like |
273 |
the stack trace. Kamaki in debug mode cancels suppression of warning messages. |
274 |
|
275 |
To run kamaki in debug mode use the -d or --debug option (can be combined with |
276 |
any other parameters or options) |
277 |
|
278 |
Logging |
279 |
""""""" |
280 |
|
281 |
Kamaki keeps its logs in a file specified as global.log_file and its value |
282 |
defaults to ${HOME}/.kamaki.log . This value may change with a config setting:: |
283 |
|
284 |
kamaki config set log_file /new/log/file/path |
285 |
|
286 |
Kamaki logs mostly the http connection requests and responses, including http |
287 |
methods, urls, parameters and headers. There is some special handling in two |
288 |
cases: |
289 |
|
290 |
* HTTP bodies are not logged by default |
291 |
to enable logging the full http bodies, set log_data to `on`:: |
292 |
|
293 |
kamaki config set log_data on |
294 |
|
295 |
to disable it, set it to `off`:: |
296 |
|
297 |
kamaki config set log_data off |
298 |
|
299 |
or delete it:: |
300 |
|
301 |
kamaki config delete log_data |
302 |
|
303 |
* X-Auth-Token header is not logged by default |
304 |
to enable logging the X-Auth-Token header, set log_token to `on`:: |
305 |
|
306 |
kamaki config set log_token on |
307 |
|
308 |
to disable it, set it to `off`:: |
309 |
|
310 |
kamaki config set log_token off |
311 |
|
312 |
or delete it:: |
313 |
|
314 |
kamaki config delete log_token |
315 |
|
316 |
Verbose and Include |
317 |
""""""""""""""""""" |
318 |
|
319 |
Most kamaki commands are translated into http requests. Kamaki clients API |
320 |
translated the semantics to REST and handles the response. Users who need to |
321 |
have access to these commands can use the verbose mode that presents the HTTP |
322 |
Request details as well as the full server response. |
323 |
|
324 |
To run kamaki in verbose mode use the -v or --verbose option |
325 |
|
326 |
Be default, kamaki in verbose mode prints down only the headers and the address |
327 |
information, thus hiding the data body of the request or response. To see the |
328 |
data body, the -i option can be used. |
329 |
|
330 |
One-command features |
331 |
^^^^^^^^^^^^^^^^^^^^ |
332 |
|
333 |
Kamaki commands can be used along with advanced shell features. |
334 |
|
335 |
.. code-block:: console |
336 |
:emphasize-lines: 1 |
337 |
|
338 |
Example 3.4.1: List the trash container contents, containing c1_ |
339 |
|
340 |
|
341 |
$ kamaki file list -o cloud.default.pithos_container=trash| grep c1_ |
342 |
c1_1370859409.0 20KB |
343 |
c1_1370859414.0 9MB |
344 |
c1_1370859409.1 110B |
345 |
|
346 |
The -o argument can be used to temporarily override various (set or unset) |
347 |
options. In one command, all -o option sets are forgotten just after the |
348 |
command has been completed, and the previous settings are restored (the |
349 |
configuration file is not modified). |
350 |
|
351 |
The file-list command in example 3.4.1 runs with an explicitly provided |
352 |
pithos_account, which temporarily overrides the one probably provided in the |
353 |
configuration file (it works even if the user has not set the optional |
354 |
pithos_account config option). |
355 |
|
356 |
Interactive shell |
357 |
----------------- |
358 |
|
359 |
Command Contexts |
360 |
^^^^^^^^^^^^^^^^ |
361 |
|
362 |
The kamaki interactive shell implements the notion of command contexts. Each |
363 |
command group is also a context where the users can **enter** by typing the |
364 |
group name. If the context switch is successful, the kamaki shell prompt |
365 |
changes to present the new context ("file" in example 4.1.1). |
366 |
|
367 |
.. code-block:: console |
368 |
:emphasize-lines: 1 |
369 |
|
370 |
Example 4.1.1: Enter file commands context / group |
371 |
|
372 |
|
373 |
$ kamaki |
374 |
[kamaki]: file |
375 |
[file]: |
376 |
|
377 |
Type **exit** (alternatively **ctrl-D** in (X)nix systems or **ctrl-Z** in |
378 |
Windows) to exit a context and return to the context of origin. If already at |
379 |
the top context (kamaki), an exit is equivalent to exiting the program. |
380 |
|
381 |
.. code-block:: console |
382 |
:emphasize-lines: 1 |
383 |
|
384 |
Example 4.1.2: Exit file context and then exit kamaki |
385 |
|
386 |
[file]: exit |
387 |
[kamaki]: exit |
388 |
$ |
389 |
|
390 |
A user might **browse** through different contexts during one session. |
391 |
|
392 |
.. code-block:: console |
393 |
:emphasize-lines: 1 |
394 |
|
395 |
Example 4.1.3: Execute list command in different contexts |
396 |
|
397 |
$ kamaki |
398 |
[kamaki]: config |
399 |
[config]: list |
400 |
... (configuration options listing) ... |
401 |
[config]: exit |
402 |
[kamaki]: file |
403 |
[file]: list |
404 |
... (storage containers listing) ... |
405 |
[file]: exit |
406 |
[kamaki]: server |
407 |
[server]: list |
408 |
... (VMs listing) ... |
409 |
[server]: exit |
410 |
[kamaki]: |
411 |
|
412 |
Users have the option to avoid switching between contexts: all commands can run |
413 |
from the **top context**. As a result, examples 4.1.3 and 4.1.4 are equivalent. |
414 |
|
415 |
.. code-block:: console |
416 |
:emphasize-lines: 1 |
417 |
|
418 |
Example 4.1.4: Execute different "list" commands from top context |
419 |
|
420 |
|
421 |
[kamaki]: config list |
422 |
... (configuration options listing) ... |
423 |
[kamaki]: file list |
424 |
... (storage container listing) ... |
425 |
[kamaki]: server list |
426 |
... (VMs listing) ... |
427 |
[kamaki]: |
428 |
|
429 |
Using Help |
430 |
^^^^^^^^^^ |
431 |
|
432 |
There are two help mechanisms: a context-level and a command-level. |
433 |
|
434 |
**Context-level help** lists the available commands in a context and can also |
435 |
offer a short description for each command. |
436 |
|
437 |
Context-level help syntax:: |
438 |
|
439 |
* Show available commands in current context * |
440 |
[context]: help |
441 |
[context]: ? |
442 |
|
443 |
* Show help for command cmd * |
444 |
[context]: help cmd |
445 |
[context]: ?cmd |
446 |
|
447 |
The context-level help results may change from context to context |
448 |
|
449 |
.. code-block:: console |
450 |
:emphasize-lines: 1 |
451 |
|
452 |
Example 4.2.1: Get available commands and then get help in a context |
453 |
|
454 |
|
455 |
[kamaki]: help |
456 |
|
457 |
kamaki commands: |
458 |
================ |
459 |
user config flavor history image network server file |
460 |
|
461 |
interactive shell commands: |
462 |
=========================== |
463 |
exit help shell |
464 |
|
465 |
[kamaki]: ?config |
466 |
Configuration commands (config -h for more options) |
467 |
|
468 |
[kamaki]: config |
469 |
|
470 |
[config]: ? |
471 |
|
472 |
config commands: |
473 |
================ |
474 |
delete get list set |
475 |
|
476 |
interactive shell commands: |
477 |
=========================== |
478 |
exit help shell |
479 |
|
480 |
[config]: help set |
481 |
Set a configuration option (set -h for more options) |
482 |
|
483 |
In context-level, there is a distinction between kamaki-commands and |
484 |
interactive shell commands. The former are available in one-command mode and |
485 |
are related to the cloud client setup and use, while the later are |
486 |
context-shell functions. |
487 |
|
488 |
**Command-level help** prints the syntax, arguments and description of a |
489 |
specific (terminal) command |
490 |
|
491 |
Command-level help syntax:: |
492 |
|
493 |
* Get help for command cmd1 cmd2 ... cmdN * |
494 |
[context]: cmd1 cmd2 ... cmdN -h |
495 |
<syntax> |
496 |
|
497 |
<description> |
498 |
|
499 |
<arguments and possible extensions> |
500 |
|
501 |
Command-level help mechanism is exactly the same as the one used in |
502 |
one-command mode. For example, it is invoked by using the -h or --help |
503 |
parameter at any point. |
504 |
|
505 |
.. code-block:: console |
506 |
:emphasize-lines: 1 |
507 |
|
508 |
Example 4.2.2: Get command-level help for config and config-set |
509 |
|
510 |
|
511 |
[kamaki]: config --help |
512 |
config: Configuration commands |
513 |
delete: Delete a configuration option (and use the default value) |
514 |
get : Show a configuration option |
515 |
list : List configuration options |
516 |
set : Set a configuration option |
517 |
|
518 |
[kamaki]: config |
519 |
|
520 |
[config]: set -h |
521 |
usage: set <option> <value> [-v] [-d] [-h] [-i] [--config CONFIG] [-s] |
522 |
|
523 |
Set a configuration option |
524 |
|
525 |
optional arguments: |
526 |
-v, --verbose More info at response |
527 |
-d, --debug Include debug output |
528 |
-h, --help Show help message |
529 |
-i, --include Include protocol headers in the output |
530 |
--config CONFIG Path to configuration file |
531 |
-s, --silent Do not output anything |
532 |
|
533 |
There are many ways of producing a help message, as shown in example 4.2.3 |
534 |
|
535 |
.. code-block:: console |
536 |
:emphasize-lines: 1 |
537 |
|
538 |
Example 4.2.3: Equivalent calls of command-level help for config-set |
539 |
|
540 |
|
541 |
[config]: set -h |
542 |
[config]: set --help |
543 |
[kamaki]: config set -h |
544 |
[kamaki]: config set --help |
545 |
[file]: /config set -h |
546 |
[server]: /config set --help |
547 |
|
548 |
.. _accessing-top-level-commands-ref: |
549 |
|
550 |
Accessing top-level commands |
551 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
552 |
|
553 |
When working in a context, it is often useful to access other contexts or |
554 |
top-level commands. Kamaki offers access to top-level commands by using the |
555 |
`/` prefix, as shown bellow:: |
556 |
|
557 |
* access a command "anothercontext cmd1 cmd2 ... cmdN" |
558 |
[context]: /anothercontext cmd1 cmd2 ... cmdN |
559 |
|
560 |
An example (4.3.1) that showcases how top-level access improves user experience |
561 |
is the creation of a VM. A VM is created with the command server-create. This |
562 |
command is called with three parameters: |
563 |
|
564 |
* the name of the new VM |
565 |
* the flavor id |
566 |
* the image id |
567 |
|
568 |
It is often the case that a user who works in the context command, needs to |
569 |
create a new VM, but hasn't selected a flavor or an image id, or cannot recall |
570 |
the id of that flavor or image. Therefore, it is necessary to list all |
571 |
available flavors (flavor-list) or images (image-compute-list). Both commands |
572 |
belong to different contexts. |
573 |
|
574 |
.. code-block:: console |
575 |
:emphasize-lines: 1 |
576 |
|
577 |
Example 4.3.1: Create a VM from server context |
578 |
|
579 |
[server]: create -h |
580 |
create <name> <flavor id> <image id> ... |
581 |
... |
582 |
|
583 |
[server]: /flavor list |
584 |
... |
585 |
43 AFLAVOR |
586 |
SNF:disk_template: drbd |
587 |
cpu : 4 |
588 |
disk : 10 |
589 |
ram : 2048 |
590 |
|
591 |
[server]: /image compute list |
592 |
1580deb4-edb3-7a246c4c0528 (Ubuntu Desktop) |
593 |
18a82962-43eb-8f8880af89d7 (Windows 7) |
594 |
531aa018-9a40-a4bfe6a0caff (Windows XP) |
595 |
6aa6eafd-dccb-67fe2bdde87e (Debian Desktop) |
596 |
|
597 |
[server]: create 'my debian' 43 6aa6eafd-dccb-67fe2bdde87e |
598 |
... |
599 |
|
600 |
An other example (4.3.2) showcases how to acquire and modify configuration |
601 |
settings from a different context. In this scenario, the user token expires at |
602 |
server side while the user is working. When that happens, the system responds |
603 |
with an *(401) UNAUTHORIZED* message. The user can acquire a new token (valid |
604 |
for the Astakos identity manager of preference) which has to be set to kamaki. |
605 |
|
606 |
.. code-block:: console |
607 |
:emphasize-lines: 1 |
608 |
|
609 |
Example 4.3.2: Set a new token from file context |
610 |
|
611 |
|
612 |
[file]: list |
613 |
(401) UNAUTHORIZED Access denied |
614 |
|
615 |
[file]: /user authenticate |
616 |
(401) UNAUTHORIZED Invalid X-Auth-Token |
617 |
|
618 |
[file]: /config get cloud.default.token |
619 |
my3xp1r3dt0k3n== |
620 |
|
621 |
[file]: /config set cloud.default.token myfr35ht0k3n== |
622 |
|
623 |
[file]: /config get cloud.default |
624 |
cloud.default.url = https://astakos.example.com/astakos/identity/2.0/ |
625 |
cloud.default.token = myfr35ht0k3n== |
626 |
|
627 |
[file]: list |
628 |
1. pithos (10MB, 2 objects) |
629 |
2. trash (0B, 0 objects) |
630 |
|
631 |
.. note:: The error messages on this example where shortened for clarity. |
632 |
Actual kamaki error messages are more helpful and descriptive. |
633 |
|
634 |
The following example compares some equivalent calls that run |
635 |
*user-authenticate* after a *file-list* 401 failure. |
636 |
|
637 |
.. code-block:: console |
638 |
:emphasize-lines: 1,3,10,17,26 |
639 |
|
640 |
Example 4.3.3: Equivalent user-authenticate calls after a file-list 401 |
641 |
|
642 |
* without kamaki interactive shell * |
643 |
$ kamaki file list |
644 |
(401) UNAUTHORIZED Access denied |
645 |
$ kamaki user authenticate |
646 |
... |
647 |
$ |
648 |
|
649 |
* from top-level context * |
650 |
[kamaki]: file list |
651 |
(401) UNAUTHORIZED Access denied |
652 |
[kamaki]: user authenticate |
653 |
... |
654 |
[kamaki] |
655 |
|
656 |
* maximum typing * |
657 |
[file]: list |
658 |
(401) UNAUTHORIZED Access denied |
659 |
[file]: exit |
660 |
[kamaki]: user |
661 |
[user]: authenticate |
662 |
... |
663 |
[user]: |
664 |
|
665 |
* minimum typing * |
666 |
[file]: list |
667 |
(401) UNAUTHORIZED Access denied |
668 |
[file]: /user authenticate |
669 |
... |
670 |
[file]: |
671 |
|
672 |
.. hint:: To exit kamaki shell while in a context, try */exit* |
673 |
|
674 |
Using config |
675 |
^^^^^^^^^^^^ |
676 |
|
677 |
The configuration mechanism of kamaki is detailed in the |
678 |
`setup section <setup.html>`_ and it is common for both interaction modes. In |
679 |
specific, the configuration mechanism is implemented as a command group, namely |
680 |
`config`. Using the config commands is as straightforward as any other kamaki |
681 |
commands. |
682 |
|
683 |
It is often useful to set, delete or update a value. This can be managed either |
684 |
inside the config context or from any command context by using the / prefix. |
685 |
|
686 |
.. Note:: config updates in kamaki shell persist even after the session is over |
687 |
|
688 |
All setting changes affect the physical kamaki config file. The config file is |
689 |
created automatically at callers' home firectory the first time a config option |
690 |
is set, and lives there as *.kamakirc* . It can be edited with any text editor |
691 |
or managed with kamaki config commands. |
692 |
|
693 |
In example 4.4.1 the user is going to work with only one storage container. The |
694 |
file commands use the container:path syntax, but if the user sets a container |
695 |
name as default, the container name can be omitted. This is possible by setting |
696 |
a *file.container* setting. |
697 |
|
698 |
.. code-block:: console |
699 |
:emphasize-lines: 1 |
700 |
|
701 |
Example 4.4.1: Set default storage container (cloud: default) |
702 |
|
703 |
|
704 |
[file]: list |
705 |
1. mycontainer (32MB, 2 objects) |
706 |
2. pithos (0B, 0 objects) |
707 |
3. trash (2MB, 1 objects) |
708 |
|
709 |
[file]: list mycontainer |
710 |
1. D mydir/ |
711 |
2. 20M mydir/rndm_local.file |
712 |
|
713 |
[file]: /config set cloud.default.pithos_container mycontainer |
714 |
|
715 |
[file]: list |
716 |
1. D mydir/ |
717 |
2. 20M mydir/rndm_local.file |
718 |
|
719 |
After a while, the user needs to work with multiple containers, therefore a |
720 |
default container is no longer needed. The *pithos_container* setting can be |
721 |
deleted, as shown in example 4.4.2 |
722 |
|
723 |
.. code-block:: console |
724 |
:emphasize-lines: 1 |
725 |
|
726 |
Example 4.4.2: Delete a setting option (cloud: default) |
727 |
|
728 |
|
729 |
[file]: /config delete cloud.default.pithos_container |
730 |
|
731 |
[file]: list |
732 |
1. mycontainer (32MB, 2 objects) |
733 |
2. pithos (0B, 0 objects) |
734 |
3. trash (2MB, 1 objects) |
735 |
|
736 |
Using history |
737 |
^^^^^^^^^^^^^ |
738 |
|
739 |
There are two history modes: session and permanent. Session history keeps |
740 |
record of all actions in a kamaki shell session, while permanent history |
741 |
appends all commands to an accessible history file. |
742 |
|
743 |
Session history is only available in interactive shell mode. Users can iterate |
744 |
through past commands in the same session with the ↑ and ↓ keys. Session |
745 |
history is not stored, although syntactically correct commands are recorded |
746 |
through the permanent history mechanism. |
747 |
|
748 |
Permanent history is implemented as a command group and is common to both the |
749 |
one-command and shell interfaces. In specific, every syntactically correct |
750 |
command is appended in a history file (configured as `history_file` in |
751 |
settings, see `setup section <setup.html>`_ for details). Commands executed in |
752 |
one-command mode are mixed with the ones run in kamaki shell (also |
753 |
see :ref:`using-history-ref` section on this guide). |
754 |
|
755 |
Scripting |
756 |
^^^^^^^^^ |
757 |
|
758 |
The history-run feature allows the sequential run of previous command |
759 |
executions in kamaki shell. |
760 |
|
761 |
The following sequence copies and downloads a file from *mycontainer1* , |
762 |
uploads it to *mycontainer2* , then undo the proccess and repeats it with |
763 |
history-run |
764 |
|
765 |
.. code-block:: console |
766 |
:emphasize-lines: 1,12,19,32 |
767 |
|
768 |
* Download mycontainer1:myfile and upload it to mycontainer2:myfile |
769 |
[kamaki]: file |
770 |
[file]: copy mycontainer1:somefile mycontainer1:myfile |
771 |
[file]: download mycontainer1:myfile mylocalfile |
772 |
Download completed |
773 |
[file]: upload mylocalfile mycontainer2:myfile |
774 |
Upload completed |
775 |
|
776 |
* undo the process * |
777 |
[file]: !rm mylocalfile |
778 |
[file]: delete mycontainer1:myfile |
779 |
[file]: delete mycontainer2:myfile |
780 |
|
781 |
* check history entries * |
782 |
[file]: exit |
783 |
[kamaki]: history |
784 |
[history]: show |
785 |
1. file |
786 |
2. file copy mycontainer1:somefile mycontainer1:myfile |
787 |
3. file download mycontainer1:myfile mylocalfile |
788 |
4. file upload mylocalfile mycontainer2:myfile |
789 |
5. file delete mycontainer1:myfile |
790 |
6. file delete mycontainer2:myfile |
791 |
7. history |
792 |
8. history show |
793 |
|
794 |
*repeat the process * |
795 |
[history]: run 2-4 |
796 |
<file copy mycontainer1:somefile mycontainer1:myfile> |
797 |
<file download mycontainer1:myfile mylocalfile> |
798 |
Download completed |
799 |
<file upload mylocalfile mycontainer2:myfile> |
800 |
Upload completed |
801 |
|
802 |
For powerfull scripting, users are advised to take advantage of their os shell |
803 |
scripting capabilities and combine them with kamaki one-command. Still, the |
804 |
history-run functionality might prove handy in many occasions. |
805 |
|
806 |
Tab completion |
807 |
^^^^^^^^^^^^^^ |
808 |
|
809 |
Kamaki shell features tab completion for the first level of command terms of |
810 |
the current context. Tab completion pool changes dynamically when the context |
811 |
is switched. Currently, tab completion is not supported when / is used |
812 |
(see :ref:`accessing-top-level-commands-ref` ). |
813 |
|
814 |
OS Shell integration |
815 |
^^^^^^^^^^^^^^^^^^^^ |
816 |
|
817 |
Kamaki shell features the ability to execute OS-shell commands from any |
818 |
context. This can be achieved by typing *!* or *shell*:: |
819 |
|
820 |
[kamaki_context]: !<OS shell command> |
821 |
... OS shell command output ... |
822 |
|
823 |
[kamaki_context]: shell <OS shell command> |
824 |
... OS shell command output ... |
825 |
|
826 |
.. code-block:: console |
827 |
:emphasize-lines: 1 |
828 |
|
829 |
Example 4.7.1: Run unix-style shell commands from kamaki shell |
830 |
|
831 |
|
832 |
[kamaki]: !ls -al |
833 |
total 16 |
834 |
drwxrwxr-x 2 username username 4096 Nov 27 16:47 . |
835 |
drwxrwxr-x 7 username username 4096 Nov 27 16:47 .. |
836 |
-rw-rw-r-- 1 username username 8063 Jun 28 14:48 kamaki-logo.png |
837 |
|
838 |
[kamaki]: shell cp kamaki-logo.png logo-copy.png |
839 |
|
840 |
[kamaki]: shell ls -al |
841 |
total 24 |
842 |
drwxrwxr-x 2 username username 4096 Nov 27 16:47 . |
843 |
drwxrwxr-x 7 username username 4096 Nov 27 16:47 .. |
844 |
-rw-rw-r-- 1 username username 8063 Jun 28 14:48 kamaki-logo.png |
845 |
-rw-rw-r-- 1 username username 8063 Jun 28 14:48 logo-copy.png |
846 |
|
847 |
|
848 |
Kamaki shell commits command strings to the outside shell and prints the |
849 |
results, without interacting with it. After a command is finished, kamaki shell |
850 |
returns to its initial state, which involves the current directory, as show in |
851 |
example 4.8.2 |
852 |
|
853 |
.. code-block:: console |
854 |
:emphasize-lines: 1 |
855 |
|
856 |
Example 4.8.2: Attempt (and fail) to change working directory |
857 |
|
858 |
|
859 |
[kamaki]: !pwd |
860 |
/home/username |
861 |
|
862 |
[kamaki]: !cd .. |
863 |
|
864 |
[kamaki]: shell pwd |
865 |
/home/username |