Skip to content
Open
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
6 changes: 5 additions & 1 deletion coriolis/osmorphing/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ def __init__(
detected_os_info,
osmorphing_parameters,
operation_timeout,
nics_set_dhcp=True,
):

self.check_detected_os_info_parameters(detected_os_info)
Expand All @@ -155,6 +156,7 @@ def __init__(
self._detected_os_info = detected_os_info
self._environment = {}
self._osmorphing_parameters = osmorphing_parameters
self._nics_set_dhcp = nics_set_dhcp
self._osmorphing_operation_timeout = operation_timeout

@classmethod
Expand Down Expand Up @@ -293,6 +295,7 @@ def __init__(
detected_os_info,
osmorphing_parameters,
operation_timeout=None,
nics_set_dhcp=True,
):
super(BaseLinuxOSMorphingTools, self).__init__(
conn,
Expand All @@ -303,6 +306,7 @@ def __init__(
detected_os_info,
osmorphing_parameters,
operation_timeout,
nics_set_dhcp,
)
self._ssh = conn
self._grub2_update_scheduled = False
Expand Down Expand Up @@ -813,7 +817,7 @@ def _configure_cloud_init(self):
else:
self._create_cloudinit_user()

if not self._osmorphing_parameters.get('set_dhcp', True):
if not self._nics_set_dhcp:
disabled_network_config = {"network": {"config": "disabled"}}
cloud_cfg_mods.update(disabled_network_config)
modules = self._get_cloud_init_modules()
Expand Down
2 changes: 2 additions & 0 deletions coriolis/osmorphing/debian.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(
detected_os_info,
osmorphing_parameters,
operation_timeout=None,
nics_set_dhcp=True,
):
super(BaseDebianMorphingTools, self).__init__(
conn,
Expand All @@ -50,6 +51,7 @@ def __init__(
detected_os_info,
osmorphing_parameters,
operation_timeout,
nics_set_dhcp,
)

# NOTE: every dpkg invocation may run maintainer scripts which prompt
Expand Down
6 changes: 4 additions & 2 deletions coriolis/osmorphing/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ def _morph_image(
# - automatically detect the target hypervisor type from the worker VM
hypervisor_type = osmorphing_info.get('hypervisor_type', None)
osmorphing_parameters = osmorphing_info.get('osmorphing_parameters', {})
nics_set_dhcp = osmorphing_info.get('nics_set_dhcp', True)

export_os_morphing_tools = None
try:
Expand All @@ -280,6 +281,7 @@ def _morph_image(
detected_os_info,
osmorphing_parameters,
CONF.default_osmorphing_operation_timeout,
nics_set_dhcp,
)
export_os_morphing_tools.set_environment(environment)
else:
Expand Down Expand Up @@ -313,6 +315,7 @@ def _morph_image(
detected_os_info,
osmorphing_parameters,
CONF.default_osmorphing_operation_timeout,
nics_set_dhcp,
)
import_os_morphing_tools.set_environment(environment)

Expand Down Expand Up @@ -362,8 +365,7 @@ def _morph_image(
import_os_morphing_tools.pre_packages_install(packages_add)

nics_info = osmorphing_info.get('nics_info')
set_dhcp = osmorphing_info.get('nics_set_dhcp', True)
import_os_morphing_tools.set_net_config(nics_info, dhcp=set_dhcp)
import_os_morphing_tools.set_net_config(nics_info, dhcp=nics_set_dhcp)
LOG.info("Pre packages")

if packages_add:
Expand Down
2 changes: 2 additions & 0 deletions coriolis/osmorphing/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def __init__(
detected_os_info,
osmorphing_parameters,
operation_timeout=None,
nics_set_dhcp=True,
):
super(BaseRedHatMorphingTools, self).__init__(
conn,
Expand All @@ -53,6 +54,7 @@ def __init__(
detected_os_info,
osmorphing_parameters,
operation_timeout,
nics_set_dhcp,
)

def disable_predictable_nic_names(self):
Expand Down
2 changes: 2 additions & 0 deletions coriolis/osmorphing/windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ def __init__(
detected_os_info,
osmorphing_parameters,
operation_timeout=None,
nics_set_dhcp=True,
):
super(BaseWindowsMorphingTools, self).__init__(
conn,
Expand All @@ -228,6 +229,7 @@ def __init__(
detected_os_info,
osmorphing_parameters,
operation_timeout,
nics_set_dhcp,
)

self._version_number = detected_os_info['version_number']
Expand Down
16 changes: 11 additions & 5 deletions coriolis/tests/osmorphing/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1129,11 +1129,12 @@ def test__create_cloudinit_user_already_exists(
mock__exec_cmd_chroot.assert_not_called()

@ddt.data(
(None, ["vim"], {}, False, [], None, False),
(None, ["vim"], {}, True, False, [], None, False),
(
["Oracle"],
["cloud-init"],
{"retain_user_credentials": True, "set_dhcp": False},
{"retain_user_credentials": True},
False,
False,
["set_hostname"],
{
Expand All @@ -1148,7 +1149,8 @@ def test__create_cloudinit_user_already_exists(
(
[],
["cloud-init", "vim"],
{"retain_user_credentials": False, "set_dhcp": True},
{"retain_user_credentials": False},
True,
True,
[],
{},
Expand All @@ -1157,7 +1159,8 @@ def test__create_cloudinit_user_already_exists(
(
[],
["cloud-init", "vim"],
{"retain_user_credentials": False, "set_dhcp": False},
{"retain_user_credentials": False},
False,
True,
["update_etc_hosts", "set_hostname", "write_files"],
{
Expand All @@ -1169,7 +1172,8 @@ def test__create_cloudinit_user_already_exists(
(
["ConfigDrive", "OpenStack"],
["cloud-init", "vim"],
{"retain_user_credentials": False, "set_dhcp": True},
{"retain_user_credentials": False},
True,
True,
[],
{"datasource_list": ["ConfigDrive", "OpenStack"]},
Expand All @@ -1194,6 +1198,7 @@ def test__configure_cloud_init(
datasource_list,
returned_packages,
osmorphing_params,
nics_set_dhcp,
creates_cloudinit_user,
cloud_init_modules,
expected_result,
Expand All @@ -1213,6 +1218,7 @@ def test__configure_cloud_init(
mock_datasource_list.return_value = datasource_list
mock_get_packages.return_value = returned_packages
self.os_morphing_tools._osmorphing_parameters = osmorphing_params
self.os_morphing_tools._nics_set_dhcp = nics_set_dhcp
mock__has_systemd_chroot.return_value = has_systemd_chroot
mock__get_cloud_init_modules.return_value = cloud_init_modules

Expand Down
Loading