Skip to content

Commit

Permalink
Merge pull request #141 from SUNET/bugfix.access_downlink
Browse files Browse the repository at this point in the history
Bugfix.access downlink
  • Loading branch information
indy-independence authored Oct 28, 2020
2 parents aedd53d + fc1d620 commit 1cd1be4
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/cnaas_nms/api/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ def get(self, hostname):
result['data']['hostname'] = dev.hostname
intfs = session.query(Interface).filter(Interface.device == dev).all()
intf: Interface
interfaces = []
for intf in intfs:
result['data']['interfaces'].append(intf.as_dict())
ifdict = intf.as_dict()
ifdict['indexnum'] = Interface.interface_index_num(ifdict['name'])
interfaces.append(ifdict)
result['data']['interfaces'] = sorted(interfaces, key=lambda i: i['indexnum'])
return result

@jwt_required
Expand Down
5 changes: 3 additions & 2 deletions src/cnaas_nms/confpush/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@ def get_uplinks(session, hostname: str) -> Dict[str, str]:
for neighbor_d in dev.get_neighbors(session):
if neighbor_d.device_type == DeviceType.DIST:
local_if = dev.get_neighbor_local_ifname(session, neighbor_d)
# TODO: check that dist interface is configured as downlink
# Neighbor interface ifclass is already verified in
# update_linknets -> verify_peer_iftype
if local_if:
uplinks[local_if] = neighbor_d.hostname
elif neighbor_d.device_type == DeviceType.ACCESS:
intfs: Interface = session.query(Interface).filter(Interface.device == neighbor_d). \
filter(InterfaceConfigType == InterfaceConfigType.ACCESS_DOWNLINK).all()
filter(Interface.configtype == InterfaceConfigType.ACCESS_DOWNLINK).all()
local_if = dev.get_neighbor_local_ifname(session, neighbor_d)
remote_if = neighbor_d.get_neighbor_local_ifname(session, dev)

Expand Down
7 changes: 6 additions & 1 deletion src/cnaas_nms/confpush/sync_devices.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,10 @@ def populate_device_vars(session, dev: Device,
untagged_vlan = None
tagged_vlan_list = []
intfdata = None
try:
ifindexnum: int = Interface.interface_index_num(intf.name)
except ValueError as e:
ifindexnum: int = 0
if intf.data:
if 'untagged_vlan' in intf.data:
untagged_vlan = resolve_vlanid(intf.data['untagged_vlan'],
Expand All @@ -180,7 +184,8 @@ def populate_device_vars(session, dev: Device,
'ifclass': intf.configtype.name,
'untagged_vlan': untagged_vlan,
'tagged_vlan_list': tagged_vlan_list,
'data': intfdata
'data': intfdata,
'indexnum': ifindexnum
})
mlag_vars = get_mlag_vars(session, dev)
device_variables = {**device_variables,
Expand Down

0 comments on commit 1cd1be4

Please sign in to comment.