Repository navigation
Refactor provider options - #503
Cristi1324 wants to merge 1 commit into
Conversation
b03c3c2 to
d799e6f
Compare
70b1df5 to
d757307
Compare
|
|
||
| nics_info = osmorphing_info.get('nics_info') | ||
| set_dhcp = osmorphing_info.get('nics_set_dhcp', True) | ||
| set_dhcp = osmorphing_parameters.get('set_dhcp', True) |
There was a problem hiding this comment.
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.
6de4af7 to
328497f
Compare
| "title": "Set DHCP", | ||
| "description": ( | ||
| "Sets whether or not to configure the VM to use DHCP " | ||
| "during the OSMorphing stage." |
There was a problem hiding this comment.
Nit:
| "during the OSMorphing stage." | |
| "during the OSMorphing stage. " | |
| "When disabled, guest static IPs will be preserved after the migration." |
| "Keep the guest user accounts during OS morphing. " | ||
| "When false, OS morphing creates the cloud-init user." |
There was a problem hiding this comment.
| "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." |
| opts = [ | ||
| cfg.ListOpt( | ||
| "cloudbase_init_plugins", | ||
| default=None, |
There was a problem hiding this comment.
Why don't you use the config_defaults from CORE_DESTINATION_OPTIONS as well?
There was a problem hiding this comment.
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.
| LOG = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def merge_core_destination_options(provider_options, option_names=None): |
There was a problem hiding this comment.
Please set type hints for all introduced method args and return types.
| """ | ||
| if plugins is None: | ||
| return None | ||
| if isinstance(plugins, str): |
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
Please set the new descriptions here as well.
| # 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 |
There was a problem hiding this comment.
since there's not only osmorphing options in here, maybe we should move these somewhere else, and not in osmorphing_conf?
There was a problem hiding this comment.
I'd also like to see these in a separate section, not under DEFUALT. Something like common_target_option.
6cc5e62 to
b89fa1b
Compare
Dany9966
left a comment
There was a problem hiding this comment.
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).
|
|
||
| from coriolis.osmorphing import windows | ||
|
|
||
| COMMON_TARGET_OPTION_GROUP = "common_target_option" |
There was a problem hiding this comment.
NIT:
| 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": { |
There was a problem hiding this comment.
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." |
There was a problem hiding this comment.
| "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." |
| if provider_plugins is not None: | ||
| return provider_plugins | ||
|
|
||
| from coriolis.osmorphing import conf as osmorphing_conf |
There was a problem hiding this comment.
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.
| remote_script_path, | ||
| ) | ||
|
|
||
| def _parse_cloudbase_init_plugins(self, plugins): |
There was a problem hiding this comment.
Why no type hints for these private methods?
| ``_resolve_destination_option``. | ||
| """ | ||
| if not isinstance(osmorphing_info, dict): | ||
| osmorphing_info = osmorphing_info or {} |
There was a problem hiding this comment.
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.
| osmorphing_info = osmorphing_info or {} | |
| osmorphing_info = {} |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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
b89fa1b to
afd830d
Compare
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.
afd830d to
873a876
Compare
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
data_transfer_mechanism,set_dhcp, andretain_user_credentialsto every provider destination option list.set_dhcpasnics_set_dhcp.retain_user_credentialson the morphing parameters.[common_target_options].Test plan
data_transfer_mechanism,set_dhcp, andretain_user_credentials.set_dhcp. Confirm the response contains only that row.set_dhcpset to false. Confirm the guest keeps its static addresses.retain_user_credentialsset to true. Confirm the destination platform keeps the existing guest credentials.set_dhcpomitted. Confirm OS morphing uses the[common_target_options]value fornics_set_dhcp.Depends on: https://github.com/cloudbase/coriolis-provider-cloudstack/pull/6