feat(opennebula): support ETHx_VLAN_ID for 802.1Q VLAN interfaces#6815
feat(opennebula): support ETHx_VLAN_ID for 802.1Q VLAN interfaces#6815mcanevet wants to merge 1 commit intocanonical:mainfrom
Conversation
96b8a1c to
5044a76
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.) |
5044a76 to
b4b19ef
Compare
|
@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.
b4b19ef to
36825cd
Compare
There was a problem hiding this comment.
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 avlans:section whenETH<x>_VLAN_IDis present, leaving the parent NIC without IP configuration. - Add unit tests covering VLAN generation, mixed VLAN/non-VLAN NICs, and omission of the
vlanskey when unused. - Document
ETH<x>_VLAN_IDbehavior 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.
| 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: |
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 Netplan v2
vlans:stanza requiresid:(integer) andlink:(parentdevice 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:
After boot, verify
ip link showincludeseth0.100andip addr show eth0.100shows
10.0.0.1/24. The parenteth0should have no address.Merge type