Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion cloudinit/user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
NOT_MULTIPART_TYPE = handlers.NOT_MULTIPART_TYPE
PART_FN_TPL = handlers.PART_FN_TPL
OCTET_TYPE = handlers.OCTET_TYPE
INCLUDE_MAP = handlers.INCLUSION_TYPES_MAP

# Saves typing errors
CONTENT_TYPE = 'Content-Type'
Expand Down Expand Up @@ -115,7 +116,8 @@ def find_ctype(payload):
# Attempt to figure out the payloads content-type
if not ctype_orig:
ctype_orig = UNDEF_TYPE
if ctype_orig in TYPE_NEEDED:
if ctype_orig in TYPE_NEEDED or (ctype_orig in
INCLUDE_MAP.values()):
ctype = find_ctype(payload)
if ctype is None:
ctype = ctype_orig
Expand Down
34 changes: 34 additions & 0 deletions tests/unittests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,40 @@ def test_mixed_cloud_config(self):
self.assertEqual(1, len(cc))
self.assertEqual('c', cc['a'])

def test_cloud_config_as_x_shell_script(self):
blob_cc = '''
#cloud-config
a: b
c: d
'''
message_cc = MIMEBase("text", "x-shellscript")
message_cc.set_payload(blob_cc)

blob_jp = '''
#cloud-config-jsonp
[
{ "op": "replace", "path": "/a", "value": "c" },
{ "op": "remove", "path": "/c" }
]
'''

message_jp = MIMEBase('text', "cloud-config-jsonp")
message_jp.set_payload(blob_jp)

message = MIMEMultipart()
message.attach(message_cc)
message.attach(message_jp)

self.reRoot()
ci = stages.Init()
ci.datasource = FakeDataSource(str(message))
ci.fetch()
ci.consume_data()
cc_contents = util.load_file(ci.paths.get_ipath("cloud_config"))
cc = util.load_yaml(cc_contents)
self.assertEqual(1, len(cc))
self.assertEqual('c', cc['a'])

def test_vendor_user_yaml_cloud_config(self):
vendor_blob = '''
#cloud-config
Expand Down