Statistics
| Branch: | Tag: | Revision:

root / docs / usage.rst @ 2bd23362

History | View | Annotate | Download (26.3 kB)

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