diff options
Diffstat (limited to 'cloudinit/sources')
-rw-r--r-- | cloudinit/sources/__init__.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/cloudinit/sources/__init__.py b/cloudinit/sources/__init__.py index a3f4af1e..d49b67b2 100644 --- a/cloudinit/sources/__init__.py +++ b/cloudinit/sources/__init__.py @@ -81,8 +81,7 @@ class DataSource(object): # headers, if not just skip this.... launch_idxs = 0 for part in processed_ud.walk(): - # multipart/* are just containers - if part.get_content_maintype() == 'multipart': + if ud.is_skippable(part): continue launch_idx_h = part.get('Launch-Index', None) if launch_idx_h is not None: @@ -94,17 +93,23 @@ class DataSource(object): # that have some other garbage that we don't know what to do with accumulating_msg = MIMEMultipart() tot_attached = 0 + tot_processed = 0 for part in processed_ud.walk(): - # multipart/* are just containers - if part.get_content_maintype() == 'multipart': + if ud.is_skippable(part): continue try: + tot_processed += 1 launch_idx_h = part.get('Launch-Index', None) if launch_idx_h is None or int(launch_idx_h) == int(idx): accumulating_msg.attach(part) tot_attached += 1 - except: - # If any int conversion fails (or other error), keep the part + else: + LOG.debug(("Discarding multipart message %s, " + "launch-index provided destined for %s " + "and not %s"), + tot_processed, launch_idx_h, idx) + except (TypeError, ValueError): + # If any int conversion fails keep the message accumulating_msg.attach(part) tot_attached += 1 accumulating_msg[ud.ATTACHMENT_FIELD] = str(tot_attached) |