Skip to content

Commit eada34c

Browse files
committed
[airos] added schema and handler for autoneg and flowcontrol property
1 parent 0237f7d commit eada34c

File tree

2 files changed

+33
-9
lines changed

2 files changed

+33
-9
lines changed

netjsonconfig/backends/airos/converters.py

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,26 @@ def type_to_role(self, typestr):
268268
}
269269
return roles.get(typestr, '')
270270

271+
def autoneg_status(self, interface):
272+
if interface.get('autoneg'):
273+
return 'enabled'
274+
else:
275+
return 'disabled'
276+
277+
def flowcontrol_status(self, interface):
278+
if interface.get('flowcontrol'):
279+
status = 'enabled'
280+
else:
281+
status = 'disabled'
282+
return {
283+
'rx': {
284+
'status': status,
285+
},
286+
'tx': {
287+
'status': status,
288+
},
289+
}
290+
271291
def to_intermediate(self):
272292
result = []
273293
interfaces = []
@@ -282,15 +302,9 @@ def to_intermediate(self):
282302
}
283303
# handle interface type quirks
284304
if interface['type'] == 'ethernet' and '.' not in interface['name']:
285-
base['autoneg'] = 'enabled'
286-
base['flowcontrol'] = {
287-
'rx': {
288-
'status': 'enabled',
289-
},
290-
'tx': {
291-
'status': 'enabled',
292-
},
293-
}
305+
base['autoneg'] = self.autoneg_status(interface)
306+
307+
base['flowcontrol'] = self.flowcontrol_status(interface)
294308

295309
if interface['type'] == 'wireless':
296310
base['devname'] = interface['wireless']['radio']

netjsonconfig/backends/airos/schema.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,16 @@
6060
},
6161
},
6262
},
63+
"interface_settings": {
64+
"properties": {
65+
"authoneg": {
66+
"type": "boolean",
67+
},
68+
"flowcontrol": {
69+
"type": "boolean",
70+
}
71+
}
72+
}
6373
},
6474
"properties": {
6575
"netmode": {

0 commit comments

Comments
 (0)