diff options
author | Scott Moser <smoser@nelson> | 2010-01-11 14:13:28 -0500 |
---|---|---|
committer | Scott Moser <smoser@nelson> | 2010-01-11 14:13:28 -0500 |
commit | 7bde8d909ec9b2cabd3ab6366ea33d8f52e8e2fc (patch) | |
tree | 83a45c1acba361c2801ec4226eff02f3998bb76d /ec2init/UserDataHandler.py | |
parent | cc01225957ef50fd9858424122e50938100bc23b (diff) | |
download | vyos-cloud-init-7bde8d909ec9b2cabd3ab6366ea33d8f52e8e2fc.tar.gz vyos-cloud-init-7bde8d909ec9b2cabd3ab6366ea33d8f52e8e2fc.zip |
correctly mark content type of simple files
For user data that is not a mime message, we were not applying the
starts with rules. In fact, they were not getting applied at all.
Other fix here is to have the 'main' function decompress input
Diffstat (limited to 'ec2init/UserDataHandler.py')
-rw-r--r-- | ec2init/UserDataHandler.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ec2init/UserDataHandler.py b/ec2init/UserDataHandler.py index 71bc3203..0ab1bbec 100644 --- a/ec2init/UserDataHandler.py +++ b/ec2init/UserDataHandler.py @@ -40,15 +40,17 @@ def process_includes(msg,parts): # multipart/* are just containers if part.get_content_maintype() == 'multipart': continue - ctype = part.get_content_type() payload = part.get_payload() + ctype = None + for str, gtype in starts_with_mappings.items(): + if payload.startswith(str): + ctype = gtype + break + if ctype is None: - ctype = 'application/octet-stream' - for str, gtype in starts_with_mappings.items(): - if payload.startswith(str): - ctype = gtype + ctype = part.get_content_type() if ctype == 'text/x-include-url': do_include(payload,parts) @@ -118,7 +120,7 @@ def walk_userdata(str, callbacks, data = None): if __name__ == "__main__": import sys - data = file(sys.argv[1]).read() + data = decomp_str(file(sys.argv[1]).read()) parts = { } process_includes(email.message_from_string(data),parts) print "#found %s parts" % len(parts['content']) |