Skip to content

Commit 2d6c413

Browse files
committed
[airos] updated docs for airos backend and intermediate representation
[airos] fixed problem with ellipsis not recognised in json example [airos] updated docs for ntp client and ntp servers [airos] fixed netjoson examples in documentation to be compliant to netjson [airos] fixed typo [airos] added terminal dot [airos] added snippet for the undecided about authentication encryption
1 parent ac95dca commit 2d6c413

File tree

2 files changed

+75
-49
lines changed

2 files changed

+75
-49
lines changed

docs/source/backends/airos.rst

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,12 @@ The default values for this key are as reported below
149149
Netmode
150150
-------
151151

152-
AirOS v8.3 can operate in ``bridge`` and ``router`` mode (but defaults to ``bridge``) and this can be specified with the ``netmode`` property
152+
AirOS v8.3 can operate in ``bridge`` and ``router`` mode (but defaults to ``bridge``) and this can be specified with the ``netmode`` property.
153153

154154
.. code-block:: json
155155
156156
{
157+
"type": "DeviceConfiguration",
157158
"netmode": "bridge"
158159
}
159160
@@ -162,16 +163,35 @@ NTP servers
162163

163164
This is an extension to the `NetJSON` specification.
164165

165-
By setting the key ``ntp_servers`` in your input you can provide a list of ntp servers to use.
166+
By setting the key ``ntp`` property in your input you can provide the configuration for the ntp client running on the device.
166167

167168
.. code-block:: json
168169
169170
{
170171
"type": "DeviceConfiguration",
171-
...
172-
"ntp_servers": [
173-
"0.ubnt.pool.ntp.org"
174-
]
172+
"ntp": {
173+
"enabled": true,
174+
"server": [
175+
"0.ubnt.pool.ntp.org"
176+
]
177+
}
178+
}
179+
180+
For the lazy one we provide these defaults
181+
182+
.. code-block:: json
183+
184+
{
185+
"type": "DeviceConfiguration",
186+
"ntp": {
187+
"enabled": true,
188+
"server": [
189+
"0.pool.ntp.org",
190+
"1.pool.ntp.org",
191+
"2.pool.ntp.org",
192+
"3.pool.ntp.org"
193+
]
194+
}
175195
}
176196
177197
Users
@@ -188,7 +208,7 @@ From the antenna configuration take the user section.
188208
users.1.name=ubnt
189209
users.1.password=$1$yRo1tmtC$EcdoRX.JnD4VaEYgghgWg1
190210
191-
I the line ``users.1.password=$1$yRo1tmtC$EcdoRX.JnD4VaEYgghgWg1`` there are both the salt and the password hash in the format ``$ algorithm $ salt $ hash $``, e.g in the previous block ``algorithm=1``, ``salt=yRo1tmtC`` and ``hash=EcdoRX.JnD4VaEYgghgWg1``.
211+
In the line ``users.1.password=$1$yRo1tmtC$EcdoRX.JnD4VaEYgghgWg1`` there are both the salt and the password hash in the format ``$ algorithm $ salt $ hash $``, e.g in the previous block ``algorithm=1``, ``salt=yRo1tmtC`` and ``hash=EcdoRX.JnD4VaEYgghgWg1``.
192212

193213
To specify the password in NetJSON use the ``user`` property.
194214

@@ -220,9 +240,11 @@ As an example here is a snippet that set the authentication protocol to WPA2 per
220240
{
221241
"name": "wlan0",
222242
"type": "wireless",
223-
"encryption": {
224-
"protocol": "wpa2_personal",
225-
"key": "changeme"
243+
"wireless": {
244+
"encryption": {
245+
"protocol": "wpa2_personal",
246+
"key": "changeme"
247+
}
226248
}
227249
}
228250
]
@@ -237,12 +259,31 @@ And another that set the authentication protocol to WPA2 enterprise, but this is
237259
{
238260
"name": "wlan0",
239261
"type": "wireless",
240-
"encryption": {
241-
"protocol": "wpa2_enterprise",
242-
"key": "changeme"
262+
"wireless": {
263+
"encryption": {
264+
"protocol": "wpa2_enterprise",
265+
"key": "changeme"
266+
}
243267
}
244268
}
245269
]
246270
}
247271
272+
The ``encryption`` property **must** be specified otherwise you will experience a ``ValidationError``, if you are not sure on what you want
273+
use this snippet to set to no encryption
274+
275+
.. code-block:: json
276+
277+
{
278+
"interfaces": [
279+
{
280+
"name": "wlan0",
281+
"type": "wireless",
282+
"wireless": {
283+
"encryption": {
284+
"protocol": "none"
285+
}
286+
}
287+
}
288+
}
248289
Leaving the `NetJSON Encryption object <http://netjson.org/rfc.html#rfc.section.5.4.2.1>` empty defaults to no encryption at all.

docs/source/backends/intermediate.rst

Lines changed: 21 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,11 @@ e.g. `vlan.1.devname=eth0` we store a list of dictionaries.
8080
{
8181
'ipython' : True,
8282
}
83-
],
84-
},
83+
],
84+
},
8585
}
86-
])
86+
]
87+
)
8788
8889
And the resulting tree is:
8990

@@ -127,26 +128,10 @@ Flattening
127128
To avoid at all cost a recursive logic in the template we flatten the intermediate
128129
representation to something that has a *namespace* a *key* and a *value*.
129130

130-
This input NetJSON will be converted to a python :ref:`configuration_dictionary`:
131+
The objective is to go from a python :ref:`configuration_dictionary` that we get from loading a NetJSON to the AirOS configuration.
131132

132-
.. code-block:: json
133+
An input :ref:`configuration_dictionary` is just a python dictionary, e.g.:
133134

134-
//netjson
135-
{
136-
"type" : "DeviceConfiguration",
137-
"interfaces" : [
138-
{
139-
"name" : "eth0.1",
140-
"type" : "ethernet",
141-
"comment" : "management vlan"
142-
},
143-
{
144-
"name" : "eth0.2",
145-
"type" : "ethernet",
146-
"comment" : "traffic vlan"
147-
}
148-
]
149-
}
150135

151136
.. code-block:: python
152137
@@ -157,11 +142,12 @@ This input NetJSON will be converted to a python :ref:`configuration_dictionary`
157142
'name' : 'eth0.1',
158143
'type' : 'ethernet',
159144
'comment' : 'management vlan'
145+
'comment' : 'management'
160146
},
161147
{
162148
'name' : 'eth0.2',
163149
'type' : 'ethernet',
164-
'comment' : 'traffic vlan'
150+
'comment' : 'traffic'
165151
}
166152
]
167153
}
@@ -191,21 +177,20 @@ resembles the target text, the output configuration.
191177
'vlan',
192178
#options
193179
[
194-
{
195-
# key : value
196-
'1.devname' : 'eth0',
197-
'1.id' : '1'
198-
'1.status' : 'enabled',
199-
'1.comment' : 'management'
200-
},
201-
{
202-
'2.devname' : 'eth0',
203-
'2.id' : '2'
204-
'2.status' : 'enabled',
205-
'2.comment' : 'traffic'
206-
}
180+
{
181+
# key : value
182+
'1.devname' : 'eth0',
183+
'1.id' : '1'
184+
'1.status' : 'enabled',
185+
'1.comment' : 'management'
186+
},
187+
{
188+
'2.devname' : 'eth0',
189+
'2.id' : '2'
190+
'2.status' : 'enabled',
191+
'2.comment' : 'traffic'
192+
}
207193
]
208-
209194
)
210195
211196
And to do that we get rid of the multiple indentation levels by flattening the tree structure.

0 commit comments

Comments
 (0)