Tweaking the new unique id generate to be uuid compliant
This commit is contained in:
parent
23886c5c0d
commit
350a32bd95
1 changed files with 14 additions and 2 deletions
|
@ -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
|
||||||
|
@ -32,11 +35,20 @@ from ansible.errors import AnsibleError
|
||||||
from ansible.parsing.splitter import parse_kv
|
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):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue