Merge "Do not set the mime-type for userdata"

This commit is contained in:
Jenkins 2016-12-15 03:10:04 +00:00 committed by Gerrit Code Review
commit 8fc3489108
3 changed files with 21 additions and 6 deletions

View File

@ -325,7 +325,9 @@ class NovaClientPlugin(client_plugin.ClientPlugin):
subtype = os.path.splitext(filename)[0]
if content is None:
content = ''
msg = text.MIMEText(content, _subtype=subtype)
msg = (text.MIMEText(content, _subtype=subtype)
if subtype else text.MIMEText(content))
msg.add_header('Content-Disposition', 'attachment',
filename=filename)
return msg
@ -359,7 +361,6 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
(cloudinit_boothook, 'boothook.sh', 'cloud-boothook'),
(read_cloudinit_file('part_handler.py'),
'part-handler.py')]
if is_cfntools:
attachments.append((userdata, 'cfn-userdata', 'x-cfninitdata'))
elif is_software_config:
@ -376,7 +377,7 @@ echo -e '%s\tALL=(ALL)\tNOPASSWD: ALL' >> /etc/sudoers
part.get_filename(),
part.get_content_subtype()))
else:
attachments.append((userdata, 'userdata', 'x-shellscript'))
attachments.append((userdata, ''))
if is_cfntools:
attachments.append((read_cloudinit_file('loguserdata.py'),

View File

@ -23,6 +23,9 @@ parameters:
dns_servers:
type: comma_delimited_list
default: ["8.8.8.8", "8.8.4.4"]
user_data_format:
type: string
default: RAW
resources:
sg:
type: OS::Neutron::SecurityGroup
@ -76,7 +79,7 @@ resources:
- subnet: {get_resource: subnet}
security_groups:
- {get_resource: sg}
user_data_format: RAW
user_data_format: {get_param: user_data_format}
user_data:
str_replace:
template: |

View File

@ -20,13 +20,15 @@ from heat_integrationtests.scenario import scenario_base
class ServerSignalIntegrationTest(scenario_base.ScenarioTestsBase):
"""Test a server in a created network can signal to heat."""
def test_server_signal(self):
def _test_server_signal(self, user_data_format='RAW',
image=None):
"""Check a server in a created network can signal to heat."""
parameters = {
'key_name': self.keypair_name,
'flavor': self.conf.minimal_instance_type,
'image': self.conf.minimal_image_ref,
'image': image,
'timeout': self.conf.build_timeout,
'user_data_format': user_data_format
}
# Launch stack
@ -72,3 +74,12 @@ class ServerSignalIntegrationTest(scenario_base.ScenarioTestsBase):
self._log_console_output(servers=[server])
self.fail(
"Timed out waiting for %s to become reachable" % server_ip)
def test_server_signal_userdata_format_raw(self):
self._test_server_signal(image=self.conf.minimal_image_ref)
def test_server_signal_userdata_format_software_config(self):
if not self.conf.image_ref:
raise self.skipException("No image configured to test")
self._test_server_signal(user_data_format='SOFTWARE_CONFIG',
image=self.conf.image_ref)