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