Add nd_interface_ethernet_trunk_host module#264
Closed
allenrobel wants to merge 2 commits intond_interface_ethernet_accessfrom
Closed
Add nd_interface_ethernet_trunk_host module#264allenrobel wants to merge 2 commits intond_interface_ethernet_accessfrom
allenrobel wants to merge 2 commits intond_interface_ethernet_accessfrom
Conversation
Adds a new Ansible module for CRUD operations on host-facing ethernet trunk interfaces in Nexus Dashboard 4.2. Follows the same composite- identifier, bulk-CRUD, and deploy-lifecycle pattern as the access module, filtering on policyType=trunkHost. - TrunkHostPolicyTypeEnum added to shared interface enums. - EthernetTrunkHostInterfaceModel defines trunk-specific policy fields (allowed_vlans with regex validator, native_vlan, vlan_mapping, vlan_mapping_entries) and reuses shared enums for the rest. - EthernetTrunkHostInterfaceOrchestrator inherits the shared ethernet base; only _managed_policy_types() is type-specific. - Integration test target covers merged/replaced/overridden/deleted. Unit tests deferred to match nd_interface_ethernet_access. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Resolves issues surfaced by the full trunk-host integration run:
- `EthernetTrunkHostVlanMappingEntryModel.customer_vlan_id` is now
`List[str]`, matching the ND API which expects `customerVlanId` as an
array of VLAN tokens rather than a single string.
- `EthernetTrunkHostPolicyModel.validate_allowed_vlans` now coerces
integer input to string before regex validation, so ND responses that
return a single-VLAN `allowedVlans` as a bare integer (e.g. `999`) no
longer raise a Pydantic `ValueError`.
- `InterfaceDefaultPolicyModel` now includes `description: ""` and
`nativeVlan: 1`, so `interfaceActions/normalize` fully resets user-set
descriptions and native VLANs on deleted / overridden interfaces
instead of leaving them behind.
- `EthernetTrunkHostInterfaceOrchestrator.query_all` filters out
interfaces matching the unconfigured `int_trunk_host` default
signature. Normalizing a trunkHost interface produces another
trunkHost interface, so without this filter `state: overridden` could
not be idempotent (every fabric-default interface appeared in `before`
and was re-queued for normalization on every run).
- Integration tests scope `selectattr('interface_name', ...)` lookups
by `switch_ip` so assertions work on multi-switch fabrics, and the
VLAN-mapping block is gated on a new `supports_vlan_mapping` extra-var
because Nexus 9000v virtual switches reject
`switchport vlan mapping ... dot1q-tunnel ...`.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue(s)
Stacks on top of #222 (access module).
Proposed Changes
Adds the
nd_interface_ethernet_trunk_hostmodule for managing Cisco Nexus Dashboard 4.2 ethernet interfaces with thetrunkHostpolicy type. Parallelsnd_interface_ethernet_access: composite(switch_ip, interface_name)identifier, bulk create / bulk normalize-as-delete, per-interface deploy queueing, and the full merged / replaced / overridden / deleted state lifecycle.EthernetTrunkHostInterfaceModelwith trunk-specific fields —allowed_vlans(regex-validated, acceptsnone,all, or comma-separated IDs/ranges),native_vlan,vlan_mapping, and nestedvlan_mapping_entrieswithcustomer_vlan_idasList[str]to match the ND API.TrunkHostPolicyTypeEnumadded to shared interface enums.EthernetTrunkHostInterfaceOrchestratorfiltersquery_allto exclude interfaces matching the unconfiguredint_trunk_hostdefault signature, sostate: overriddenis idempotent on the second run. Normalizing a trunkHost interface produces another trunkHost interface, so without this filter every fabric-default interface would appear inbeforeand be re-queued for normalization on every run.InterfaceDefaultPolicyModelgainsdescription: ""andnativeVlan: 1sointerfaceActions/normalizeactually clears user-set descriptions and native VLANs on deleted / overridden interfaces instead of leaving them behind. This affects all ethernet modules that delete via normalize, which is the desired behavior.allowed_vlansvalidator coerces bare-integer ND responses (e.g. a single VLAN returned as999) to string before regex validation.selectattr('interface_name', ...)lookups are scoped byswitch_ipso assertions hold on multi-switch fabrics. The VLAN-mapping test block is gated on asupports_vlan_mappingextra-var because Nexus 9000v virtual switches rejectswitchport vlan mapping ... dot1q-tunnel ...at the NX-OS layer.Test Notes
ansible-test network-integration nd_interface_ethernet_trunk_host -v.--extra-vars supports_vlan_mapping=true.Cisco Nexus Dashboard Version
4.2
Related ND API Resource Category
Checklist