Skip to content

Commit ee9e8c5

Browse files
polycubectl: improve documentation
- add syntax explanation - add documentation about reading configuration from standard input Signed-off-by: Mauricio Vasquez B <mauriciovasquezbernal@gmail.com>
1 parent 074ece5 commit ee9e8c5

File tree

1 file changed

+63
-7
lines changed

1 file changed

+63
-7
lines changed

Documentation/polycubectl/polycubectl.rst

Lines changed: 63 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@ How to use
1515
----------
1616

1717
**NOTE**: ``polycubed`` must be running, in order to use ``polycubectl``.
18-
You can start the daemon typing ``sudo polycubed`` in another terminal. Refer to :doc:`Quick Start <../quickstart>`.
18+
You can start the daemon typing ``sudo polycubed`` in another terminal.
19+
Refer to :doc:`Quick Start <../quickstart>`.
1920

2021
``polycubectl`` is a generic CLI, that enables the user to interact with ``Cubes`` (``bridge``, ``router``, ...) and with some framework primitives to ``connect``, ``show`` and build complex ``topologies``.
2122

2223
::
2324

2425
# Show help
2526
polycubectl --help
26-
27-
::
28-
2927
Keyword Type Description
3028
simpleforwarder service Simple Forwarder Base Service
3129
simplebridge service Simple L2 Bridge Service
@@ -45,14 +43,71 @@ You can start the daemon typing ``sudo polycubed`` in another terminal. Refer to
4543
connect command Connect ports
4644
disconnect command Disconnect ports
4745

48-
attach command Attach transparent cubes
49-
detach command Detach transparent cubes
46+
attach command Attach transparent cubes
47+
detach command Detach transparent cubes
5048

5149
services command Show/Add/Del services (e.g. Bridge, Router, ..)
5250
cubes command Show running service instances (e.g. br1, nat2, ..)
5351
topology command Show topology of service instances
5452
netdevs command Show net devices available
5553

54+
``polycubectl`` is service agnostic, hence the syntax is service dependent.
55+
However we can generalize the syntax as:
56+
57+
::
58+
59+
polycubectl [parent] [command] [child] [argument0=value0] [argument1=value1]
60+
61+
62+
- ``parent``: path of the parent resource where the command has to be applied.
63+
- ``command``: ``add``, ``del``, ``show``, ``set`` or a yang action.
64+
- ``child``: specific resource where the command is applied.
65+
- ``argument``: some commands accept additional commands that are sent in the body request.
66+
67+
Some examples:
68+
69+
::
70+
71+
polycubectl router r0 add loglevel=debug
72+
polycubectl r0 ports add port1 ip=10.1.0.1 netmask=255.255.0.0
73+
polycubectl r0 show routing table
74+
polycubectl r0 ports port1 set peer=veth1
75+
polycubectl r0 ports del port1
76+
77+
# yang action
78+
polycubectl firewall1 chain ingress append src=10.0.0.1 action=DROP
79+
80+
81+
The best way to know what is the syntax for each service is to use the `Help`_ or the bash completion by pressing ``<TAB>`` at any point.
82+
83+
84+
``polycubectl`` is also able to read the contents of the request from the standard input, it can be used in two ways:
85+
86+
Passing complex configuration from the command line
87+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
88+
::
89+
90+
# create a helloworld instance with loglevel debug and action forward
91+
polycubectl helloworld add hw0 << EOF
92+
{
93+
"loglevel": "debug",
94+
"action": "forward"
95+
}
96+
EOF
97+
98+
99+
Reading configuration from a file
100+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
101+
::
102+
103+
# create helloworld from a yaml file
104+
polycubectl helloworld add hw0 < hw0.yaml
105+
106+
# create a router from a json file
107+
polycubectl router add r0 < r0.json
108+
109+
# add a list of cubes
110+
polycubectl cubes add < mycubes.yaml
56111

57112
Help
58113
^^^^
@@ -124,7 +179,8 @@ More complete examples are available in :doc:`tutorials <../tutorials/index>`.
124179
Configuration
125180
-------------
126181

127-
By default, the CLI contacts ``polycubed`` daemon at ``http://localhost:9000/polycube/v1/``. The user can override this configuration with following instructions.
182+
By default, ``polycubectl`` contacts ``polycubed`` at ``http://localhost:9000/polycube/v1/``.
183+
The user can override this configuration with following instructions.
128184

129185
Parameters
130186
^^^^^^^^^^

0 commit comments

Comments
 (0)