Whamcloud - gitweb
b=1171
authorwangchao <wangchao>
Wed, 31 Dec 2003 07:42:11 +0000 (07:42 +0000)
committerwangchao <wangchao>
Wed, 31 Dec 2003 07:42:11 +0000 (07:42 +0000)
r=shaver

create true uuid in lmc

lustre/utils/lmc

index f8375b9..47076a3 100755 (executable)
@@ -25,7 +25,7 @@ lmc - lustre configuration data manager
 
 """
 
-import sys, os, getopt, string, exceptions
+import sys, os, getopt, string, exceptions, random
 import xml.dom.minidom
 from xml.dom.ext import PrettyPrint
 
@@ -216,7 +216,11 @@ def new_name(base):
     return ret
 
 def new_uuid(name):
-    return "%s_UUID" % (name)
+    ret_uuid = '%05x_%.19s_%05x%05x' % (int(random.random() * 1048576),
+                                        name,
+                                        int(random.random() * 1048576),
+                                        int(random.random() * 1048576))
+    return ret_uuid[:36]
 
 ldlm_name = 'ldlm'
 ldlm_uuid = 'ldlm_UUID'
@@ -1006,6 +1010,15 @@ def main():
 
     gen = GenConfig(doc)
 
+    # the PRNG is normally seeded with time(), which is not so good for starting    # time-synchronized clusters
+    input = open('/dev/urandom', 'r')
+    if not input:
+        print 'Unable to open /dev/urandom!'
+        sys.exit(1)
+    seed = input.read(32)
+    input.close()
+    random.seed(seed)
+
     if options.batch:
         fp = open(options.batch)
         batchCommands = fp.readlines()