take out the code that computes a new key - for use by the dummynet boot medium creat...
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 20 Mar 2008 11:59:45 +0000 (11:59 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 20 Mar 2008 11:59:45 +0000 (11:59 +0000)
PLC/Methods/GetBootMedium.py

index 8f6c49b..c8d52a6 100644 (file)
@@ -22,6 +22,18 @@ boot_medium_actions = [ 'node-preview',
                         'generic-usb',
                         ]
 
+# compute a new key
+# xxx used by GetDummyBoxMedium
+def compute_key():
+    # Generate 32 random bytes
+    bytes = random.sample(xrange(0, 256), 32)
+    # Base64 encode their string representation
+    key = base64.b64encode("".join(map(chr, bytes)))
+    # Boot Manager cannot handle = in the key
+    # XXX this sounds wrong, as it might prevent proper decoding
+    key = key.replace("=", "")
+    return key
+
 class GetBootMedium(Method):
     """
     This method is a redesign based on former, supposedly dedicated, 
@@ -149,12 +161,7 @@ class GetBootMedium(Method):
         ( host, domain ) = self.split_hostname (node)
 
         if renew_key:
-            # Generate 32 random bytes
-            bytes = random.sample(xrange(0, 256), 32)
-            # Base64 encode their string representation
-            node['key'] = base64.b64encode("".join(map(chr, bytes)))
-            # XXX Boot Manager cannot handle = in the key
-            node['key'] = node['key'].replace("=", "")
+            node['key'] = compute_key()
             # Save it
             node.sync()