Add shared module utility support - #294
Conversation
sivakasi-cisco
left a comment
There was a problem hiding this comment.
Addressed your comments.
For the comment on data.py and utils.py files, I can combine them if required.
You can consider the latest changes for review and subsequent approval.
sivakasi-cisco
left a comment
There was a problem hiding this comment.
Resolved the comments
Code reviewFound 4 issues:
ansible-nd/plugins/module_utils/nd_state_machine.py Lines 217 to 221 in 28f6cdc
ansible-nd/plugins/module_utils/utils.py Lines 32 to 43 in 28f6cdc
ansible-nd/plugins/module_utils/utils.py Lines 52 to 64 in 28f6cdc
ansible-nd/plugins/module_utils/utils.py Lines 38 to 43 in 28f6cdc 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
Reply: Fixed — only items actually pushed are marked as sent now, so check-mode and skipped/failed items no longer trigger a deploy.
Reply: Added tests/unit/module_utils/test_utils.py covering 'issubset' and 'get_diff'
Reply:: As the dict comparison ignores 'None' keys it was not strict ==. Corrected the docstring now.
|
|
High: PRs #281 and #360 require semantic conflict reconciliation after #294 “Conflict reconciliation” means manually combining both PRs’ behaviors after #294 merges. Selecting Git’s entire “ours” or “theirs” version would break one side. Currently, PR #281 already conflicts with PR #360Both PRs modify
The combined implementation needs both: def get_diff(
self,
other,
exclude_unset=False,
allow_superset=False,
):
self_data = self.to_diff_dict()
other_data = other.to_diff_dict(exclude_unset=exclude_unset)
is_subset = issubset(
other_data,
self_data,
allow_superset=allow_superset,
)
if is_subset and exclude_unset and self.merge_would_change(other):
return False
return is_subsetKeep #360’s Taking only #294 would lose storm-control transition detection. Taking only #360 would remove The combined tests should prove that:
PR #281PR #281 conflicts in three shared files and also has semantic overlaps that Git may auto-merge incorrectly.
|
…_files # Conflicts: # plugins/module_utils/models/base.py
|
Have tested the nd_vrf_lite module with the latest changes in #294. |
- Drop default=[] on nd_manage_networks config so an omitted value stays None instead of being coerced into an empty list - Add NDStateMachine.validate_config_presence and call it on the raw config (before normalization) in the network coordinator and the vpc_pair wrapper, plus in the state machine itself - Explicit config: [] still works for intentional delete-all under overridden - Fix PrefixListModel.get_diff to accept exclude_unset/allow_superset so it matches the shared NDBaseModel signature used by NDConfigCollection - Add composed wrapper tests covering omitted/null/explicit-empty config (overridden, check mode, existing resources) and a get_diff regression
1b14547 to
d22cf55
Compare
d22cf55 to
e7d2363
Compare
|
Hi Mike, This is really helpful with the integration order. For PR294 - the current one - base merged to 'develop' branch. Now the combined version of base.py is below with allow_superset and merge_would_change. self_data = self.to_diff_dict() Both #294 and #360 touch NDBaseModel.get_diff() #294 added allow_superset for list comparison |
e7a8938
…-core 2.19 ansible-core 2.19 requires a non-empty _ANSIBLE_PROFILE to decode _ANSIBLE_ARGS when constructing AnsibleModule. Patch _ANSIBLE_PROFILE="legacy" (create=True) in the composed-module tests so they pass on 2.19 while staying compatible with 2.18.
allenrobel
left a comment
There was a problem hiding this comment.
Code review
Fresh pass over the current head (my June review was dismissed by subsequent pushes). One behavioral concern with check-mode sent tracking and two type-annotation notes, each as an inline comment.
🤖 Generated with Claude Code
allenrobel
left a comment
There was a problem hiding this comment.
LGTM after comments addressed.
Related Issue(s)
Fixes #450
Problem Description
This PR separates out a few shared framework changes that are needed before modules like
nd_manage_vrf_litecan cleanly follow the generic ND 4.x module architecture - #281.Some ND 4.x resources are simple: one playbook item maps directly to one controller object. In those cases, the existing generic state machine can compare “what the user wants” with “what exists on the controller” and decide create, update, delete, or no-op.
But some resources are nested. VRF Lite is a good example: the user gives VRF-level config, but the actual work happens under smaller child objects like VRF attachments and VRF Lite links. Without small shared framework improvements, each nested module has to write its own custom comparison logic.
This PR adds the common support needed for that style of module.
Why These Common Changes Are Needed
This PR updates the common state machine and utility logic used by the VRF Lite workflow.
The main change is to make
mergedstate behave correctly when the controller already has extra data that the user did not provide in the playbook. In that case, the module should not report a change just because existing data has additional fields.This PR also tracks deleted items in the state machine, so follow-up actions like config save and deploy can know which VRFs were changed by a delete operation.