nd_interface_port_channel_access module#269
Open
allenrobel wants to merge 6 commits intond_interface_loopbackfrom
Open
nd_interface_port_channel_access module#269allenrobel wants to merge 6 commits intond_interface_loopbackfrom
allenrobel wants to merge 6 commits intond_interface_loopbackfrom
Conversation
2c6a87d to
f74553d
Compare
8 tasks
532a0ff to
b741c2c
Compare
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
a6b89bd to
bba871b
Compare
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)
(none)
Proposed Changes
Adds
nd_interface_port_channel_accessfor managing accessPoHost port-channel interfaces on ND 4.2 fabrics. The PC policy is the single source of truth for members (theportslist); ND propagates access-mode configuration to member interfaces — users do not pre-configure members.PortChannelAccessInterfaceModel— Pydantic policy/payload model targetingaccessPoHost, 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 extendingNDBaseInterfaceOrchestrator. UsesEpManageInterfacesRemovefor delete (PCs are virtual/deletable like loopbacks). Filtersquery_allbyinterfaceType="portChannel"and per-subclass policy-type set.PortChannelAccessInterfaceOrchestrator— concrete subclass bindingmodel_classand theaccessPoHostpolicy-type filter.plugins/module_utils/models/interfaces/enums.py— first introduction on this branch; containsAccessPoHostPolicyTypeEnum,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_loopbackfor the base interface infrastructure (NDBaseInterfaceOrchestrator,FabricContext,manage_interfacesendpoints, 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_configround-trips, composite identifier,get_diff,merge, andget_argument_spec.tests/unit/module_utils/orchestrators/test_port_channel_access_interface.py— 8 cases coveringmodel_class, bulk-support flags,_managed_policy_types == {"accessPoHost"}, andPortChannelBaseOrchestrator.query_allfiltering byinterfaceTypeandpolicyType, 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:
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: deletedwith member-revert path,deploy: falsestaging, 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 sharednd_argument_specdefaults.To run:
Required
[nd:vars]entries (intests/integration/inventory.networking):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
Checklist
🤖 Generated with Claude Code