8
0
Fork 0
mirror of https://gitlab2.federez.net/re2o/re2o synced 2024-12-26 00:43:46 +00:00

FIx, on preprocess avant de faire la recherche : switch_id n'est pas forcément un switch...

This commit is contained in:
Gabriel Detraz 2017-09-11 23:56:08 +00:00 committed by root
parent 6ad7605bfe
commit 13357cec50

View file

@ -238,11 +238,15 @@ def detach(_=None):
def decide_vlan_and_register_macauth(switch_id, port_number, mac_address): def decide_vlan_and_register_macauth(switch_id, port_number, mac_address):
# Get port from switch and port number # Get port from switch and port number
ipv4 = IpList.objects.filter(ipv4=switch_id) if not isinstance(switch_id, int):
switch = Switch.objects.filter(switch_interface=Interface.objects.filter(Q(ipv4=ipv4) | Q(domain=Domain.objects.filter(name=switch_id)))) switch = Switch.objects.filter(switch_interface=Interface.objects.filter(domain=Domain.objects.filter(name=switch_id)))
if not switch or not ipv4: else:
switch = Switch.objects.filter(switch_interface=Interface.objects.filter(ipv4=switch_id))
if not switch:
return ('?', 'Switch inconnu', VLAN_OK) return ('?', 'Switch inconnu', VLAN_OK)
ipv4 = switch.first().switch_interface.ipv4
sw_name = str(switch.first().switch_interface) sw_name = str(switch.first().switch_interface)
port = Port.objects.filter(switch=switch.first(), port=port_number) port = Port.objects.filter(switch=switch.first(), port=port_number)