CiscoDevNet / ansible-dcnm

Apache License 2.0
47 stars 37 forks source link

dcnm_image_policy: fix for issue #347 #348

Open allenrobel opened 5 days ago

allenrobel commented 5 days ago

Summary

The dcnm_image_policy module was not handling overridden state correctly.

It was correctly deleting image policies that were not in the playbook, but it was merging image policy configurations from the playbook with the image policy configurations on the controller. It should have been REPLACING these configurations.

Fix

This PR addresses this by modifying the Overridden() class within dcnm_image_policy.py to call Replaced().commit() rather than Merged().commit().

No changes are required for unit tests since the individual support modules are all doing what they are supposed to do. The only issue here was that dcnm_image_policy.py (main module) was instantiating, and calling commit() on, the wrong class.

Other changes

  1. Updated dcnm_image_policy integration test.

a. For overridden state, added a packages dictionary to the created image policy's configuration (this adds packageName and rpmimages to the image policy).

b. Added verifications that the task for overridden state removes packageName and rpmimages from the image policy.

c. Updated asserts for metadata to verify that metadata.action is "replace" rather than "update"

Closes

Closes issue #347