Standardize uuid generation for events/storage/registry (#39184)
This commit is contained in:
parent
28332f23b3
commit
bee6d87e7a
6 changed files with 34 additions and 15 deletions
15
homeassistant/util/uuid.py
Normal file
15
homeassistant/util/uuid.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
"""Helpers to generate uuids."""
|
||||
|
||||
import random
|
||||
import uuid
|
||||
|
||||
|
||||
def uuid_v1mc_hex() -> str:
|
||||
"""Generate a uuid1 with a random multicast MAC address.
|
||||
|
||||
The uuid1 uses a random multicast MAC address instead of the real MAC address
|
||||
of the machine without the overhead of calling the getrandom() system call.
|
||||
|
||||
This is effectively equivalent to PostgreSQL's uuid_generate_v1mc() function
|
||||
"""
|
||||
return uuid.uuid1(node=random.getrandbits(48) | (1 << 40)).hex
|
Loading…
Add table
Add a link
Reference in a new issue