From 13357cec50971c5934a731eeffed4920bd677723 Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Mon, 11 Sep 2017 23:56:08 +0000 Subject: [PATCH] =?UTF-8?q?FIx,=20on=20preprocess=20avant=20de=20faire=20l?= =?UTF-8?q?a=20recherche=20:=20switch=5Fid=20n'est=20pas=20forc=C3=A9ment?= =?UTF-8?q?=20un=20switch...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- freeradius_utils/auth.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/freeradius_utils/auth.py b/freeradius_utils/auth.py index 26da6cbe..690a703a 100644 --- a/freeradius_utils/auth.py +++ b/freeradius_utils/auth.py @@ -238,11 +238,15 @@ def detach(_=None): def decide_vlan_and_register_macauth(switch_id, port_number, mac_address): # Get port from switch and port number - ipv4 = IpList.objects.filter(ipv4=switch_id) - switch = Switch.objects.filter(switch_interface=Interface.objects.filter(Q(ipv4=ipv4) | Q(domain=Domain.objects.filter(name=switch_id)))) - if not switch or not ipv4: + if not isinstance(switch_id, int): + switch = Switch.objects.filter(switch_interface=Interface.objects.filter(domain=Domain.objects.filter(name=switch_id))) + else: + switch = Switch.objects.filter(switch_interface=Interface.objects.filter(ipv4=switch_id)) + if not switch: return ('?', 'Switch inconnu', VLAN_OK) + ipv4 = switch.first().switch_interface.ipv4 + sw_name = str(switch.first().switch_interface) port = Port.objects.filter(switch=switch.first(), port=port_number)