Skip to content

Commit 1585d8c

Browse files
committed
[airos] moved vlan interface selection to property
1 parent c8cf4c3 commit 1585d8c

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

netjsonconfig/backends/airos/converters.py

Lines changed: 6 additions & 5 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 autonegotiation, bridge, bssid, flowcontrol, hidden_ssid, protocol, radio, split_cidr, ssid, wireless
7+
from .interface import autonegotiation, bridge, bssid, flowcontrol, hidden_ssid, protocol, radio, split_cidr, ssid, stp, wireless
88
from .radius import radius_from_interface
99
from .schema import default_ntp_servers
1010
from .radio import radio_device_base, radio_configuration
@@ -604,13 +604,14 @@ def to_intermediate(self):
604604
class Vlan(AirOsConverter):
605605
netjson_key = 'interfaces'
606606

607+
@property
608+
def vlan(self):
609+
return vlan(get_copy(self.netjson, self.netjson_key, []))
610+
607611
def to_intermediate(self):
608612
result = []
609-
original = [
610-
i for i in get_copy(self.netjson, self.netjson_key, []) if '.' in i['name']
611-
]
612613
vlans = []
613-
for v in original:
614+
for v in self.vlan:
614615
vlans.append({
615616
'comment': v.get('comment', ''),
616617
'devname': v['name'].split('.')[0],

netjsonconfig/backends/airos/interface.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ def ssid(interface):
9696
return interface['wireless']['ssid']
9797

9898

99+
def vlan(interfaces):
100+
"""
101+
Return the vlan interfaces from the interfaces list
102+
"""
103+
return [i for i in interfaces if '.' in i['name']]
104+
105+
99106
def wireless(interfaces):
100107
"""
101108
Return the wireless interfaces from the interfaces list

0 commit comments

Comments
 (0)