salt-ext-modules-vmware
salt-ext-modules-vmware copied to clipboard
Use dictdiffer for state returns
Getting the entire "old" and "new" returns is... excessive, most of the time we don't care about every attribute, just those that change.
If we change https://github.com/saltstack/salt-ext-modules-vmware/blob/7cdff88d4e052e6bb222fd7d8e9800f941e1aca8/src/saltext/vmware/utils/vmc_state.py#L13
to
"changes": dictdiffer.deep_diff(old_state or {}, new_state or {}) if old_state or new_state else {},
That would be a pretty massive improvement. If we wanted to add a verbose
flag or something, that would be OK. But the default shouldn't include everything.
Here's an example:
ID: Make a Cool Firewall
Function: vmc_distributed_firewall_rules.present
Name: Some_Cool_Firewall_Rule_37
Result: True
Comment: Updated distributed firewall rule Some_Cool_Firewall_Rule_37
Started: 23:21:52.370356
Duration: 8207.019 ms
Changes:
----------
new:
----------
_last_modified_time:
1649132471953
_revision:
4
disabled:
True
old:
----------
_last_modified_time:
1649131338392
_revision:
3
disabled:
False
tags:
None
(though, I'd probably even pass in an ignore of ['_last_modified_time', '_revision']
in that case. Also kinda looks like tags should be returned from the module always :thinking: Or removed if it's None)