Skip to content

nd_fabric_prepare_update - ND 4.2 software staging#291

Open
allenrobel wants to merge 3 commits into
developfrom
nd_fabric_prepare_update
Open

nd_fabric_prepare_update - ND 4.2 software staging#291
allenrobel wants to merge 3 commits into
developfrom
nd_fabric_prepare_update

Conversation

@allenrobel

Copy link
Copy Markdown
Collaborator

Stacked PR. Base branch is nd_fabric_update_group (per the stack); retarget to develop once the parent merges.

Related Issue(s)

N/A — new module.

Proposed Changes

  • New module nd_fabric_prepare_update — the Fabric Software Management "Prepare" step on Nexus Dashboard 4.2, i.e. the softwareUpdatePlan/actions/stage action: stages and validates the configured image on the switches of one or more update groups.
  • One-shot action module: pre-flight check rejects mixed-role update groups (ND will not prepare them), idempotent against already-staged groups, and with wait: true polls to completion.
  • FabricPrepareUpdateOrchestrator — drives the stage action and a poll loop that tolerates transient transport errors during the long wait.
  • New endpoint models EpFabricSoftwareUpdatePlanStage and EpFabricSoftwareUpdatePlanSummary; Pydantic models for the softwareUpdatePlan/summary response.
  • 33 unit tests (orchestrator + models) and an integration test target.

Test Notes

  • Unit: python -m pytest tests/unit/module_utils/models/test_fabric_prepare_update.py tests/unit/module_utils/orchestrators/test_fabric_prepare_update.py — 33 pass.
  • Sanity: ansible-test sanity --docker passes for all new/changed files.
  • Integration: ansible-test integration nd_fabric_prepare_update — green against a live ND 4.2.1 lab (fabric SITE1), covering mixed-role pre-flight rejection, check mode, a real stage + wait, and idempotency.

Cisco Nexus Dashboard Version

4.2.1

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

🤖 Generated with Claude Code

@allenrobel allenrobel force-pushed the nd_fabric_update_group branch from 3c80477 to 67167cd Compare May 21, 2026 19:41
@allenrobel allenrobel force-pushed the nd_fabric_prepare_update branch from fc757df to 49a49b9 Compare May 21, 2026 19:41
@allenrobel allenrobel changed the title Add nd_fabric_prepare_update module for ND 4.2 software staging nd_fabric_prepare_update - ND 4.2 software staging May 27, 2026
@allenrobel allenrobel force-pushed the nd_fabric_update_group branch from 67167cd to fbf128d Compare May 28, 2026 17:34
@allenrobel allenrobel force-pushed the nd_fabric_prepare_update branch 2 times, most recently from 542a13f to 5f144b3 Compare May 28, 2026 18:16
@allenrobel allenrobel force-pushed the nd_fabric_update_group branch from ae32c0e to a9575ad Compare June 1, 2026 19:29
@allenrobel allenrobel force-pushed the nd_fabric_prepare_update branch 5 times, most recently from b06785f to f5a5e6d Compare June 4, 2026 18:18
@allenrobel allenrobel force-pushed the nd_fabric_update_group branch from afbd34b to 8bb515f Compare June 4, 2026 20:42
@allenrobel allenrobel force-pushed the nd_fabric_prepare_update branch from f5a5e6d to 2ed1e9d Compare June 4, 2026 20:42
Base automatically changed from nd_fabric_update_group to develop June 8, 2026 23:45
@allenrobel allenrobel force-pushed the nd_fabric_prepare_update branch from 2ed1e9d to 7167190 Compare June 9, 2026 00:04
allenrobel and others added 3 commits June 12, 2026 17:21
Implements the Fabric Software Management "Prepare" step on Nexus
Dashboard 4.2 - the softwareUpdatePlan/actions/stage action - which
stages and validates the configured image on the switches of one or
more update groups.

- New module nd_fabric_prepare_update: a one-shot action module that
  pre-flight checks for mixed-role update groups, is idempotent against
  already-staged groups, and (with wait) polls to completion.
- FabricPrepareUpdateOrchestrator: drives the stage action and a poll
  loop that tolerates transient transport errors during the long wait.
- EpFabricSoftwareUpdatePlanStage and EpFabricSoftwareUpdatePlanSummary
  endpoint models; softwareUpdatePlan/summary response models.
- 33 unit tests (orchestrator + models) and an integration test target.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
preflight_role_check and status_snapshot each fetched
softwareUpdatePlan/summary independently, so a prepare run made two
identical GETs back-to-back at startup. Both now accept an optional
pre-fetched summary; _run_prepare fetches it once and passes it to both.

Startup now costs one summary GET instead of two (check mode included),
and the role check and `before` snapshot observe the same point-in-time
summary. Adds test_fabric_prepare_update_00220 asserting a single GET
across the three startup calls.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 13, 2026 03:28
@allenrobel allenrobel force-pushed the nd_fabric_prepare_update branch from 7167190 to 12e2301 Compare June 13, 2026 03:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a new one-shot Ansible module to drive Nexus Dashboard 4.2 “Prepare” (stage + validate) for one or more fabric software update groups, including a dedicated orchestrator, endpoint models, response parsing models, and test coverage.

Changes:

  • Introduces nd_fabric_prepare_update module with preflight mixed-role rejection, idempotency detection, and optional wait/poll-to-completion behavior.
  • Adds FabricPrepareUpdateOrchestrator plus new Manage endpoint models for softwareUpdatePlan/summary and softwareUpdatePlan/actions/stage.
  • Adds unit tests (orchestrator + models), fixtures, and an integration test target.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/unit/module_utils/orchestrators/test_fabric_prepare_update.py Unit tests covering orchestrator preflight, stage call, idempotency snapshot logic, and polling behavior.
tests/unit/module_utils/models/test_fabric_prepare_update.py Unit tests validating Pydantic parsing/aliasing for the summary response models.
tests/unit/module_utils/fixtures/fixture_data/test_fabric_prepare_update.json Fixture responses for summary/stage workflows and polling scenarios.
tests/integration/targets/nd_fabric_prepare_update/vars/main.yaml Integration test variables for real ND 4.2.1 fabric + switches + image name.
tests/integration/targets/nd_fabric_prepare_update/tasks/setup.yaml Creates prerequisite update groups (single-role and mixed-role) for integration tests.
tests/integration/targets/nd_fabric_prepare_update/tasks/prepare.yaml Executes prepare module scenarios (mixed-role rejection, check mode, real stage+wait, idempotency).
tests/integration/targets/nd_fabric_prepare_update/tasks/main.yaml Integration test harness with module defaults/timeouts and setup/cleanup blocks.
tests/integration/targets/nd_fabric_prepare_update/tasks/cleanup.yaml Removes created update groups after test run.
tests/integration/targets/nd_fabric_prepare_update/meta/main.yml Declares integration target metadata (no dependencies).
plugins/modules/nd_fabric_prepare_update.py New module implementing prepare/stage workflow and documentation/examples.
plugins/module_utils/orchestrators/fabric_prepare_update.py Orchestrator implementing summary fetch, preflight checks, stage action, and poll loop with transient-failure tolerance.
plugins/module_utils/models/fabric_prepare_update/software_update_plan_summary.py Pydantic models for softwareUpdatePlan/summary response parsing.
plugins/module_utils/models/fabric_prepare_update/init.py Package init for the new model namespace.
plugins/module_utils/endpoints/v1/manage/software_update_plan_summary.py New endpoint model for GET summary.
plugins/module_utils/endpoints/v1/manage/software_update_plan_actions.py Adds endpoint model for POST stage action.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +390 to +391
deadline = time.monotonic() + max(timeout, 0)
consecutive_failures = 0
Comment on lines +99 to +102
wait: true
wait_timeout: 3600
wait_interval: 60
state: merged
Comment on lines +199 to +203
try:
result = _run_prepare(module)
module.exit_json(**result)
except Exception as e:
module.fail_json(msg=f"Module execution failed: {str(e)}")
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