nd_fabric_prepare_update - ND 4.2 software staging#291
Open
allenrobel wants to merge 3 commits into
Open
Conversation
3c80477 to
67167cd
Compare
fc757df to
49a49b9
Compare
67167cd to
fbf128d
Compare
542a13f to
5f144b3
Compare
ae32c0e to
a9575ad
Compare
b06785f to
f5a5e6d
Compare
afbd34b to
8bb515f
Compare
f5a5e6d to
2ed1e9d
Compare
2ed1e9d to
7167190
Compare
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>
7167190 to
12e2301
Compare
There was a problem hiding this comment.
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_updatemodule with preflight mixed-role rejection, idempotency detection, and optional wait/poll-to-completion behavior. - Adds
FabricPrepareUpdateOrchestratorplus new Manage endpoint models forsoftwareUpdatePlan/summaryandsoftwareUpdatePlan/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)}") |
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)
N/A — new module.
Proposed Changes
nd_fabric_prepare_update— the Fabric Software Management "Prepare" step on Nexus Dashboard 4.2, i.e. thesoftwareUpdatePlan/actions/stageaction: stages and validates the configured image on the switches of one or more update groups.wait: truepolls to completion.FabricPrepareUpdateOrchestrator— drives the stage action and a poll loop that tolerates transient transport errors during the long wait.EpFabricSoftwareUpdatePlanStageandEpFabricSoftwareUpdatePlanSummary; Pydantic models for thesoftwareUpdatePlan/summaryresponse.Test Notes
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.ansible-test sanity --dockerpasses for all new/changed files.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
Checklist
🤖 Generated with Claude Code