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

Fix problème de variables globales réassignées en fonctions

This commit is contained in:
Gabriel Detraz 2017-10-04 04:31:28 +02:00 committed by root
parent 753ae0eb32
commit 1a4b1a4b98

View file

@ -263,6 +263,7 @@ def check_user_machine_and_register(nas_type, username, mac_address):
def decide_vlan_and_register_switch(nas, nas_type, port_number, mac_address):
# Get port from switch and port number
extra_log = ""
if not nas:
return ('?', u'Nas inconnu', VLAN_OK)
@ -275,10 +276,13 @@ def decide_vlan_and_register_switch(nas, nas_type, port_number, mac_address):
port = port.first()
# Si un vlan a été précisé, on l'utilise pour VLAN_OK
if port.vlan_force:
VLAN_OK = int(port.vlan_force.vlan_id)
DECISION_VLAN = int(port.vlan_force.vlan_id)
extra_log = u"Force sur vlan " + str(DECISION_VLAN)
else:
DECISION_VLAN = VLAN_OK
if port.radius == 'NO':
return (sw_name, u"Pas d'authentification sur ce port", VLAN_OK)
return (sw_name, u"Pas d'authentification sur ce port" + extra_log, DECISION_VLAN)
if port.radius == 'BLOQ':
return (sw_name, u'Port desactive', VLAN_NOK)
@ -312,12 +316,12 @@ def decide_vlan_and_register_switch(nas, nas_type, port_number, mac_address):
else:
result, reason = room_user.first().autoregister_machine(mac_address, nas_type)
if result:
return (sw_name, u'Access Ok, Capture de la mac...', VLAN_OK)
return (sw_name, u'Access Ok, Capture de la mac...' + extra_log, DECISION_VLAN)
else:
return (sw_name, u'Erreur dans le register mac %s' % reason + unicode(mac_address), VLAN_NOK)
elif not interface.first().is_active:
return (sw_name, u'Machine non active / adherent non cotisant', VLAN_NOK)
else:
return (sw_name, u'Machine OK', VLAN_OK)
return (sw_name, u'Machine OK' + extra_log, DECISION_VLAN)