Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1 Bug Fix - Network Compliance Module #273

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion plugins/modules/network_compliance_workflow_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,10 @@ def get_device_ids_from_ip(self, ip_address_list):
except Exception as e:
# Log an error message if any exception occurs during the process
self.log("Error while fetching device ID for device: '{0}' from Cisco Catalyst Center: {1}".format(device_ip, str(e)), "ERROR")
if not mgmt_ip_instance_id_map:
self.msg = "Reachable devices not found in the IP Address List: {0}".format(ip_address_list)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we split the ip addresses using .join ? Can you check in our code?

    formatted_ip_list = ', '.join(ip_address_list)
    self.msg = "No reachable devices found among the provided IP addresses: [{}]".format(formatted_ip_list)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will address this in the next PR.

self.update_result("ok", False, self.msg, "INFO")
self.module.exit_json(**self.result)

return mgmt_ip_instance_id_map

Expand Down Expand Up @@ -671,6 +675,11 @@ def get_device_ids_from_site(self, site_name, site_id):
# Log an error message if any exception occurs during the process
self.log("Unable to fetch the device(s) associated to the site '{0}' due to {1}".format(site_name, str(e)), "ERROR")

if not mgmt_ip_instance_id_map:
self.msg = "Reachable devices not found at Site: {0}".format(site_name)
rukapse marked this conversation as resolved.
Show resolved Hide resolved
self.update_result("ok", False, self.msg, "INFO")
self.module.exit_json(**self.result)

return mgmt_ip_instance_id_map

def get_device_id_list(self, ip_address_list, site_name):
Expand Down Expand Up @@ -834,7 +843,7 @@ def get_want(self, config):
required, self.msg, categorized_devices = self.is_sync_required(compliance_details, mgmt_ip_instance_id_map)
self.log("Is Sync Requied: {0} {1}".format(required, self.msg), "DEBUG")
if not required:
self.update_result("success", False, self.msg, "INFO")
self.update_result("ok", False, self.msg, "INFO")
self.module.exit_json(**self.result)

# Get the device IDs of devices in the "OTHER" category and "COMPLIANT" category
Expand Down