Commit 23e38173 authored by Julien Muchembled's avatar Julien Muchembled

master: simplify generation of new uuid

Even if random chars are all 0, at least the first one isn't
so we know we can't return INVALID_UUID.
parent 006010f0
......@@ -395,15 +395,10 @@ class Application(object):
self.cluster_state = state
def getNewUUID(self, node_type):
# build an UUID
uuid = os.urandom(15)
while uuid == protocol.INVALID_UUID[1:]:
uuid = os.urandom(15)
# look for the prefix
prefix = UUID_NAMESPACES.get(node_type, None)
if prefix is None:
try:
return UUID_NAMESPACES[node_type] + os.urandom(15)
except KeyError:
raise RuntimeError, 'No UUID namespace found for this node type'
return prefix + uuid
def isValidUUID(self, uuid, addr):
if uuid == self.uuid:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment