Skip to content

Commit 0179fa7

Browse files
Merge pull request #535 from netscaler/nitro_token
Resolving error of early logout when token login is used
2 parents e902351 + 88f8208 commit 0179fa7

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

plugins/module_utils/client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ def __init__(self, module, resource_name):
3838
self._module.params.get("nitro_user"),
3939
self._module.params.get("nitro_pass"),
4040
)
41-
4241
# Prioritize token over user/pass
4342
if have_token:
4443
self._headers["Cookie"] = (

plugins/module_utils/module_executor.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,16 @@ def __init__(self, resource_name, supports_check_mode=True):
9090
argument_spec=argument_spec,
9191
supports_check_mode=supports_check_mode,
9292
mutually_exclusive=[
93+
(
94+
"nitro_pass", "nitro_auth_token"
95+
),
9396
(
9497
"managed_netscaler_instance_name",
9598
"managed_netscaler_instance_ip",
9699
"managed_netscaler_instance_id",
97100
),
98101
],
99102
required_together=[
100-
("nitro_user", "nitro_pass"),
101103
(
102104
"managed_netscaler_instance_username",
103105
"managed_netscaler_instance_password",
@@ -143,7 +145,7 @@ def __init__(self, resource_name, supports_check_mode=True):
143145
"logout",
144146
}:
145147
self.module.params["api_path"] = "nitro/v2/config"
146-
148+
self.have_token = self.module.params.get("nitro_auth_token", None)
147149
self.client = NitroAPIClient(self.module, self.resource_name)
148150
have_userpass = all([
149151
self.module.params.get("nitro_user"),
@@ -219,7 +221,7 @@ def return_success(self):
219221
# }
220222
if self.resource_name == "login":
221223
self.module_result["sessionid"] = self.sessionid
222-
if self.client._headers.get("Cookie", None) not in (None, "") and not self.module.check_mode:
224+
if self.client._headers.get("Cookie", None) not in (None, "") and not self.module.check_mode and not self.have_token:
223225
ok, response = adc_logout(self.client)
224226
if not ok:
225227
log("ERROR: Logout failed: %s" % response)
@@ -249,7 +251,7 @@ def update_diff_list(self, existing=None, desired=None, delete=False, **kwargs):
249251

250252
@trace
251253
def return_failure(self, msg):
252-
if self.client._headers["Cookie"] != "" and not self.module.check_mode:
254+
if self.client._headers.get("Cookie", None) not in (None, "") and not self.module.check_mode and not self.have_token:
253255
ok, response = adc_logout(self.client)
254256
if not ok:
255257
log("ERROR: Logout failed: %s" % response)

0 commit comments

Comments
 (0)