Skip to content

feat(opennebula): support ETHx_VLAN_ID for 802.1Q VLAN interfaces#6815

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

feat(opennebula): support ETHx_VLAN_ID for 802.1Q VLAN interfaces#6815
mcanevet wants to merge 1 commit intocanonical:mainfrom
mcanevet:feat/opennebula-eth-vlan-id

Conversation

@mcanevet
Copy link
Copy Markdown
Contributor

Proposed Commit Message

feat(opennebula): support ETHx_VLAN_ID for 802.1Q VLAN interfaces

When ETHx_VLAN_ID is set, context-linux creates a VLAN sub-interface
(e.g. eth0.100) and assigns IP config to it. cloud-init ignored this
variable entirely.

Restructure gen_conf() to check for VLAN_ID per interface: when set,
emit a bare parent entry in ethernets: (MAC match only) and place all
IP configuration in a vlans: entry named <dev>.<id>. The vlans: key
is omitted from the output when no VLANs are configured.

Additional Context

Part of a series bringing cloud-init's OpenNebula datasource to feature
parity with the context-linux package from one-apps.

The Netplan v2 vlans: stanza requires id: (integer) and link: (parent
device name). All other configuration keys (addresses, gateway4, nameservers,
etc.) are placed on the VLAN entry, not the parent.

Test Steps

In an OpenNebula VM context, set:

ETH0_IP="10.0.0.1"
ETH0_MASK="255.255.255.0"
ETH0_VLAN_ID="100"

After boot, verify ip link show includes eth0.100 and ip addr show eth0.100
shows 10.0.0.1/24. The parent eth0 should have no 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-vlan-id branch 2 times, most recently from 96b8a1c to 5044a76 Compare April 1, 2026 08:33
@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-vlan-id branch from 5044a76 to b4b19ef Compare April 22, 2026 06:43
@mcanevet
Copy link
Copy Markdown
Contributor Author

@blackboxsw rebased

When ETHx_VLAN_ID is set, context-linux creates a VLAN sub-interface
(e.g. eth0.100) and assigns IP config to it. cloud-init ignored this
variable entirely.

Restructure gen_conf() to check for VLAN_ID per interface: when set,
emit a bare parent entry in ethernets: (MAC match only) and place all
IP configuration in a vlans: entry named <dev>.<id>. The vlans: key
is omitted from the output when no VLANs are configured.
Copilot AI review requested due to automatic review settings May 5, 2026 14:34
@mcanevet mcanevet force-pushed the feat/opennebula-eth-vlan-id branch from b4b19ef to 36825cd Compare May 5, 2026 14:34
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 updates the OpenNebula datasource’s Netplan v2 generation to support OpenNebula’s ETH<x>_VLAN_ID contextualization variable, emitting an 802.1Q VLAN sub-interface (e.g. eth0.100) and applying IP configuration to the VLAN device rather than the parent NIC.

Changes:

  • Extend OpenNebulaNetwork.gen_conf() to generate a vlans: section when ETH<x>_VLAN_ID is present, leaving the parent NIC without IP configuration.
  • Add unit tests covering VLAN generation, mixed VLAN/non-VLAN NICs, and omission of the vlans key when unused.
  • Document ETH<x>_VLAN_ID behavior in the OpenNebula datasource reference docs.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
cloudinit/sources/DataSourceOpenNebula.py Generate Netplan vlans: stanzas when ETH<x>_VLAN_ID is set and keep the parent NIC unaddressed.
tests/unittests/sources/test_opennebula.py Add unit tests validating VLAN Netplan output structure and key placement (parent vs VLAN).
doc/rtd/reference/datasources/opennebula.rst Document the new ETH<x>_VLAN_ID contextualization variable and resulting interface behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +291 to +300
vlan_id: Optional[str] = self.get_field(c_dev, "vlan_id")
devconf: Dict[str, Any]

# Set MAC address
devconf["match"] = {"macaddress": mac}
if vlan_id:
# Parent: just bring it up, no IP configuration
netconf["ethernets"][dev] = {"match": {"macaddress": mac}}
# VLAN sub-interface carries the actual IP config
target_name = "%s.%s" % (dev, vlan_id)
devconf = {"id": int(vlan_id), "link": dev}
else:
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