Commit ea7e50f5 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by root

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

parent 1a134e31
......@@ -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)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment