Skip to content

nd_interface_port_channel_trunk_host#270

Open
allenrobel wants to merge 13 commits into
nd_interface_port_channel_accessfrom
nd_interface_port_channel_trunk_host
Open

nd_interface_port_channel_trunk_host#270
allenrobel wants to merge 13 commits into
nd_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 allenrobel force-pushed the nd_interface_port_channel_access branch from a6b89bd to bba871b Compare May 6, 2026 01:42
allenrobel added a commit that referenced this pull request May 6, 2026
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 22ea587 to 6009d17 Compare May 6, 2026 01:42
allenrobel added a commit that referenced this pull request May 6, 2026
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 6009d17 to c6c9b99 Compare May 6, 2026 21:36
@allenrobel allenrobel force-pushed the nd_interface_port_channel_access branch from bba871b to 5baf130 Compare May 6, 2026 21:36
allenrobel added a commit that referenced this pull request May 6, 2026
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from c6c9b99 to 6465a0f Compare May 6, 2026 21:50
@allenrobel allenrobel force-pushed the nd_interface_port_channel_access branch from 5baf130 to 6421474 Compare May 6, 2026 21:50
allenrobel added a commit that referenced this pull request May 6, 2026
allenrobel added a commit that referenced this pull request May 20, 2026
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 6feffd8 to 1e1d26d Compare May 20, 2026 21:23
@allenrobel allenrobel changed the title nd_interface_port_channel_trunk_host module nd_interface_port_channel_trunk_host May 20, 2026
@allenrobel allenrobel force-pushed the nd_interface_port_channel_access branch from 274aae3 to a0eb2e2 Compare May 21, 2026 19:41
allenrobel added a commit that referenced this pull request May 21, 2026
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 1e1d26d to 69c77c5 Compare May 21, 2026 19:41
allenrobel added a commit that referenced this pull request May 22, 2026
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 69c77c5 to b993187 Compare May 22, 2026 00:50
allenrobel added a commit that referenced this pull request May 22, 2026
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 01d4292 to 3061435 Compare May 22, 2026 03:13
allenrobel added a commit that referenced this pull request May 22, 2026
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 3061435 to 31f1f7c Compare May 22, 2026 03:22
allenrobel added a commit that referenced this pull request May 22, 2026
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from 31f1f7c to b8f83bc Compare May 22, 2026 03:28
allenrobel added a commit that referenced this pull request May 22, 2026
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from b8f83bc to a042e60 Compare May 22, 2026 03:33
allenrobel and others added 13 commits May 22, 2026 07:10
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
…y_all tests

validate_for_mutation reads freeze status from cached fabric_summary
(see fabric_context.py:166), so query_all no longer issues a separate
GET to /deploymentFreeze. The extra _freeze response was being
consumed by the next request in the sequence, breaking the happy-path
test (00400) and silently masking the no-match (00410) and switch-404
(00430) tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…arg spec

Same change as ethernet_access (5ecd435): drop interface_type, mode,
and network_os_type from get_argument_spec() and DOCUMENTATION; narrow
each in the Pydantic model to Literal[<value>] (or keep the existing
Enum for policy_type) and add Field(frozen=True) so the values are
immutable post-construction. Updates the argspec assertion test, the
interface_type/mode existence tests, and the network_os_type test to
verify the Literal lock instead of accepting "ios-xe".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
YAML 1.1 parses an unquoted `on` as the boolean True, so the
DOCUMENTATION block's `choices: [ on, active, passive ]` resolved to
`[True, 'active', 'passive']` while the argument_spec correctly used
the string 'on'. This tripped two ansible-test validate-modules
checks: doc-choices-do-not-match-spec and doc-choices-incompatible-type.

Quote 'on' so the documented choices parse as strings and match the spec.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@allenrobel allenrobel force-pushed the nd_interface_port_channel_trunk_host branch from a042e60 to 297e66c Compare May 22, 2026 17:14
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