mirror of https://git.48k.eu/ogcp
views: normalize every MAC address during POST processing
Use aabbccddeeaa as MAC format in every payload. List of accepted MAC formats: aabbccddeeaa aa:bb:cc:dd:ee:aa aa-bb-cc-dd-ee-aa aa.bb.cc.dd.ee.aamaster
parent
84365a0db2
commit
9ea8a74c63
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue