From c1a006bb9ee915c08075e9adeab245f02452ee43 Mon Sep 17 00:00:00 2001 From: Martin Packman Date: Mon, 12 Mar 2012 13:56:40 +0000 Subject: Restrict warning to userdata without MIME wrapping only while still ignoring most types --- cloudinit/UserDataHandler.py | 4 ++-- cloudinit/__init__.py | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/UserDataHandler.py b/cloudinit/UserDataHandler.py index 98729056..ec914480 100644 --- a/cloudinit/UserDataHandler.py +++ b/cloudinit/UserDataHandler.py @@ -180,7 +180,7 @@ def process_includes(msg, appendmsg=None): payload = part.get_payload(decode=True) - if ctype_orig == "text/plain": + if ctype_orig in ("text/plain", "text/x-not-multipart"): ctype = type_from_startswith(payload) if ctype is None: @@ -213,7 +213,7 @@ def message_from_string(data, headers=None): else: msg[key] = val else: - mtype = headers.get("Content-Type", "text/plain") + mtype = headers.get("Content-Type", "text/x-not-multipart") maintype, subtype = mtype.split("/", 1) msg = MIMEBase(maintype, subtype, *headers) msg.set_payload(data) diff --git a/cloudinit/__init__.py b/cloudinit/__init__.py index 98a48fec..1c3f861c 100644 --- a/cloudinit/__init__.py +++ b/cloudinit/__init__.py @@ -606,12 +606,14 @@ def partwalker_callback(pdata, ctype, filename, payload): partwalker_handle_handler(pdata, ctype, filename, payload) return if ctype not in pdata['handlers']: - start = payload.split("\n", 1)[0][:24] # Use first line or 24 bytes - if start < payload: - details = "starting '%s...'" % start.encode("string-escape") - else: - details = repr(payload) - log.warning("Unhandled userdata part of type %s %s", ctype, details) + if ctype == "text/x-not-multipart": + # Extract the first line or 24 bytes for displaying in the log + start = payload.split("\n", 1)[0][:24] + if start < payload: + details = "starting '%s...'" % start.encode("string-escape") + else: + details = repr(payload) + log.warning("Unhandled non-multipart userdata %s", details) return handler_handle_part(pdata['handlers'][ctype], pdata['data'], ctype, filename, payload, pdata['frequency']) -- cgit v1.2.3