diff options
Diffstat (limited to 'ogcp')
-rw-r--r-- | ogcp/views.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/ogcp/views.py b/ogcp/views.py index ac5df38..ab75280 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -96,6 +96,9 @@ class ServerError(Exception): class ServerErrorCode(Exception): pass +def normalize_mac(mac): + return mac.replace(':', '').replace('-', '').replace('.', '').lower() + def ogserver_down(view): flash(_('Cannot talk to ogserver. Is ogserver down?'), category='error') return redirect(url_for(view)) @@ -1307,7 +1310,7 @@ def action_client_update(): "room": int(form.room.data), "name": form.name.data, "boot": form.boot.data, - "mac": form.mac.data } + "mac": normalize_mac(form.mac.data) } server = get_server_from_ip_port(form.server.data) r = server.post('/client/update', payload) if r.status_code != requests.codes.ok: @@ -1550,7 +1553,7 @@ def action_client_add(): payload = {"boot": form.boot.data, "ip": form.ip.data, "livedir": form.livedir.data, - "mac": form.mac.data, + "mac": normalize_mac(form.mac.data), "maintenance": form.maintenance.data, "name": form.name.data, "netdriver": "generic", @@ -1762,7 +1765,7 @@ def action_clients_import_post(): 'room': int(form.room.data)} for client in clients: payload['name'] = client[0] - payload['mac'] = client[1].replace(':', '') + payload['mac'] = normalize_mac(client[1]) payload['ip'] = client[2] resp = server.post('/client/add', payload) if resp.status_code != requests.codes.ok: |