Skip to content

Ansible ND 4.X | WIP | ND Manage Switches Module + Pydantic Models + Smart Endpoints#198

Open
AKDRG wants to merge 30 commits intoCiscoDevNet:nd42_integrationfrom
AKDRG:switch_int_pr
Open

Ansible ND 4.X | WIP | ND Manage Switches Module + Pydantic Models + Smart Endpoints#198
AKDRG wants to merge 30 commits intoCiscoDevNet:nd42_integrationfrom
AKDRG:switch_int_pr

Conversation

@AKDRG
Copy link
Copy Markdown

@AKDRG AKDRG commented Mar 11, 2026

This PR introduces the initial implementation of ND Manage switch lifecycle support in the cisco.nd collection.
It adds a new switch management resource layer, endpoint wrappers, Pydantic model hierarchy, utility helpers.

What’s Included

  1. New switch lifecycle resource implementation

Added a full resource engine in plugins/module_utils/nd_switch_resources.py
Implements state handling for:

  • gathered
  • merged
  • overridden
  • deleted
  • POAP flows (bootstrap, pre-provision, serial swap)
  • RMA flow

Adds structured operation sequencing:

  • discovery
  • add/remove
  • role updates
  • credentials save
  • wait-for-manageability
  • save/deploy finalize
  1. ND Manage endpoint layer

Added endpoint models under plugins/module_utils/endpoints/v1/nd_manage_switches:

  • manage_credentials.py
  • manage_fabric_bootstrap.py
  • manage_fabric_config.py
  • manage_fabric_discovery.py
  • manage_fabric_switch_actions.py
  • manage_fabric_switches.py
  1. Pydantic model framework and nd_manage_switches models

Added shared model base and nested infrastructure:

  • plugins/module_utils/models/base.py
  • plugins/module_utils/models/nested.py
  • Added nd_manage_switches model package and exports:
  • bootstrap, config, discovery, preprovision, rma, switch_actions, switch_data, enums, validators
  • package-level init re-exports for consistent imports

Added model consolidation in:
plugins/module_utils/models/nd_manage_switches/summary_models.py

  1. Utilities for lifecycle orchestration
    Added helpers in plugins/module_utils/utils/nd_manage_switches:
  • bootstrap_utils.py
  • fabric_utils.py
  • payload_utils.py
  • switch_helpers.py
  • switch_wait_utils.py
  • exceptions.py

These utilities centralize grouping, payload shaping, wait/retry logic, and fabric operations.


# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
"""
ND Manage Fabric Config endpoint models.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is some overlap here with the fabric module endpoints so we should discuss consolidation and moving things like config-save and config-deploy to a more common location instead of under nd_manage_switches


from ansible_collections.cisco.nd.plugins.module_utils.nd_v2 import NDModule
from ansible_collections.cisco.nd.plugins.module_utils.enums import OperationType
from ansible_collections.cisco.nd.plugins.module_utils.nd_output import NDOutput
Copy link
Copy Markdown
Collaborator

@mikewiebe mikewiebe Mar 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes about NDOutput behavior from my discussion today

Don't worry about the control knobs for now. We can do that in a subsequent update.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the changes have been integrated. Query for "after " and performance control knob is being explored.

- C(merged) and C(query) are the only states supported for POAP.
- C(merged) is the only state supported for RMA.
type: str
default: merged
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed that it would be good to support state: gathered

This should follow the Ansible argspec and if used in a playbook with state overridden would result in no changes to the controller

This IMO can be a subsequent update to the module

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gathered is now supported in the module.

Comment on lines +174 to +175
- Please note that the existing switch should be configured and deployed in maintenance mode.
- Please note that the existing switch being replaced should be shutdown state or out of network.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These contradict each other a bit; I'll draft something to help reword.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have reworded this, please check and let me know if we need to change.

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.

4 participants