Skip to content

Commit

Permalink
Bug fixed for the AP - PNP devices
Browse files Browse the repository at this point in the history
  • Loading branch information
md-rafeek committed Nov 13, 2024
1 parent 5fe1559 commit d587688
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions plugins/modules/pnp_workflow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ def validate_input(self):
)

if invalid_params:
self.msg = "Invalid parameters in playbook: {0}".format(
"\n".join(invalid_params))
self.msg = "Invalid parameters in playbook: {0}".format("\n".join(invalid_params))
self.log(str(self.msg), "ERROR")
self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status()

Expand Down Expand Up @@ -464,31 +463,26 @@ def get_site_type(self):
self.log("Received site details for '{0}': {1}".format(self.want.get("site_name"),
str(response)), "DEBUG")
site = response.get("response")
site_additional_info = site[0].get("additionalInfo")
site_type = None
for item in site_additional_info:
if item["nameSpace"] == "Location":
site_type = item.get("attributes").get("type")
self.log("Site type for site name '{1}' : {0}".
format(site_type, self.want.get("site_name")), "INFO")

if self.compare_dnac_versions(self.get_ccc_version(), "2.3.5.3") <= 0:
site_additional_info = site[0].get("additionalInfo")
for item in site_additional_info:
if item["nameSpace"] == "Location":
site_type = item.get("attributes").get("type")
self.log("Site type for site name '{1}' : {0}".
format(site_type, self.want.get("site_name")), "INFO")
else:
site_type = site[0].get("type")
self.log("Site type for site name '{1}' : {0}".
format(site_type, self.want.get("site_name")), "INFO")

return site_type
except Exception:
self.msg = "Exception occurred as site '{0}' was not found".format(self.want.get("site_name"))
self.log(self.msg, "CRITICAL")
self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status()

if response:
self.log("Received site details for '{0}': {1}".format(self.want.get("site_name"),
str(response)), "DEBUG")
site = response.get("response")
site_additional_info = site[0].get("additionalInfo")
for item in site_additional_info:
if item["nameSpace"] == "Location":
site_type = item.get("attributes").get("type")
self.log("Site type for site name '{1}' : {0}".format(site_type, self.want.get("site_name")), "INFO")

return site_type

def get_pnp_params(self, params):
"""
Store pnp parameters from the playbook for pnp processing in Cisco Catalyst Center.
Expand Down Expand Up @@ -785,8 +779,7 @@ def get_have(self):
template_name = self.want.get("template_name")
if template_name:
if not (template_list and isinstance(template_list, list)):
self.msg = "Either project not found"\
" or it is Empty."
self.msg = "Either project not found or it is Empty."
self.log(self.msg, "CRITICAL")
self.set_operation_result("failed", False, self.msg, "ERROR").check_return_status()

Expand Down

0 comments on commit d587688

Please sign in to comment.