Skip to content

Commit a557f9f

Browse files
committed
[airos] moved autonegotiation and flowcontrol method to interface module
1 parent 47c8b3d commit a557f9f

2 files changed

Lines changed: 31 additions & 23 deletions

File tree

netjsonconfig/backends/airos/converters.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from ...utils import get_copy
55
from ..base.converter import BaseConverter
66
from .aaa import bridge_devname, profile_from_interface, status_from_interface
7-
from .interface import bridge, bssid, hidden_ssid, protocol, radio, split_cidr, ssid, wireless
7+
from .interface import autonegotiation, bridge, bssid, flowcontrol, hidden_ssid, protocol, radio, split_cidr, ssid, wireless
88
from .radius import radius_from_interface
99
from .schema import default_ntp_servers
1010
from .radio import radio_device_base, radio_configuration
@@ -260,26 +260,6 @@ def type_to_role(self, typestr):
260260
}
261261
return roles.get(typestr, '')
262262

263-
def autoneg_status(self, interface):
264-
if interface.get('autoneg'):
265-
return 'enabled'
266-
else:
267-
return 'disabled'
268-
269-
def flowcontrol_status(self, interface):
270-
if interface.get('flowcontrol'):
271-
status = 'enabled'
272-
else:
273-
status = 'disabled'
274-
return {
275-
'rx': {
276-
'status': status,
277-
},
278-
'tx': {
279-
'status': status,
280-
},
281-
}
282-
283263
def to_intermediate(self):
284264
result = []
285265
interfaces = []
@@ -294,9 +274,9 @@ def to_intermediate(self):
294274
}
295275
# handle interface type quirks
296276
if interface['type'] == 'ethernet' and '.' not in interface['name']:
297-
base['autoneg'] = self.autoneg_status(interface)
277+
base['autoneg'] = autonegotiation(interface)
298278

299-
base['flowcontrol'] = self.flowcontrol_status(interface)
279+
base['flowcontrol'] = flowcontrol(interface)
300280

301281
if interface['type'] == 'wireless':
302282
base['devname'] = radio(interface)

netjsonconfig/backends/airos/interface.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
from ipaddress import ip_interface
22

33

4+
def autonegotiation(interface):
5+
"""
6+
Return the configuration for ``autoneg`` on interface
7+
"""
8+
if interface.get('autoneg'):
9+
return 'enabled'
10+
else:
11+
return 'disabled'
12+
13+
414
def bridge(interfaces):
515
"""
616
Return the bridge interfaces from the interfaces list
@@ -15,6 +25,24 @@ def bssid(interface):
1525
return interface['wireless'].get('bssid', '')
1626

1727

28+
def flowcontrol(interface):
29+
"""
30+
Return the configuration for ``flowcontrol`` on interface
31+
"""
32+
if interface.get('flowcontrol'):
33+
status = 'enabled'
34+
else:
35+
status = 'disabled'
36+
return {
37+
'rx': {
38+
'status': status,
39+
},
40+
'tx': {
41+
'status': status,
42+
},
43+
}
44+
45+
1846
def hidden_ssid(interface):
1947
"""
2048
Return wether the ssid is hidden

0 commit comments

Comments
 (0)