Skip to content

Commit 9595eea

Browse files
author
Shiva Shankar Vaddepally
committed
add check_mode case
Signed-off-by: Shiva Shankar Vaddepally <shivashankar.vaddepally@cloud.com>
1 parent dfc2207 commit 9595eea

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

plugins/module_utils/module_executor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,12 +212,13 @@ def return_success(self):
212212
# }
213213
if self.resource_name == "login":
214214
self.module_result["sessionid"] = self.sessionid
215-
if self.client._headers["Cookie"] != "":
215+
if self.client._headers.get("Cookie", None) not in (None, "") and not self.module.check_mode:
216216
ok, response = adc_logout(self.client)
217217
if not ok:
218218
log("ERROR: Logout failed: %s" % response)
219219
else:
220220
log("INFO: Logout successful")
221+
self.client._headers["Cookie"] = ""
221222
self.module.exit_json(**self.module_result)
222223

223224
@trace
@@ -241,7 +242,7 @@ def update_diff_list(self, existing=None, desired=None, delete=False, **kwargs):
241242

242243
@trace
243244
def return_failure(self, msg):
244-
if self.client._headers["Cookie"] != "":
245+
if self.client._headers["Cookie"] != "" and not self.module.check_mode:
245246
ok, response = adc_logout(self.client)
246247
if not ok:
247248
log("ERROR: Logout failed: %s" % response)

0 commit comments

Comments
 (0)