mac-check

This commit is contained in:
dahn 2020-04-14 12:03:54 +02:00 committed by Daan Hoogland
parent 6a72e6e9f8
commit 22e0fc8752

View File

@ -22,6 +22,7 @@ import hashlib
import base64
import traceback
import logging
import re
from flask import Flask
@ -147,11 +148,18 @@ server = None
@app.route('/baremetal/provisiondone/<mac>', methods=['GET'])
def notify_provisioning_done(mac):
try:
if not is_a_mac(mac):
raise "there is an issue with that '%s'. Not a mac?" % mac
return server.notify_provisioning_done(mac)
except:
logger.warn(traceback.format_exc())
return ''
def is_a_mac(mac):
if re.match("[0-9a-f]{2}([-:]?)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", mac.lower()):
return True
else:
return False
if __name__ == '__main__':
server = Server()