Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions vrtManager/util.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import random
import secrets
import re
import string

Expand All @@ -25,15 +26,15 @@ def randomMAC():

def randomUUID():
"""Generate a random UUID."""
u = [random.randint(0, 255) for ignore in range(0, 16)]
u = [secrets.randbelow(256) for ignore in range(0, 16)]
u[6] = (u[6] & 0x0F) | (4 << 4)
u[8] = (u[8] & 0x3F) | (2 << 6)
return "-".join(["%02x" * 4, "%02x" * 2, "%02x" * 2, "%02x" * 2, "%02x" * 6]) % tuple(u)


def randomPasswd(length=12, alphabet=string.ascii_letters + string.digits):
"""Generate a random password"""
return "".join([random.choice(alphabet) for i in range(length)])
return "".join([secrets.choice(alphabet) for i in range(length)])


def get_max_vcpus(conn, type=None):
Expand Down