Skip to content

nd_interface_port_channel_access module#269

Open
allenrobel wants to merge 6 commits intond_interface_loopbackfrom
nd_interface_port_channel_access
Open

nd_interface_port_channel_access module#269
allenrobel wants to merge 6 commits intond_interface_loopbackfrom
nd_interface_port_channel_access

Conversation

@allenrobel
Copy link
Copy Markdown
Collaborator

@allenrobel allenrobel commented May 2, 2026

Related Issue(s)

(none)

Proposed Changes

Adds nd_interface_port_channel_access for managing accessPoHost port-channel interfaces on ND 4.2 fabrics. The PC policy is the single source of truth for members (the ports list); ND propagates access-mode configuration to member interfaces — users do not pre-configure members.

  • PortChannelAccessInterfaceModel — Pydantic policy/payload model targeting accessPoHost, composite identifier (switch_ip, interface_name), all access-mode policy fields plus port-channel specifics (ports, copy_description, port_channel_mode, lacp_rate, lacp_port_priority, lacp_suspend).
  • PortChannelBaseOrchestrator — shared CRUD base extending NDBaseInterfaceOrchestrator. Uses EpManageInterfacesRemove for delete (PCs are virtual/deletable like loopbacks). Filters query_all by interfaceType="portChannel" and per-subclass policy-type set.
  • PortChannelAccessInterfaceOrchestrator — concrete subclass binding model_class and the accessPoHost policy-type filter.
  • plugins/module_utils/models/interfaces/enums.py — first introduction on this branch; contains AccessPoHostPolicyTypeEnum, PortChannelModeEnum, LacpRateEnum, plus access-mode enums that will be shared with future trunk-host work (BpduFilter, BpduGuard, DuplexMode, Mtu, Speed, StormControlAction).

Branch base: stacked on nd_interface_loopback for the base interface infrastructure (NDBaseInterfaceOrchestrator, FabricContext, manage_interfaces endpoints, base interface models).

Test Notes

Unit tests

Adapted from the ethernet_trunk_host unit-test trio:

  • tests/unit/module_utils/models/test_port_channel_access_interface.py — 114 cases covering policy/network_os/config_data/interface model defaults, alias population, normalize_policy_type, normalize_ports, range/enum validation, AsciiDescription, serializer modes, to_payload / to_config / from_response / from_config round-trips, composite identifier, get_diff, merge, and get_argument_spec.
  • tests/unit/module_utils/orchestrators/test_port_channel_access_interface.py — 8 cases covering model_class, bulk-support flags, _managed_policy_types == {"accessPoHost"}, and PortChannelBaseOrchestrator.query_all filtering by interfaceType and policyType, plus fabric-not-found and per-switch 404 paths.
  • tests/unit/module_utils/fixtures/fixture_data/test_port_channel_access_interface.json — fabric summary, deploymentFreeze, switches, and per-switch interfaces fixtures for the orchestrator tests.

To run:

python -m pytest tests/unit/module_utils/models/test_port_channel_access_interface.py tests/unit/module_utils/orchestrators/test_port_channel_access_interface.py

122/122 pass. Full unit suite (558 tests) green; black/isort clean.

Integration tests

Cover: create / multi-create across switches, idempotency, update access_vlan and description, add member to PC, remove member from PC, state: replaced, state: overridden (incl. interfaceType filter check), state: deleted with member-revert path, deploy: false staging, and non-existent delete no-op.

Tests passed end-to-end on a 9000v testbed against ND 4.2 (192.168.7.8 / fabric_1 / leaf at 192.168.12.151).

The test target uses module_defaults: { cisco.nd.nd_interface_port_channel_access: { timeout: 300 } } to scope a 300s timeout to PC tests — port-channel deploys (build bundle, pull members, apply LACP) routinely exceed the default 30s on slower testbeds. Scoped at the test target level so we don't touch shared nd_argument_spec defaults.

To run:

ansible-test network-integration nd_interface_port_channel_access -v

Required [nd:vars] entries (in tests/integration/inventory.networking):

nd_test_fabric_name=<fabric>
nd_test_switch_ip=<switch IP>
nd_test_pc_member_a=Ethernet1/10
nd_test_pc_member_b=Ethernet1/11
nd_test_pc_member_c=Ethernet1/12
nd_test_pc_member_d=Ethernet1/13

The four member ethernets must exist on the target switch and not currently belong to any other port-channel (the SETUP cleanup at the start of each state file resets them).

Cisco Nexus Dashboard Version

4.2

Related ND API Resource Category

  • analyze
  • infra
  • manage
  • onemanage
  • other

Checklist

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

🤖 Generated with Claude Code

@allenrobel allenrobel changed the title Add nd_interface_port_channel_access module nd_interface_port_channel_access module May 2, 2026
@allenrobel allenrobel self-assigned this May 2, 2026
@allenrobel allenrobel marked this pull request as ready for review May 2, 2026 23:30
@allenrobel allenrobel force-pushed the nd_interface_port_channel_access branch from 2c6a87d to f74553d Compare May 4, 2026 05:04
@allenrobel allenrobel force-pushed the nd_interface_port_channel_access branch 4 times, most recently from 532a0ff to b741c2c Compare May 5, 2026 20:38
allenrobel and others added 6 commits May 5, 2026 15:41
Adds an Ansible module for managing port-channel accessPoHost interfaces
on Cisco Nexus Dashboard 4.2 fabrics. Members are configured via the
port-channel policy itself (the ports list); ND propagates the access-mode
configuration to member interfaces.

Components:
- PortChannelAccessInterfaceModel - Pydantic policy/payload model
  targeting the accessPoHost template, composite identifier
  (switch_ip, interface_name), with access-mode policy fields plus
  port-channel specifics (ports, copy_description, port_channel_mode,
  lacp_rate, lacp_port_priority, lacp_suspend).
- PortChannelBaseOrchestrator - shared CRUD orchestrator extending
  NDBaseInterfaceOrchestrator; uses EpManageInterfacesRemove for delete
  (port-channels are virtual/deletable like loopbacks); filters
  query_all by interfaceType="portChannel" and managed policy types.
- PortChannelAccessInterfaceOrchestrator - concrete subclass binding
  model_class and managing the accessPoHost policy type.
- shared interfaces/enums.py - first introduction on this branch;
  contains AccessPoHostPolicyTypeEnum, PortChannelModeEnum, LacpRateEnum,
  plus access-mode enums (BpduFilter, BpduGuard, DuplexMode, Mtu, Speed,
  StormControlAction) shared with future trunk-host work.
- Integration tests covering merged / replaced / overridden / deleted
  state, idempotency, member add/remove, multi-PC create, deploy:false
  staging, and member revert on PC delete.

The integration test target uses module_defaults to set timeout=300 for
all module calls, since port-channel deploys can exceed the default 30s
on slower testbeds (build PC bundle, pull members, apply LACP).

Unit tests are deferred to a follow-up commit.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Model tests: 114 cases for PortChannelAccessPolicyModel /
  NetworkOSModel / ConfigDataModel / InterfaceModel covering field
  defaults, alias population, normalize_policy_type, normalize_ports,
  range/enum validation, AsciiDescription, serializer modes,
  to_payload/to_config/from_response/from_config round-trips,
  composite identifier, get_diff, merge, and get_argument_spec.
- Orchestrator tests: 8 cases verifying model_class, bulk-support
  flags, _managed_policy_types == {"accessPoHost"}, and
  PortChannelBaseOrchestrator.query_all filtering by interfaceType
  and policyType, including fabric-not-found and per-switch 404 paths.
- Fixture JSON simulates the fabric summary, deploymentFreeze,
  switches, and per-switch interfaces endpoints.

Adapted from the ethernet_trunk_host unit-test trio.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
The nd_interface_port_channel_access module exists solely to manage
accessPoHost port-channels, so policy_type was dead surface as a
user-facing option (only one valid value).

- Remove policy_type from argspec and DOCUMENTATION
- Drop normalize_policy_type validator and serialize_policy_type
  field serializer (no Ansible-API translation needed)
- Hardcode AccessPoHostPolicyTypeEnum.ACCESS_PO_HOST as the model
  default; field still serialized into payloads as policyType
- Strip policy_type from integration test inputs
- Update unit tests to match (113/113 pass; full suite 549/549)

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 verbatim-repeated module argument blocks (check / normal / idempotent
runs of the same call) with YAML anchors. 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
@allenrobel allenrobel force-pushed the nd_interface_port_channel_access branch from a6b89bd to bba871b 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.

1 participant