feat(opennebula): support ETHx_METHOD and ETHx_IP6_METHOD#6814
feat(opennebula): support ETHx_METHOD and ETHx_IP6_METHOD#6814mcanevet wants to merge 1 commit intocanonical:mainfrom
Conversation
ec4a406 to
e7733bf
Compare
|
Hello! Thank you for this proposed change to cloud-init. This pull request is now marked as stale as it has not seen any activity in 14 days. If no activity occurs within the next 7 days, this pull request will automatically close. If you are waiting for code review and you are seeing this message, apologies! Please reply, tagging blackboxsw, and he will ensure that someone takes a look soon. (If the pull request is closed and you would like to continue working on it, please do tag blackboxsw to reopen it.) |
e7733bf to
ade3f0b
Compare
|
@blackboxsw rebased |
cloud-init's OpenNebula datasource always generated static Netplan configuration, ignoring ETHx_METHOD and ETHx_IP6_METHOD entirely. Add get_method() and get_ip6_method() helpers and rework the IPv4/IPv6 blocks in gen_conf() to branch on the configured method: IPv4 (ETHx_METHOD): - static (default): existing behaviour, no regression - dhcp: emit dhcp4: true, no addresses - skip: omit interface from Netplan output entirely IPv6 (ETHx_IP6_METHOD): - static (default when ETHx_IP6 or ETHx_IP6_GATEWAY is present): existing behaviour - dhcp/dhcp6: emit dhcp6: true - auto/slaac: emit accept-ra: true - disable/skip: suppress all IPv6 config
ade3f0b to
6bdd5d2
Compare
There was a problem hiding this comment.
Pull request overview
This PR extends cloud-init’s OpenNebula datasource network generation to honor OpenNebula context variables ETH<x>_METHOD (IPv4) and ETH<x>_IP6_METHOD (IPv6), enabling DHCP, SLAAC/RA, and skipping behavior instead of always emitting static Netplan configuration.
Changes:
- Add
get_method()andget_ip6_method()helpers to interpretETH<x>_METHODand infer/parseETH<x>_IP6_METHOD. - Rework
OpenNebulaNetwork.gen_conf()to emitdhcp4: true,dhcp6: true,accept-ra: true, omit IPv6 config, or omit the interface entirely based on method selection. - Add/extend unit tests and update OpenNebula datasource documentation to describe the new context variables.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
cloudinit/sources/DataSourceOpenNebula.py |
Add IPv4/IPv6 method helpers and branch Netplan output on ETH<x>_METHOD / ETH<x>_IP6_METHOD. |
doc/rtd/reference/datasources/opennebula.rst |
Document the new OpenNebula context variables and their effects on generated Netplan. |
tests/unittests/sources/test_opennebula.py |
Add unit tests covering new method parsing and Netplan generation branches. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """Return IPv6 config method: static | dhcp | auto | disable | skip. | ||
|
|
||
| Defaults to 'static' when ETHx_IP6 is set, otherwise 'disable'. | ||
| """ | ||
| val = self.get_field(dev, "ip6_method", "") | ||
| if val: | ||
| return val.lower() | ||
| # infer from presence of IPv6 address or gateway | ||
| if self.get_ip6(dev) or self.get_gateway6(dev): | ||
| return "static" |
| values are ``static`` (default when ``ETH<x>_IP6`` or ``ETH<x>_IP6_GATEWAY`` | ||
| is present), ``dhcp`` / ``dhcp6``, ``auto`` / ``slaac``, ``disable``, and | ||
| ``skip``. ``dhcp``/``dhcp6`` emits ``dhcp6: true``; ``auto``/``slaac`` | ||
| emits ``accept-ra: true``; ``disable`` suppresses all IPv6 configuration. |
| """IP6_METHOD absent, ETHx_IP6 present → 'static'.""" | ||
| net = ds.OpenNebulaNetwork({"ETH0_IP6": IP6_GLOBAL}, mock.Mock()) | ||
| assert net.get_ip6_method("eth0") == "static" | ||
|
|
Proposed Commit Message
Additional Context
Part of a series bringing cloud-init's OpenNebula datasource to feature
parity with the context-linux package from one-apps.
The
get_ip6_method()helper infers the default IPv6 method from context:if
ETHx_IP6orETHx_IP6_GATEWAYis present, it defaults tostatic;otherwise
disable. This preserves backwards-compatible behaviour for allexisting tests.
Test Steps
In an OpenNebula VM context, set:
ETH0_METHOD="dhcp"After boot, verify the interface obtains its IP via DHCP (no static
address in
ip addr show).For IPv6 SLAAC:
ETH0_IP6_METHOD="auto"After boot, verify
ip addr showshows a SLAAC-derived IPv6 address.Merge type