From: Thierry Parmentelat Date: Thu, 20 Mar 2008 11:59:45 +0000 (+0000) Subject: take out the code that computes a new key - for use by the dummynet boot medium creat... X-Git-Tag: PLCAPI-4.2-4~2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=ae73709e3da43f26fbfea8d5238e10bb7dcb41ea;p=plcapi.git take out the code that computes a new key - for use by the dummynet boot medium creation method --- diff --git a/PLC/Methods/GetBootMedium.py b/PLC/Methods/GetBootMedium.py index 8f6c49b..c8d52a6 100644 --- a/PLC/Methods/GetBootMedium.py +++ b/PLC/Methods/GetBootMedium.py @@ -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()