Skip to content

Commit 8c9bf31

Browse files
Jenkinsopenstack-gerrit
authored andcommitted
Merge "Add documentation of interactive mode"
2 parents f6fc2db + 625a8ae commit 8c9bf31

2 files changed

Lines changed: 112 additions & 0 deletions

File tree

‎doc/source/index.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Contents:
1616
commands
1717
plugins
1818
authentication
19+
interactive
1920
man/openstack
2021

2122
Getting Started

‎doc/source/interactive.rst‎

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
================
2+
Interactive Mode
3+
================
4+
5+
OpenStackClient has an interactive mode, similar to the :program:`virsh(1)` or
6+
:program:`lvm(8)` commands on Linux. This mode is useful for executing a
7+
series of commands without having to reload the CLI, or more importantly,
8+
without having to re-authenticate to the cloud.
9+
10+
Enter interactive mode by issuing the :command:`openstack` command with no
11+
subcommand. An :code:`(openstack)` prompt will be displayed. Interactive mode
12+
is terminated with :command:`exit`.
13+
14+
Authentication
15+
==============
16+
17+
Authentication happens exactly as before, using the same global command line
18+
options and environment variables, except it only happens once.
19+
The credentials are cached and re-used for subsequent commands. This means
20+
that to work with multiple clouds interactive mode must be ended so a
21+
authentication to the second cloud can occur.
22+
23+
Scripting
24+
=========
25+
26+
Using interactive mode inside scripts sounds counter-intuitive, but the same
27+
single-authentication benefit can be achieved by passing OSC commands to
28+
the CLI via :code:`stdin`.
29+
30+
Sample session:
31+
32+
.. code-block:: bash
33+
34+
# assume auth credentials are in the environment
35+
$ openstack
36+
(openstack) keypair list
37+
+--------+-------------------------------------------------+
38+
| Name | Fingerprint |
39+
+--------+-------------------------------------------------+
40+
| bunsen | a5:da:0c:52:e8:52:42:a3:4f:b8:22:62:7b:e4:e8:89 |
41+
| beaker | 45:9c:50:56:7c:fc:3a:b6:b5:60:02:2f:41:fb:a9:4c |
42+
+--------+-------------------------------------------------+
43+
(openstack) image list
44+
+--------------------------------------+----------------+
45+
| ID | Name |
46+
+--------------------------------------+----------------+
47+
| 78b23835-c800-4d95-9d2a-e4de59a553d8 | OpenWRT r42884 |
48+
| 2e45d43a-7c25-45f1-b012-06ac313e2f6b | Fedora 20 |
49+
| de3a8396-3bae-42de-84bd-f4e398b8c320 | CirrOS |
50+
+--------------------------------------+----------------+
51+
(openstack) flavor list
52+
+--------------------------------------+----------+--------+--------+-----------+------+-------+-------------+-----------+-------------+
53+
| ID | Name | RAM | Disk | Ephemeral | Swap | VCPUs | RXTX Factor | Is Public | Extra Specs |
54+
+--------------------------------------+----------+--------+--------+-----------+------+-------+-------------+-----------+-------------+
55+
| 12594680-56f7-4da2-8322-7266681b3070 | m1.small | 2048 | 20 | 0 | | 1 | | True | |
56+
| 9274f903-0cc7-4a95-9124-1968018e355d | m1.tiny | 512 | 5 | 0 | | 1 | | True | |
57+
+--------------------------------------+----------+--------+--------+-----------+------+-------+-------------+-----------+-------------+
58+
(openstack) server create --image CirrOS --flavor m1.small --key-name beaker sample-server
59+
+-----------------------------+-------------------------------------------------+
60+
| Field | Value |
61+
+-----------------------------+-------------------------------------------------+
62+
| config_drive | |
63+
| created | 2014-11-19T18:08:41Z |
64+
| flavor | m1.small (12594680-56f7-4da2-8322-7266681b3070) |
65+
| id | 3a9a7f82-e902-4948-9245-52b045c76a1d |
66+
| image | CirrOS (de3a8396-3bae-42de-84bd-f4e398b8c320) |
67+
| key_name | bunsen |
68+
| name | sample-server |
69+
| progress | 0 |
70+
| properties | |
71+
| security_groups | [{u'name': u'default'}] |
72+
| status | BUILD |
73+
| tenant_id | 53c93c7952594d9ba16bd7072a165ce8 |
74+
| updated | 2014-11-19T18:08:42Z |
75+
| user_id | 1e4eea54c7124688a8092bec6e2dbee6 |
76+
+-----------------------------+-------------------------------------------------+
77+
78+
A similar session can be issued all at once:
79+
80+
.. code-block:: bash
81+
82+
$ openstack <<EOF
83+
> keypair list
84+
> flavor show m1.small
85+
> EOF
86+
(openstack) +--------+-------------------------------------------------+
87+
| Name | Fingerprint |
88+
+--------+-------------------------------------------------+
89+
| bunsen | a5:da:0c:52:e8:52:42:a3:4f:b8:22:62:7b:e4:e8:89 |
90+
| beaker | 45:9c:50:56:7c:fc:3a:b6:b5:60:02:2f:41:fb:a9:4c |
91+
+--------+-------------------------------------------------+
92+
(openstack) +----------------------------+--------------------------------------+
93+
| Field | Value |
94+
+----------------------------+--------------------------------------+
95+
| OS-FLV-DISABLED:disabled | False |
96+
| OS-FLV-EXT-DATA:ephemeral | 0 |
97+
| disk | 20 |
98+
| id | 12594680-56f7-4da2-8322-7266681b3070 |
99+
| name | m1.small |
100+
| os-flavor-access:is_public | True |
101+
| ram | 2048 |
102+
| swap | |
103+
| vcpus | 1 |
104+
+----------------------------+--------------------------------------+
105+
106+
Limitations
107+
===========
108+
109+
The obvious limitations to Interactive Mode is that it is not a Domain Specific
110+
Language (DSL), just a simple command processor. That means there are no variables
111+
or flow control.

0 commit comments

Comments
 (0)