From 22e0fc8752513f31ff9eb5cde5bdbfad7616e994 Mon Sep 17 00:00:00 2001 From: dahn Date: Tue, 14 Apr 2020 12:03:54 +0200 Subject: [PATCH] mac-check --- systemvm/debian/opt/cloud/bin/baremetal-vr.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/systemvm/debian/opt/cloud/bin/baremetal-vr.py b/systemvm/debian/opt/cloud/bin/baremetal-vr.py index b8dacc78325..1547d82c660 100755 --- a/systemvm/debian/opt/cloud/bin/baremetal-vr.py +++ b/systemvm/debian/opt/cloud/bin/baremetal-vr.py @@ -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/', 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()