diff --git a/fuel_agent/tests/test_build_utils.py b/fuel_agent/tests/test_build_utils.py index d5ce0fdd..010fedbe 100644 --- a/fuel_agent/tests/test_build_utils.py +++ b/fuel_agent/tests/test_build_utils.py @@ -187,7 +187,7 @@ class BuildUtilsTestCase(unittest2.TestCase): mock_yaml_dump.assert_called_once_with({ 'cloud_init_modules': ['ssh'], 'cloud_config_modules': ['runcmd', 'write-files'] - }, mock.ANY, default_flow_style=False) + }, mock.ANY, encoding='utf-8', default_flow_style=False) @mock.patch('fuel_agent.utils.build.os.symlink') @mock.patch('fuel_agent.utils.build.os.mkdir') @@ -214,8 +214,10 @@ class BuildUtilsTestCase(unittest2.TestCase): allow_unsigned_file='fake_unsigned', force_ipv4_file='fake_force_ipv4', pipeline_depth_file='fake_pipeline_depth') + file_handle_mock = mock_open.return_value.__enter__.return_value file_handle_mock.write.assert_called_once_with('manual\n') + mock_exec_expected_calls = [ mock.call('sed', '-i', @@ -241,11 +243,18 @@ class BuildUtilsTestCase(unittest2.TestCase): mock.call('chroot', 'etc/init/mcollective.override'), mock.call('chroot', 'etc/systemd/system'), mock.call('chroot', 'etc/systemd/system/mcollective.service'), + mock.call('chroot', 'etc/cloud/cloud.cfg.d/'), + mock.call('chroot', + 'etc/cloud/cloud.cfg.d/99-disable-network-config.cfg'), mock.call('chroot', 'etc/cloud/cloud.cfg'), mock.call('/', bu.GRUB2_DMRAID_SETTINGS)] self.assertEqual(mock_path_join_expected_calls, mock_path.join.call_args_list) mock_symlink.assert_called_once_with('/dev/null', 'fake_path') + mock_yaml_dump.assert_called_with(mock.ANY, + mock.ANY, + encoding='utf-8', + default_flow_style=False) @mock.patch('fuel_agent.utils.build.open', create=True, new_callable=mock.mock_open) diff --git a/fuel_agent/utils/build.py b/fuel_agent/utils/build.py index 0d99f6d0..3ee05326 100644 --- a/fuel_agent/utils/build.py +++ b/fuel_agent/utils/build.py @@ -186,7 +186,8 @@ def fix_cloud_init_config(config_path): config['cloud_init_modules'].remove('write-files') config['cloud_config_modules'].append('write-files') with open(config_path, 'w') as cloud_conf: - yaml.safe_dump(config, cloud_conf, default_flow_style=False) + yaml.safe_dump(config, + cloud_conf, encoding='utf-8', default_flow_style=False) def do_post_inst(chroot, hashed_root_password, @@ -213,6 +214,14 @@ def do_post_inst(chroot, hashed_root_password, if os.path.exists(os.path.join(chroot, 'etc/systemd/system')): os.symlink('/dev/null', os.path.join(chroot, 'etc/systemd/system/mcollective.service')) + cloud_cfg = os.path.join(chroot, 'etc/cloud/cloud.cfg.d/') + utils.makedirs_if_not_exists(os.path.dirname(cloud_cfg)) + with open(os.path.join( + chroot, + 'etc/cloud/cloud.cfg.d/99-disable-network-config.cfg'), 'w') as cf: + yaml.safe_dump({'network': {'config': 'disabled'}}, cf, + encoding='utf-8', + default_flow_style=False) cloud_init_conf = os.path.join(chroot, 'etc/cloud/cloud.cfg') if os.path.exists(cloud_init_conf): fix_cloud_init_config(cloud_init_conf)