Skip to content

Commit 6c1e93f

Browse files
committed
[airos] added radius property to aaa converter
moved radius configuration to separate module and get it from converter property
1 parent 104234f commit 6c1e93f

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

netjsonconfig/backends/airos/converters.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from ...utils import get_copy
55
from ..base.converter import BaseConverter
66
from .interface import bridge, wireless
7+
from .radius import radius_from_interface
78
from .schema import default_ntp_servers
89
from .wpasupplicant import available_mode_authentication
910

@@ -46,6 +47,10 @@ def wireless(self):
4647
"""
4748
return wireless(get_copy(self.netjson, 'interfaces', []))
4849

50+
@property
51+
def radius(self):
52+
original = get_copy(self.netjson, 'radius', {})
53+
return original
4954

5055
def to_intermediate(self):
5156
result = []
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
from .interface import mode, protocol
2+
3+
_radius = {
4+
'radius': {
5+
'acct': [
6+
{
7+
'port': 1813,
8+
'status': 'disabled',
9+
}
10+
],
11+
'auth': [
12+
{
13+
'port': 1812,
14+
},
15+
],
16+
},
17+
'status': 'disabled',
18+
}
19+
20+
_radius_from_mode = {
21+
'access_point': {
22+
'none': {},
23+
'wpa2_personal': {
24+
'radius': {
25+
'auth': [{
26+
'port': 1812,
27+
'status': 'disabled',
28+
}],
29+
'acct': [
30+
{
31+
'port': 1813,
32+
'status': 'disabled',
33+
}
34+
],
35+
'macacl': {
36+
'status': 'disabled',
37+
},
38+
},
39+
'status': 'enabled',
40+
},
41+
},
42+
'station': {
43+
'none': {},
44+
'wpa2_personal': {},
45+
}
46+
}
47+
48+
def radius_from_interface(interface):
49+
radius = _radius.copy()
50+
radius.update(
51+
_radius_from_mode[mode(interface)][protocol(interface)]
52+
)
53+
return radius
54+
55+
__all__ = [
56+
radius_from_interface,
57+
]

0 commit comments

Comments
 (0)