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