Skip to content

Commit 616ee6f

Browse files
Merge pull request #548 from netscaler/NSHELP-40733_sslcertfile
NSHELP-40733 sslcertfile module – Importing a new SSL certificate fai…
2 parents 0e84bac + 6beaef8 commit 616ee6f

3 files changed

Lines changed: 43 additions & 12 deletions

File tree

plugins/module_utils/constants.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,19 @@
135135
'cacheglobal_cachepolicy_binding',
136136
'botglobal_botpolicy_binding',
137137
]
138+
139+
GETALL_ONLY_RESOURCES = [
140+
'appfwlearningdata',
141+
'application',
142+
'bridgetable',
143+
'gslbldnsentry',
144+
'locationfile',
145+
'locationfile6',
146+
'routerdynamicrouting',
147+
'sslcertbundle',
148+
'sslcertfile',
149+
'sslcrlfile',
150+
'ssldhfile',
151+
'sslkeyfile',
152+
'systementitydata'
153+
]

plugins/module_utils/module_executor.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
HTTP_RESOURCE_ALREADY_EXISTS,
3939
NETSCALER_COMMON_ARGUMENTS,
4040
NITRO_ATTRIBUTES_ALIASES,
41+
GETALL_ONLY_RESOURCES,
4142
)
4243
from .decorators import trace
4344
from .logger import log, loglines
@@ -321,17 +322,31 @@ def get_existing_resource(self):
321322
if is_exist is False:
322323
return {}
323324
if len(existing_resource) > 1:
324-
msg = (
325-
"ERROR: For resource `%s` Found more than one resource with the same primary key `%s` and resource_module_params %s"
326-
% (
327-
self.resource_name,
328-
self.resource_id,
329-
self.resource_module_params,
325+
if self.resource_name in GETALL_ONLY_RESOURCES:
326+
for resources in existing_resource:
327+
# Check if all module params match this resource
328+
match_found = True
329+
for key, value in self.resource_module_params.items():
330+
if key in resources and resources[key] != value:
331+
match_found = False
332+
break
333+
334+
# If all parameters match, use this resource
335+
if match_found:
336+
self.existing_resource = resources
337+
break
338+
else:
339+
msg = (
340+
"ERROR: For resource `%s` Found more than one resource with the same primary key `%s` and resource_module_params %s"
341+
% (
342+
self.resource_name,
343+
self.resource_id,
344+
self.resource_module_params,
345+
)
330346
)
331-
)
332-
self.return_failure(msg)
333-
334-
self.existing_resource = existing_resource[0]
347+
self.return_failure(msg)
348+
else:
349+
self.existing_resource = existing_resource[0]
335350

336351
if self.resource_name in NITRO_ATTRIBUTES_ALIASES:
337352
self.existing_resource = self._add_nitro_attributes_aliases(

tools/migrationtool/convert_yaml.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ def get_task_level_keys(task_data, verbose):
8686
def get_cred_attributes(plugindata, verbose):
8787
logincreds = {}
8888
if verbose:
89-
print(f"getting nitro credentials")
89+
print("getting nitro credentials")
9090
try:
9191
for key in netscaler_login_specifics:
9292
if key in plugindata:
@@ -227,7 +227,7 @@ def convert_yaml_file(input_file, output_file, template_file, verbose):
227227
print(f"Error occurred during conversion: {e}")
228228
return
229229
print(f"Output written to: {output_file}")
230-
print(f"YAML conversion completed")
230+
print("YAML conversion completed")
231231

232232

233233
def main():

0 commit comments

Comments
 (0)