mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Tweaking the new unique id generate to be uuid compliant
This commit is contained in:
@@ -21,6 +21,9 @@ __metaclass__ = type
|
|||||||
|
|
||||||
import ast
|
import ast
|
||||||
import os
|
import os
|
||||||
|
import random
|
||||||
|
import sys
|
||||||
|
import uuid
|
||||||
|
|
||||||
from json import dumps
|
from json import dumps
|
||||||
from collections import MutableMapping
|
from collections import MutableMapping
|
||||||
@@ -33,10 +36,19 @@ from ansible.parsing.splitter import parse_kv
|
|||||||
from ansible.module_utils._text import to_native, to_text
|
from ansible.module_utils._text import to_native, to_text
|
||||||
|
|
||||||
cur_id = 0
|
cur_id = 0
|
||||||
|
node_mac = ("%012x" % uuid.getnode())[:12]
|
||||||
|
random_int = ("%08x" % random.randint(0, sys.maxint))[:8]
|
||||||
|
|
||||||
def get_unique_id():
|
def get_unique_id():
|
||||||
global cur_id
|
global cur_id
|
||||||
cur_id += 1
|
cur_id += 1
|
||||||
return "%s-%s" % (os.getpid(), cur_id)
|
return "-".join([
|
||||||
|
node_mac[0:8],
|
||||||
|
node_mac[8:12],
|
||||||
|
random_int[0:4],
|
||||||
|
random_int[4:8],
|
||||||
|
("%012x" % cur_id)[:12],
|
||||||
|
])
|
||||||
|
|
||||||
def _validate_mutable_mappings(a, b):
|
def _validate_mutable_mappings(a, b):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user