Skip to content

feat(opennebula): support ETHx_METHOD and ETHx_IP6_METHOD#6814

Open
mcanevet wants to merge 1 commit intocanonical:mainfrom
mcanevet:feat/opennebula-eth-method
Open

feat(opennebula): support ETHx_METHOD and ETHx_IP6_METHOD#6814
mcanevet wants to merge 1 commit intocanonical:mainfrom
mcanevet:feat/opennebula-eth-method

Conversation

@mcanevet
Copy link
Copy Markdown
Contributor

Proposed Commit Message

feat(opennebula): support ETHx_METHOD and ETHx_IP6_METHOD

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

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_IP6 or ETHx_IP6_GATEWAY is present, it defaults to static;
otherwise disable. This preserves backwards-compatible behaviour for all
existing 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 show shows a SLAAC-derived IPv6 address.

Merge type

  • Squash merge using "Proposed Commit Message"
  • Rebase and merge unique commits. Requires commit messages per-commit each referencing the pull request number (#<PR_NUM>)

@github-actions github-actions Bot added the documentation This Pull Request changes documentation label Mar 30, 2026
@mcanevet mcanevet force-pushed the feat/opennebula-eth-method branch 3 times, most recently from ec4a406 to e7733bf Compare April 1, 2026 08:32
@github-actions
Copy link
Copy Markdown

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.)

@github-actions github-actions Bot added the stale-pr Pull request is stale; will be auto-closed soon label Apr 16, 2026
@blackboxsw blackboxsw removed the stale-pr Pull request is stale; will be auto-closed soon label Apr 21, 2026
@mcanevet mcanevet force-pushed the feat/opennebula-eth-method branch from e7733bf to ade3f0b Compare April 22, 2026 06:37
@mcanevet
Copy link
Copy Markdown
Contributor Author

@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
@mcanevet mcanevet force-pushed the feat/opennebula-eth-method branch from ade3f0b to 6bdd5d2 Compare May 5, 2026 14:33
Copilot AI review requested due to automatic review settings May 5, 2026 14:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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() and get_ip6_method() helpers to interpret ETH<x>_METHOD and infer/parse ETH<x>_IP6_METHOD.
  • Rework OpenNebulaNetwork.gen_conf() to emit dhcp4: 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.

Comment on lines +260 to +269
"""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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation This Pull Request changes documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants