Skip to content

Commit c92cbf0

Browse files
committed
[airos] use role provided from users instead of guess
updated docs and converter to use properties role instread of management
1 parent 5a727e4 commit c92cbf0

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed

docs/source/backends/airos.rst

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ AirOS supports the following types of interfaces
141141
* **wirelesss interfaces**: must be of type ``wireless``
142142
* **bridge interfaces**: must be of type ``bridge``
143143

144-
A network interface can be designed to be the management interfaces by setting the ``managed`` key to ``True`` on the address chosen.
144+
A network interface can be designed to be the management interfaces by setting the ``role`` key to ``mlan`` on the address chosen.
145145

146146
As an example here is a snippet that set the vlan ``eth0.2`` to be the management interface on the address ``192.168.1.20``
147147

@@ -156,7 +156,7 @@ As an example here is a snippet that set the vlan ``eth0.2`` to be the managemen
156156
{
157157
"address": "192.168.1.20",
158158
"family": "ipv4",
159-
"managed": true,
159+
"role": "mlan",
160160
"mask": 24,
161161
"proto": "static"
162162
}
@@ -188,7 +188,40 @@ As an example here is a snippet that enables both auto-negotiation and flow cont
188188
Role
189189
^^^^
190190

191-
Interfaces can be assigned a ``role`` to mimic the web interfaces features. As an example setting the ``management`` property of an address to ``true`` will add the role ``mlan`` to the interface configuration. If not set the management interface will be selected as the (first) one providing a gateway in one of it's addresses.
191+
Interfaces can be assigned a ``role`` to mimic the web interfaces features.
192+
193+
As an example setting the ``role`` property of an address to ``mlan`` will add the role ``mlan`` to the interface configuration.
194+
195+
Here is the snippet to set the role to ``mlan``
196+
197+
.. code-block:: json
198+
199+
{
200+
"interfaces": [
201+
{
202+
"type": "ethernet",
203+
"name": "eth0",
204+
"addresses": [
205+
{
206+
"family": "ipv4",
207+
"proto": "static",
208+
"address": "192.168.1.1",
209+
"role": "mlan"
210+
}
211+
]
212+
}
213+
]
214+
}
215+
216+
217+
This is the list of roles available for a device in ``bridge`` mode:
218+
219+
* ``mlan`` for the management interface
220+
221+
This is the list of roles available for a device in ``router`` mode:
222+
223+
* ``wan`` for the wan interface
224+
* ``lan`` for the lan interface
192225

193226

194227
DNS servers

netjsonconfig/backends/airos/converters.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,6 @@ def to_intermediate(self):
297297
class Netconf(AirOsConverter):
298298
netjson_key = 'interfaces'
299299

300-
def type_to_role(self, typestr):
301-
roles = {
302-
'ethernet': 'mlan',
303-
'bridge': 'mlan',
304-
}
305-
return roles.get(typestr, '')
306-
307300
def to_intermediate(self):
308301
result = []
309302
interfaces = []
@@ -331,8 +324,8 @@ def to_intermediate(self):
331324
# configuration
332325
for addr in addresses:
333326
temp = deepcopy(base)
334-
if addr.get('management'):
335-
temp['role'] = self.type_to_role(interface['type'])
327+
if 'role' in addr:
328+
temp['role'] = addr.get('role', '')
336329
# handle explicit address policy
337330
if addr['proto'] == 'dhcp':
338331
temp['autoip'] = {'status': 'enabled'}

0 commit comments

Comments
 (0)