Skip to content

nd_interface_port_channel_trunk_host module#270

Open
allenrobel wants to merge 10 commits intond_interface_port_channel_accessfrom
nd_interface_port_channel_trunk_host
Open

nd_interface_port_channel_trunk_host module#270
allenrobel wants to merge 10 commits intond_interface_port_channel_accessfrom
nd_interface_port_channel_trunk_host

Conversation

@allenrobel
Copy link
Copy Markdown
Collaborator

Related Issue(s)

N/A

Proposed Changes

  • Add nd_interface_port_channel_trunk_host Ansible module managing trunkPoHost port-channel interfaces on Cisco Nexus Dashboard 4.2.
  • Mirrors nd_interface_port_channel_access structure: composite identifier (switch_ip, interface_name), policyType hardcoded to "trunkPoHost" and not exposed in argspec, full ND OpenAPI intPortChannelTrunkHostTemplate field set (42 policy fields including bandwidth, link_type, negotiate_auto, vlan_mapping with selective dot1q-tunnel, storm-control float fields).
  • New enums: TrunkPoHostPolicyTypeEnum, LinkTypeEnum in plugins/module_utils/models/interfaces/enums.py.
  • New orchestrator inherits from PortChannelBaseOrchestrator; managed policy types filter to {"trunkPoHost"} only.
  • state: overridden deletes via interfaceActions/remove (mirrors access PC); state: query deferred consistent with current parity stance.
  • Comprehensive unit test coverage (148 model + 8 orchestrator tests). Covers field defaults, snake/camelCase construction, validators (including allowed_vlans regex with int -> str coercion for ND's single-id-as-int responses), AsciiDescription, storm-control float-from-string coercion, vlan_mapping entries, composite identifier round-trips, and query_all filtering.
  • Integration tests cover merged/replaced/overridden/deleted state transitions, member-uniqueness ordering, and a non-9000v vlan_mapping block guarded by nd_test_platform.

Test Notes

  • Unit tests pass: pytest tests/unit/module_utils/ -k port_channel_trunk_host -v (156 passed). Full suite (pytest tests/unit/): 705 passed, no regressions.
  • black and pylint clean (matching access PC scoring).
  • Integration tests pass against ND 4.2 fabric on N9K-C9300v testbed (single-fabric, single-switch). vlan_mapping block skipped on 9000v as expected.
  • Live-API verification: ND returns policyType: "trunkPoHost" and accepts the model's payload shape (verified with POST/GET/PUT/DELETE round-trip during development).
  • Note: ND echoes single-id allowedVlans as a JSON int rather than string; the model coerces int -> str in a mode='before' validator and a unit test locks the behavior.

Cisco Nexus Dashboard Version

4.2

Related ND API Resource Category

  • analyze
  • infra
  • manage
  • onemanage
  • other

Checklist

  • Latest commit is rebased from develop with merge conflicts resolved
  • New or updates to documentation has been made accordingly
  • Assigned the proper reviewers

Stacking

This PR is stacked on top of #269 (nd_interface_port_channel_access). Base branch is nd_interface_port_channel_access; merge after #269 lands.

🤖 Generated with Claude Code

@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 39e151c to 4e69ab6 Compare May 4, 2026 19:27
@allenrobel allenrobel force-pushed the nd_interface_port_channel_access branch from 835edb8 to 6e2ccb3 Compare May 4, 2026 19:36
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 4e69ab6 to b861768 Compare May 4, 2026 19:36
Comment thread plugins/module_utils/models/interfaces/port_channel_trunk_host_interface.py Outdated
Comment thread plugins/modules/nd_interface_port_channel_trunk_host.py Outdated
Comment thread plugins/modules/nd_interface_port_channel_trunk_host.py
Comment thread plugins/modules/nd_interface_port_channel_trunk_host.py
Comment thread plugins/modules/nd_interface_port_channel_trunk_host.py
Comment thread tests/integration/targets/nd_interface_port_channel_trunk_host/tasks/merged.yaml Outdated
@allenrobel allenrobel force-pushed the nd_interface_port_channel_access branch from 6e2ccb3 to bdd7390 Compare May 5, 2026 19:46
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from b861768 to 55fb7a3 Compare May 5, 2026 19:46
@allenrobel allenrobel force-pushed the nd_interface_port_channel_access branch from bdd7390 to 532a0ff Compare May 5, 2026 20:24
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 55fb7a3 to 1770181 Compare May 5, 2026 20:24
@allenrobel allenrobel force-pushed the nd_interface_port_channel_access branch from 532a0ff to b741c2c Compare May 5, 2026 20:38
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 1770181 to 9eacb19 Compare May 5, 2026 20:38
allenrobel added a commit that referenced this pull request May 5, 2026
allenrobel and others added 10 commits May 5, 2026 15:41
Mirrors nd_interface_port_channel_access structure for the trunkPoHost policy
type. 42-field policy model covers the full ND OpenAPI intPortChannelTrunkHostTemplate
superset, including bandwidth, linkType, negotiateAuto, vlan_mapping/dot1q-tunnel,
and storm-control float fields. policyType is hardcoded to "trunkPoHost" and not
exposed in the argspec. Integration tests cover merged/replaced/overridden/deleted,
member uniqueness ordering, and a non-9000v vlan_mapping block.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Covers PortChannelTrunkHostInterfaceModel and PortChannelTrunkHostInterfaceOrchestrator:
field defaults, snake_case/camelCase construction, allowed_vlans regex (with int->str
coercion for ND's single-id-as-int responses), native_vlan/bandwidth/inherit_bandwidth
range checks, AsciiDescription, storm-control float-from-string coercion, vlan_mapping
entries, composite identifier round-trips, hardcoded policyType, query_all filtering
to trunkPoHost only.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Add module docstring, scope a wrong-import-position disable to the
post-DOCUMENTATION import block, and replace dict() call with a literal.
Pylint score now 10.00/10.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace shape-only regex with Annotated types (AllowedVlans,
CustomerVlanIdList) backed by a shared per-token validator that
enforces VLAN ids in 1..4094 and rejects reversed ranges. Addresses
review feedback on lines 57-58 of port_channel_trunk_host_interface.py
and closes the same gap on customer_vlan_id. Mark both types with a
TODO to consolidate into models/types.py once sibling branches merge.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
VlanId (1..4094) recurs as Field(ge=1, le=4094) on multiple fields
across the interface family. Defer the cleanup to the same post-merge
PR that introduces AllowedVlans / CustomerVlanIdList in models/types.py.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Address review comment requesting that the valid VLAN id range
(1-4094) be stated in the module docstring. The model validators
already enforce this range; this only updates the user-facing
documentation for parity with native_vlan and similar fields.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Address review comment asking why only merged and deleted examples were
shown.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Replace verbatim-repeated module argument blocks (check / normal / idempotent
runs of the same call) with YAML anchors. Reduces ~140 lines of duplication
across deleted, merged, replaced, overridden, and vlan_mapping task files,
and removes a class of typo where one of the duplicated blocks could drift
from its siblings.

Anchors are defined at first use within each section to keep them local to
the reader.
Move the top-of-file SETUP block from merged.yaml (delete
port-channel501/502/503) into a dedicated tasks/setup.yaml and call it from
main.yaml before the state-test blocks. Makes the orchestration explicit
and keeps merged.yaml focused on its state.

Intra-test setup that's coupled to specific tests stays inline:
- Reset-to-baseline before the membership tests in merged.yaml
- port-channel504 cleanup after the no-deploy test in merged.yaml
- vlan_mapping.yaml's local SETUP/CLEANUP for port-channel501
@allenrobel allenrobel force-pushed the nd_interface_port_channel_access branch from a6b89bd to bba871b Compare May 6, 2026 01:42
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 22ea587 to 6009d17 Compare May 6, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants