MAAS 2.8/edge - modifying UUID reported by enlisting node

Thanks for your response!

These servers are not under a service contract (I bought them for training). Dell firmware generates a UUID based on the Service Tag, and the Service Tags are all the same, so the UUIDs are all the same. I tried to modify the Service Tag, but to no avail - it can’t be modified.

The motherboard serial was unique, so I added it to the reported UUID to generate a unique UUID for use.

I went with: (excuse the verbose logging)

@@ -32,7 +34,7 @@ from provisioningserver.refresh.node_info_scripts import (
 from provisioningserver.utils import kernel_to_debian_architecture
 from provisioningserver.utils.ipaddr import parse_ip_addr
 from provisioningserver.utils.lxd import parse_lxd_cpuinfo
-
+from uuid import UUID
 logger = logging.getLogger(__name__)
 
 
@@ -412,10 +414,35 @@ def _process_system_information(node, system_data):
             )
         else:
             NodeMetadata.objects.filter(node=node, key=key).delete()
+        print("[UUID] Adding Property {} = {}".format(key, value))
 
-    uuid = system_data.get("uuid")
+    read_uuid = system_data.get("uuid")
     # Convert "" to None, so that the unique check isn't triggered.
-    node.hardware_uuid = None if uuid == "" else uuid
+   
+    print("[UUID] Read UUID: {}".format(read_uuid))
+    serialNumber = system_data.get('motherboard').get('serial')
+    print("[UUID] Read Motherboard Serial: {}".format(serialNumber))
+    serialHash = hash(serialNumber)
+    print("[UUID] Hashed Serial: {}".format(serialHash))
+
+    if read_uuid is None or len(read_uuid) < 10:
+        print("[UUID] Read UUID was invalid")
+        print("[UUID] Generating from serial only")
+        uuid = UUID(int=int(int(serialHash)))
+    else:
+        print("[UUID] Generating composite UUID from hardware and serial")
+        uuid_num = UUID(read_uuid).int
+        print("[UUID] hardware uuid integer: {}".format(uuid_num))
+        uuid_comp_num = UUID(int = int(uuid_num + int(serialHash)))
+        print("[UUID] Composite UUID {}".format(uuid_comp_num))
+        #UUID is now derived from HardwareUUID + chassis serial
+        #Covert to string
+        uuid = uuid_comp_num
+    #In any case, stored uuid is uuid
+    print("[UUID] Final UUID: {}".format(uuid))
+    node.hardware_uuid = uuid
+    print("============== UUID END =============================")
+

I’m glad that’s over - it took 24h to figure out the code and flow without a debugger!

2 Likes