Skip to content

Commit 21edb12

Browse files
committed
[airos] fixed indentation in json, python examples in intermediate docs
1 parent ac95dca commit 21edb12

1 file changed

Lines changed: 21 additions & 36 deletions

File tree

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)