Skip to content

Refactor provider options - #503

Open
Cristi1324 wants to merge 1 commit into
cloudbase:mainfrom
Cristi1324:refactor-target-options
Open

Cristi1324 wants to merge 1 commit into
cloudbase:mainfrom
Cristi1324:refactor-target-options

Conversation

@Cristi1324

@Cristi1324 Cristi1324 commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Register common destination options and apply them during OS morphing.

Add data_transfer_mechanism, set_dhcp, and retain_user_credentials under
common_target_options. The worker merges those rows onto each provider
list, injects the fields into the destination schema, and removes core
names before the provider call. A request that names only core options
returns only those rows. OS morphing stores set_dhcp as nics_set_dhcp
and stores retain_user_credentials on the morphing parameters.

Summary

  • The worker adds data_transfer_mechanism, set_dhcp, and retain_user_credentials to every provider destination option list.
  • The worker adds those fields to the destination environment schema.
  • The worker removes those names before the provider call.
  • A request that names only those options returns only those rows.
  • OS morphing stores set_dhcp as nics_set_dhcp.
  • OS morphing stores retain_user_credentials on the morphing parameters.
  • A destination environment value overrides the stored provider value.
  • The stored provider value overrides [common_target_options].

Test plan

  • Test a deployment with no destination option filter. Confirm the wizard lists data_transfer_mechanism, set_dhcp, and retain_user_credentials.
  • Test a deployment with a destination options request that names only set_dhcp. Confirm the response contains only that row.
  • Test a deployment with set_dhcp set to false. Confirm the guest keeps its static addresses.
  • Test a deployment with retain_user_credentials set to true. Confirm the destination platform keeps the existing guest credentials.
  • Test a deployment with set_dhcp omitted. Confirm OS morphing uses the [common_target_options] value for nics_set_dhcp.

Depends on: https://github.com/cloudbase/coriolis-provider-cloudstack/pull/6

Comment thread coriolis/osmorphing/windows.py Outdated
Comment thread coriolis/schemas/os_morphing_resources_schema.json Outdated
Comment thread coriolis/osmorphing/destination_option_overrides.py Outdated
Comment thread coriolis/osmorphing/destination_option_overrides.py Outdated
Comment thread coriolis/osmorphing/destination_option_overrides.py Outdated
Comment thread coriolis/osmorphing/destination_options.py Outdated
@Cristi1324
Cristi1324 force-pushed the refactor-target-options branch 2 times, most recently from b03c3c2 to d799e6f Compare August 25, 2026 12:39
@Cristi1324
Cristi1324 force-pushed the refactor-target-options branch 2 times, most recently from 70b1df5 to d757307 Compare September 2, 2026 09:27
@Cristi1324 Cristi1324 changed the title WIP Refactor provider options Refactor provider options Sep 2, 2026
@Cristi1324
Cristi1324 marked this pull request as ready for review September 2, 2026 09:35
Comment thread coriolis/osmorphing/manager.py Outdated

nics_info = osmorphing_info.get('nics_info')
set_dhcp = osmorphing_info.get('nics_set_dhcp', True)
set_dhcp = osmorphing_parameters.get('set_dhcp', True)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be properly handled in: https://github.com/cloudbase/coriolis/pull/534/files.
This PR will need to be rebased eventually, and is therefore blocked in the meantime.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is blocked by: #534

@Cristi1324
Cristi1324 marked this pull request as draft October 9, 2026 10:53
@Cristi1324
Cristi1324 force-pushed the refactor-target-options branch 2 times, most recently from 6de4af7 to 328497f Compare October 13, 2026 11:56
@Cristi1324
Cristi1324 marked this pull request as ready for review October 13, 2026 11:59
@Cristi1324
Cristi1324 requested a review from Dany9966 October 15, 2026 09:47
Comment thread coriolis/osmorphing/conf.py Outdated
"title": "Set DHCP",
"description": (
"Sets whether or not to configure the VM to use DHCP "
"during the OSMorphing stage."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit:

Suggested change
"during the OSMorphing stage."
"during the OSMorphing stage. "
"When disabled, guest static IPs will be preserved after the migration."

Comment thread coriolis/osmorphing/conf.py Outdated
Comment on lines +59 to +60
"Keep the guest user accounts during OS morphing. "
"When false, OS morphing creates the cloud-init user."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Keep the guest user accounts during OS morphing. "
"When false, OS morphing creates the cloud-init user."
"Prevents the destination cloud provisioning from resetting the pre-existing credentials. "
"When disabled, the destination platform may also create a provisioned cloud guest user."

Comment thread coriolis/osmorphing/conf.py Outdated
opts = [
cfg.ListOpt(
"cloudbase_init_plugins",
default=None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't you use the config_defaults from CORE_DESTINATION_OPTIONS as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we set a default for cloudbase_init_plugins, it will be applied over the provider default because the provider default is not handled in apply_core_destination_overrides. Maybe we should pass enabled_plugins in osmorphing_parameters as cloudbase_init_plugins, but that means that this will no longer be a drop in replacement.
I can still set defaults from CORE_DESTINATION_OPTIONS for the other options.

Comment thread coriolis/osmorphing/conf.py Outdated
LOG = logging.getLogger(__name__)


def merge_core_destination_options(provider_options, option_names=None):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set type hints for all introduced method args and return types.

Comment thread coriolis/osmorphing/windows.py Outdated
"""
if plugins is None:
return None
if isinstance(plugins, str):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At what point does this plugins be a string? IMO it shouldn't reach this point and then make a list out of the string, especially since the schema expects it to be a list.
If that happens, it means a schema validation is either not being called or unfunctional.
All of this logic is supposed to be done by the schema validator.

"type": "boolean",
"default": false
"default": false,
"description": "Keep the guest user accounts during OS morphing. When false, OS morphing creates the cloud-init user."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please set the new descriptions here as well.

Comment thread etc/coriolis/coriolis.conf Outdated
# Used when dest-env and the destination provider both omit the key.
# cloudbase_init_plugins = cloudbaseinit.plugins.common.mtu.MTUPlugin,cloudbaseinit.plugins.windows.ntpclient.NTPClientPlugin
# Disk copy mechanism for destination worker VMs: HTTPS (TCP/5566) or SSH (TCP/22).
# data_transfer_mechanism = HTTPS

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since there's not only osmorphing options in here, maybe we should move these somewhere else, and not in osmorphing_conf?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd also like to see these in a separate section, not under DEFUALT. Something like common_target_option.

@Cristi1324
Cristi1324 force-pushed the refactor-target-options branch 2 times, most recently from 6cc5e62 to b89fa1b Compare October 16, 2026 10:51

@Dany9966 Dany9966 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, but I'm not overall happy with how complicated this got. I'm worried about how this code could possibly be maintained and understood. I think we'll need to think about this one some more before proceeding.

What I particularly don't like about it is that there's a lot of handling/hacks core-side to make the common options work and account for plugin defined or missing options. It would also be helpful (as in easier to review) if we'd refactor common options before adding new ones (cloudbase_init_plugins).

Comment thread coriolis/osmorphing/conf.py Outdated

from coriolis.osmorphing import windows

COMMON_TARGET_OPTION_GROUP = "common_target_option"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT:

Suggested change
COMMON_TARGET_OPTION_GROUP = "common_target_option"
COMMON_TARGET_OPTION_GROUP = "common_target_options"

"default": false,
"description": "Prevents the destination cloud provisioning from resetting the pre-existing credentials. When disabled, the destination platform may also create a provisioned cloud guest user."
},
"cloudbase_init_plugins": {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's please rename this option into custom_cloudbase_init_plugins, since it will list all the values and users can easily mess it up. By adding the Custom here, it will be more obvious that this is something to be messed with only in special cases.

"items": {
"type": "string"
},
"description": "Cloudbase-Init plugin class names for Windows guests. When set, this list is written into the guest. When omitted, the provider plugin list is used, then coriolis.conf, then the Windows morphing default."

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"description": "Cloudbase-Init plugin class names for Windows guests. When set, this list is written into the guest. When omitted, the provider plugin list is used, then coriolis.conf, then the Windows morphing default."
"description": "Custom Cloudbase-Init plugin class names for Windows guests. This overrides the destination provider's list of cloudbase-init plugins that get enabled after migrating Windows guests."

Comment thread coriolis/osmorphing/windows.py Outdated
if provider_plugins is not None:
return provider_plugins

from coriolis.osmorphing import conf as osmorphing_conf

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd much rather have the cloudbase init plugin defaults moved to conf than having the risk of circular imports. That will ensure that windows module import conf module safely, and conf module never (and should never) import windows or other modules.

Comment thread coriolis/osmorphing/windows.py Outdated
remote_script_path,
)

def _parse_cloudbase_init_plugins(self, plugins):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why no type hints for these private methods?

Comment thread coriolis/osmorphing/conf.py Outdated
``_resolve_destination_option``.
"""
if not isinstance(osmorphing_info, dict):
osmorphing_info = osmorphing_info or {}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this must be a dict, than assign a dict to it. It's even worse that down you set osmorphing_info = dict(osmorphing_info) which could've literally thrown a ValueError pretty easily.

Suggested change
osmorphing_info = osmorphing_info or {}
osmorphing_info = {}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to just raise InvalidInput when it's not a dict. I'll change all of the not isSomething to raise InvalidInput.

},
}

CORE_DESTINATION_OPTIONS = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still feel like this whole module shouldn't live under osmorphing since it will not hold only osmorphing env options.
Please refactor it elsewhere. Suggestion: conf.py module under providers

@Cristi1324
Cristi1324 force-pushed the refactor-target-options branch from b89fa1b to afd830d Compare October 22, 2026 11:51
Comment thread coriolis/providers/conf.py
@Cristi1324
Cristi1324 marked this pull request as draft October 22, 2026 12:04
Add data_transfer_mechanism, set_dhcp, and retain_user_credentials under
common_target_options. The worker merges those rows onto each provider
list, injects the fields into the destination schema, and removes core
names before the provider call. A request that names only core options
returns only those rows. OS morphing stores set_dhcp as nics_set_dhcp
and stores retain_user_credentials on the morphing parameters.
@Cristi1324
Cristi1324 force-pushed the refactor-target-options branch from afd830d to 873a876 Compare October 22, 2026 12:11
@Cristi1324
Cristi1324 marked this pull request as ready for review October 22, 2026 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants