You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NDStateMachine modules never populate diff or logs in module output despite documenting them #530
Every NDStateMachine-backed (Gen-3) module returns diff: [] and — at output_level: debug — logs: [], unconditionally. Neither key is ever populated, yet 24 modules document diff as returned: always with a populated sample, and 19 document logs. Surfaced by review of #403 (thread #403 (comment)), but it is a framework gap, not a module one.
Root cause
NDStateMachine only ever calls self.output.assign(after=..., before=..., proposed=...) (nd_state_machine.py:85) and later assign(after=...). It never passes diff or logs.
NDOutput.format() computes changed by comparing before and after (get_diff_collection) but does not derive a diff from the same comparison; it emits self._diff, which stays at its [] default.
Nothing in module_utils collects log records into a list: common/log.py only permits file handlers, so NDOutput._logs has no producer.
diff= has never been assigned since the initial ND 4.2 state-machine commit (git log -S"diff=" on nd_state_machine.py).
The only diff that exists today is API-level: Results stores a per-call diff that format_with_verbosity() surfaces as api_diff at -vvv. That is the payload sent, not a before/after config diff.
Scope
25 modules construct NDStateMachine (the nd_interface_* family, nd_manage_fabric_*, nd_local_user, nd_maintenance_mode, nd_manage_vpc_pair, nd_manage_policy_group, ...). Five of them do not document diff at all; the rest promise it.
Related
ND module's result output mismatch #304 — output-consistency discussion. The resource-manager module populates diff in the cisco.dcnm shape ({merged, deleted, gathered, debugs}), so the collection currently has two conventions: dcnm-style vs. empty. The shape decision belongs to ND module's result output mismatch #304; this issue is about the state-machine layer never producing one at all.
Derive diff in NDOutput.format() alongside changed, from before/after using the existing identifier/get_diff_config machinery: one entry per identifier that is new, removed, or changed. Ansible's native shape — a list of {"before": {...}, "after": {...}, "before_header": "<identifier>", "after_header": "<identifier>"} — makes ansible-playbook --diff render it for free; if ND module's result output mismatch #304 settles on the dcnm shape instead, the same comparison feeds that.
logs: either attach a small in-memory logging.Handler to the nd logger when output_level == debug and hand its records to assign(logs=...), or remove the key from the documentation. The handler is ~20 lines and delivers what the docs already promise.
Unit tests in test_nd_output.py for create / update / delete / no-change diff shapes, and a state-machine test asserting diff is non-empty on a changed merged run.
Summary
Every
NDStateMachine-backed (Gen-3) module returnsdiff: []and — atoutput_level: debug—logs: [], unconditionally. Neither key is ever populated, yet 24 modules documentdiffasreturned: alwayswith a populated sample, and 19 documentlogs. Surfaced by review of #403 (thread #403 (comment)), but it is a framework gap, not a module one.Root cause
NDStateMachineonly ever callsself.output.assign(after=..., before=..., proposed=...)(nd_state_machine.py:85) and laterassign(after=...). It never passesdifforlogs.NDOutput.format()computeschangedby comparingbeforeandafter(get_diff_collection) but does not derive a diff from the same comparison; it emitsself._diff, which stays at its[]default.module_utilscollects log records into a list:common/log.pyonly permits file handlers, soNDOutput._logshas no producer.diff=has never been assigned since the initial ND 4.2 state-machine commit (git log -S"diff="onnd_state_machine.py).The only diff that exists today is API-level:
Resultsstores a per-calldiffthatformat_with_verbosity()surfaces asapi_diffat-vvv. That is the payload sent, not a before/after config diff.Scope
25 modules construct
NDStateMachine(thend_interface_*family,nd_manage_fabric_*,nd_local_user,nd_maintenance_mode,nd_manage_vpc_pair,nd_manage_policy_group, ...). Five of them do not documentdiffat all; the rest promise it.Related
diffin the cisco.dcnm shape ({merged, deleted, gathered, debugs}), so the collection currently has two conventions: dcnm-style vs. empty. The shape decision belongs to ND module's result output mismatch #304; this issue is about the state-machine layer never producing one at all.nd_output.pyand already gatesdiffemission on "final state provable". A fix here should land on top of (or inside) that work rather than collide with it.Suggested direction
diffinNDOutput.format()alongsidechanged, frombefore/afterusing the existing identifier/get_diff_configmachinery: one entry per identifier that is new, removed, or changed. Ansible's native shape — a list of{"before": {...}, "after": {...}, "before_header": "<identifier>", "after_header": "<identifier>"}— makesansible-playbook --diffrender it for free; if ND module's result output mismatch #304 settles on the dcnm shape instead, the same comparison feeds that.logs: either attach a small in-memorylogging.Handlerto thendlogger whenoutput_level == debugand hand its records toassign(logs=...), or remove the key from the documentation. The handler is ~20 lines and delivers what the docs already promise.test_nd_output.pyfor create / update / delete / no-change diff shapes, and a state-machine test assertingdiffis non-empty on a changed merged run.Cisco Nexus Dashboard Version
4.2.1 (behavior is controller-independent)