From bf5444ddaee62e773b517f523b2d796b8b378db3 Mon Sep 17 00:00:00 2001 From: Sumit Jaiswal Date: Thu, 19 Sep 2019 01:49:05 +0530 Subject: [PATCH] To fix delete to pass the right parameters wrt to Checkpoint modules (#62540) * fix delete to pass the right parameters (#62525) (cherry picked from commit 2232232b4525336ebebcb4cee683095a48ac2775) * changelog --- .../fragments/62525-fix-delete-to-pass-right-param.yaml | 3 +++ lib/ansible/module_utils/network/checkpoint/checkpoint.py | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/62525-fix-delete-to-pass-right-param.yaml diff --git a/changelogs/fragments/62525-fix-delete-to-pass-right-param.yaml b/changelogs/fragments/62525-fix-delete-to-pass-right-param.yaml new file mode 100644 index 00000000000..4dd51d15c88 --- /dev/null +++ b/changelogs/fragments/62525-fix-delete-to-pass-right-param.yaml @@ -0,0 +1,3 @@ +--- +bugfixes: +- "Fix delete to pass the right parameters(https://github.com/ansible/ansible/pull/62525)" diff --git a/lib/ansible/module_utils/network/checkpoint/checkpoint.py b/lib/ansible/module_utils/network/checkpoint/checkpoint.py index 6bd7306ff1b..01e78651eb8 100644 --- a/lib/ansible/module_utils/network/checkpoint/checkpoint.py +++ b/lib/ansible/module_utils/network/checkpoint/checkpoint.py @@ -48,6 +48,8 @@ checkpoint_argument_spec_for_commands = dict( version=dict(type='str') ) +delete_params = ['name', 'uid', 'layer', 'exception-group-name', 'layer', 'rule-name'] + # send the request to checkpoint def send_request(connection, version, url, payload=None): @@ -229,7 +231,8 @@ def api_call(module, api_call_object): result[api_call_object] = response elif module.params['state'] == 'absent': if equals_code == 200: - code, response = send_request(connection, version, 'delete-' + api_call_object, payload) + payload_for_delete = get_copy_payload_with_some_params(payload, delete_params) + code, response = send_request(connection, version, 'delete-' + api_call_object, payload_for_delete) if code != 200: module.fail_json(msg=response) @@ -399,7 +402,8 @@ def api_call_for_rule(module, api_call_object): result[api_call_object] = response elif module.params['state'] == 'absent': if equals_code == 200: - code, response = send_request(connection, version, 'delete-' + api_call_object, payload) + payload_for_delete = get_copy_payload_with_some_params(payload, delete_params) + code, response = send_request(connection, version, 'delete-' + api_call_object, payload_for_delete) if code != 200: module.fail_json(msg=response)