feat(opennebula): support ETHx_ROUTES static routes in network config#6810
feat(opennebula): support ETHx_ROUTES static routes in network config#6810mcanevet wants to merge 1 commit intocanonical:mainfrom
Conversation
8c4e264 to
e5efa6e
Compare
|
Hey @mcanevet. What is your goal and intent with these PRs? It doesn't look like you are trying to a single missing feature. Are you employed by Open Nebula? |
|
I'm just trying to add support for context variables that are honored by Open Nebula's official agent. And I'm not working for them, just a simple user that would like to use cloud-init with complex network configuration. Do you prefer a single PR for all of this? |
e5efa6e to
eff0ece
Compare
Add `get_routes()` to `OpenNebulaNetwork` to parse the `ETHx_ROUTES` context variable (format: "NETWORK via GATEWAY, ...") and emit the resulting routes into the Netplan v2 `routes:` list in `gen_conf()`. Malformed entries are skipped with a warning. No `routes` key is emitted when the variable is absent or empty, preserving backward compatibility.
eff0ece to
3d4c3f9
Compare
|
@holmanb do you prefer a single PR to implement this feature that reduces the gap between the OpenNebula agent (https://github.com/OpenNebula/one-apps/tree/master/context-linux) and Cloud-init? We basically need this to use cloud-init with standard OpenNebula context variables that the official agent support. |
|
I have a few concerns:
Additionally, I would like to see the the full cloud-init logs on the system that you tested these changes on as well as from an instance without these changes applied - as well as a |
- Add type annotations to DataSourceOpenNebula.py - Add type annotations to read_context_disk_dir() function - Add type annotation for gen_conf() return type - Use assertions for type narrowing where needed - Add type: ignore for mock assignment in tests Addresses concern from PR canonical#6810 about type checking being disabled.
Add type annotations to DataSourceOpenNebula.py to address concerns raised in PR canonical#6810 about type checking being disabled for the OpenNebula datasource. Refs canonicalGH-6810
|
Hi @holmanb, regarding first concern about changing existing behavior: Looking at the diff, I believe this change is purely additive. The get_routes() method is new, and in gen_conf() the routes key is only added to the device config when ETHx_ROUTES is explicitly present in the context variables: extra_routes = self.get_routes(c_dev)
if extra_routes:
devconf["routes"] = extra_routesIf ETHx_ROUTES is absent (as it would be in all existing deployments), get_routes() returns an empty list, the condition is false, and gen_conf() output is identical to today's. No existing context variables are reinterpreted or removed. Could you clarify what specific behavior you see changing? I want to make sure I'm not missing something. Regarding the second concern, I enabled type checking in #6827. |
|
Here is a gist with |
|
you can see in the logs that before my patch, the |
Add type annotations to DataSourceOpenNebula.py to address concerns raised in PR canonical#6810 about type checking being disabled for the OpenNebula datasource. Refs canonicalGH-6810
Add type annotations to parse_shell_config, get_field (with @overload), and all OpenNebulaNetwork.get_* methods as requested. Replace assert-based type narrowing with proper guards. Remove leaked global assignment in test and revert unrelated cosmetic changes. Refs canonicalGH-6810
Add type annotations to parse_shell_config, get_field (with @overload), and all OpenNebulaNetwork.get_* methods as requested. Replace assert-based type narrowing with proper guards. Remove leaked global assignment in test and revert unrelated cosmetic changes. Refs canonicalGH-6810
Add type annotations to parse_shell_config, get_field (with @overload), and all OpenNebulaNetwork.get_* methods as requested. Replace assert-based type narrowing with proper guards. Remove leaked global assignment in test and revert unrelated cosmetic changes. Refs canonicalGH-6810
Context values come exclusively from parse_shell_config which returns Dict[str, str]. Shell variables can only be absent or hold string values, so a None context value is impossible in production. The equivalent realistic scenario is already covered by test_get_field_emptycontext. Refs canonicalGH-6810
…idates When test_find_candidates was refactored from a try/finally pattern to @mock.patch in d482353, the bare global assignment `util.find_devs_with = my_devs_with` was left in by mistake. The try/finally used to save and restore the original; without it, this assignment leaks state and can cause order-dependent failures in other tests. The @mock.patch decorator already patches the function correctly and restores it after the test. Refs canonicalGH-6810
…idates When test_find_candidates was refactored from a try/finally pattern to @mock.patch in d482353, the bare global assignment `util.find_devs_with = my_devs_with` was left in by mistake. The try/finally used to save and restore the original; without it, this assignment leaks state and can cause order-dependent failures in other tests. The @mock.patch decorator already patches the function correctly and restores it after the test. Refs canonicalGH-6810
Proposed Commit Message
Additional Context
The OpenNebula
context-linuxpackage (one-apps) supportsETHx_ROUTESto configure static routes per interface. cloud-init's OpenNebula
datasource was silently ignoring this variable, meaning any static
routes defined in the VM template were never applied.
Test Steps
On an OpenNebula VM, add to the VM template context section:
After boot, verify the routes were applied:
ip route show # expected: routes to 10.0.0.0/8 and 172.16.0.0/12 via 192.168.1.xAlso verify that a VM with no
ETHx_ROUTESset continues to boot andconfigure networking without any change in behaviour.
Merge type