Skip to content

Commit f12bda0

Browse files
Merge pull request #539 from netscaler/dnsglob
correcting GET url in global binding to include queryparameter args with type
2 parents 1442475 + 6e73201 commit f12bda0

2 files changed

Lines changed: 37 additions & 5 deletions

File tree

plugins/module_utils/common.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
HTTP_RESOURCE_ALREADY_EXISTS,
1414
HTTP_RESOURCE_NOT_FOUND,
1515
HTTP_SUCCESS_CODES,
16+
GLOBAL_BINDING_ARG_LIST
1617
)
1718
from .decorators import trace
1819
from .logger import log
@@ -61,11 +62,21 @@ def get_resource(client, resource_name, resource_id=None, resource_module_params
6162

6263
if resource_name.endswith("_binding"):
6364
# binding resources require `filter` instead of `args` to uniquely identify a resource
64-
status_code, response_body = client.get(
65-
resource=resource_name,
66-
id=resource_id,
67-
filter=get_args,
68-
)
65+
if resource_name in GLOBAL_BINDING_ARG_LIST:
66+
# here we are making sure that for globalbindings present in the list query params args=type and filter=get_arg_keys
67+
del get_args["type"]
68+
status_code, response_body = client.get(
69+
resource=resource_name,
70+
id=resource_id,
71+
filter=get_args,
72+
args={"type": resource_module_params["type"]},
73+
)
74+
else:
75+
status_code, response_body = client.get(
76+
resource=resource_name,
77+
id=resource_id,
78+
filter=get_args,
79+
)
6980
elif resource_name in {"sslcertfile"}:
7081
status_code, response_body = client.get(
7182
resource=resource_name,

plugins/module_utils/constants.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,3 +114,24 @@
114114
fallback=(env_fallback, ["MANAGED_NETSCALER_INSTANCE_PASSWORD"]),
115115
),
116116
)
117+
118+
# this list contains globalbindings whose GET call must have query params args=type and filter=get_arg_keys (check in nitro_resource_map)
119+
GLOBAL_BINDING_ARG_LIST = [
120+
'dnsglobal_dnspolicy_binding',
121+
'responderglobal_responderpolicy_binding',
122+
'contentinspectionglobal_contentinspectionpolicy_binding',
123+
'appflowglobal_appflowpolicy_binding',
124+
'appfwglobal_auditnslogpolicy_binding',
125+
'appfwglobal_auditsyslogpolicy_binding',
126+
'appfwglobal_appfwpolicy_binding',
127+
'rewriteglobal_rewritepolicy_binding',
128+
'transformglobal_transformpolicy_binding',
129+
'sslglobal_sslpolicy_binding',
130+
'tunnelglobal_tunneltrafficpolicy_binding',
131+
'cmpglobal_cmppolicy_binding',
132+
'feoglobal_feopolicy_binding',
133+
'icaglobal_icapolicy_binding',
134+
'lbglobal_lbpolicy_binding',
135+
'cacheglobal_cachepolicy_binding',
136+
'botglobal_botpolicy_binding',
137+
]

0 commit comments

Comments
 (0)