summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Moser <smoser@ubuntu.com>2011-07-26 14:04:02 -0400
committerScott Moser <smoser@ubuntu.com>2011-07-26 14:04:02 -0400
commitd5874c0bfcefc74ad9045efe4ed8450039b11b9a (patch)
tree694c58119d8f123d6ccd1f74c40a58279b811ce9
parentcf65c6c8e0da58698139223888f23adf7093d12f (diff)
downloadvyos-cloud-init-d5874c0bfcefc74ad9045efe4ed8450039b11b9a.tar.gz
vyos-cloud-init-d5874c0bfcefc74ad9045efe4ed8450039b11b9a.zip
use md5sum as the unique identifier rather than base64
base64 encode will grow with the size of the url, possibly resulting in silly-long filenames. md5sum will keep it to a constant length.
-rw-r--r--cloudinit/UserDataHandler.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/cloudinit/UserDataHandler.py b/cloudinit/UserDataHandler.py
index fa8ce716..9670c0cb 100644
--- a/cloudinit/UserDataHandler.py
+++ b/cloudinit/UserDataHandler.py
@@ -24,6 +24,7 @@ from email import encoders
import yaml
import cloudinit
import cloudinit.util as util
+import md5
starts_with_mappings={
'#include' : 'text/x-include-url',
@@ -49,7 +50,6 @@ def decomp_str(str):
def do_include(str,parts):
import urllib
import os
- import base64
# is just a list of urls, one per line
# also support '#include <url here>'
includeonce = False
@@ -66,8 +66,10 @@ def do_include(str,parts):
if line.startswith("#"): continue
# urls cannot not have leading or trailing white space
- uniquestring = base64.encodestring(line).strip()
- includeonce_filename = "%s/urlcache/%s" % (cloudinit.get_ipath_cur("data"), uniquestring)
+ msum = md5.new()
+ msum.update(line.strip())
+ includeonce_filename = "%s/urlcache/%s" % (
+ cloudinit.get_ipath_cur("data"), msum.hexdigest())
try:
if includeonce and os.path.isfile(includeonce_filename):
with open(includeonce_filename, "r") as fp: