added get_changes function .

This commit is contained in:
Shailaja Kumari 2024-06-11 06:40:43 +05:30
parent 4b476a8c3d
commit a4050ac521
Signed by untrusted user: shailaja
GPG Key ID: 2B9455CAFBC4D75A

View File

@ -152,7 +152,6 @@ response:
from ansible_collections.community.syncthing.plugins.module_utils.syncthing_api import SyncthingModule from ansible_collections.community.syncthing.plugins.module_utils.syncthing_api import SyncthingModule
from ansible_collections.community.syncthing.plugins.module_utils.common import get_changes from ansible_collections.community.syncthing.plugins.module_utils.common import get_changes
import json
def run_module(): def run_module():
module_args = dict( module_args = dict(
@ -185,17 +184,8 @@ def run_module():
module_args_keys_list = list(module_args.keys()) module_args_keys_list = list(module_args.keys())
changes = {} # Using get_changes function to determine what has changed
changes = get_changes(module.params, current_config)
for key, value in module.params.items():
# Check if the key is in module_args_keys_list
if key in module_args_keys_list:
# Check if the value is not None
if value is not None:
# Check if the value is different from the current_config
if not deep_equal(value, current_config.get(key)):
# If all conditions are met, add the key-value pair to changes
changes[key] = value
if module.check_mode or len(changes.keys()) == 0: if module.check_mode or len(changes.keys()) == 0:
module.result['device_defaults'] = current_config module.result['device_defaults'] = current_config