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

Adding DNAC log levels for Discovery and PnP #119

Merged
merged 3 commits into from
Jan 30, 2024

Conversation

abimishr
Copy link
Collaborator

Problem Description: Logging based on various levels (CRITICAL, ERROR, WARNING, INFO, DEBUG)
Fix: We have added dnac_log_levels
Test cases: Have tested for default (WARNING and DEBUG)
Results: 1. WARNING gives logs for WARNINGS, CRITICAL AND ERROR
2. DEBUG logs all the messages including CRITICAL, ERROR, WARNING and INFO as well.

@@ -721,7 +736,7 @@ def get_discovery_device_info(self, discovery_id=None, task_id=None):
)
devices = response.response

self.log(devices)
self.log("Devices Information retrieved from the get discovered network devices by discovery id API is {0}".format(str(devices)), "DEBUG")
Copy link
Owner

Choose a reason for hiding this comment

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

self.log("Retrieved device details using the API 'get_discovered_network_devices_by_discovery_id': {0}".format(str(devices)), "DEBUG")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved

self.module.fail_json(msg=msg)

self.log('Discovery network device with id {0} has not completed'.format(discovery_id), "INFO")
Copy link
Owner

Choose a reason for hiding this comment

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

if not result, we set the msg with same message (line num: 751) and if the result is true then also we see the same message. Can you please check it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for pointing it. Resolved

@@ -777,8 +794,9 @@ def delete_exist_discovery(self, params):
params=params,
)

self.log(response)
self.log("Response collected from delete discovery by id API is {0}".format(str(response)), "DEBUG")
Copy link
Owner

Choose a reason for hiding this comment

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

self.log("Response collected from API 'delete_discovery_by_id': {0}".format(str(response)), "DEBUG")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved

self.module.fail_json(msg="Site not found", response=[])

if response:
self.log(str(response))
self.log("Site details of {0} received are {1}".format(self.want.get("site_name"), str(response)), "DEBUG")
Copy link
Owner

Choose a reason for hiding this comment

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

self.log("Received site details for '{0}': {1}".format(self.want.get("site_name"), str(response)), "DEBUG")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved

site = response.get("response")
if len(site) == 1:
site_id = site[0].get("id")
site_exists = True
self.log("Site Id is {0} and site name is {1}".format(site_id, self.want.get("site_name")), "INFO")
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 say
self.log("Site Name: {1}, Site ID: {0}".format(site_id, self.want.get("site_name")), "INFO")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved

@@ -865,7 +908,7 @@ class instance for further use.
"payload": update_payload},
op_modifies=True,
)
self.log(str(update_response))
self.log("Update in the device's config API response is {0}".format(str(update_response)), "DEBUG")
Copy link
Owner

Choose a reason for hiding this comment

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

self.log("Response from 'update_device' API for device's config update: {0}".format(str(update_response)), "DEBUG")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved

@@ -875,8 +918,9 @@ class instance for further use.
params={"payload": reset_paramters},
op_modifies=True,
)
self.log(str(reset_response))
self.log("Errored state resolution response from the API is {0}".format(str(reset_response)), "DEBUG")
Copy link
Owner

Choose a reason for hiding this comment

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

self.log("Response from 'update_device' API for errored state resolution: {0}".format(str(reset_response)), "DEBUG")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved

if update_response.get("deviceInfo"):
self.result['changed'] = True
return self

claim_params = self.get_claim_params()
self.log(str(claim_params))
self.log("Paramters for claiming the device are {0}".format(str(claim_params)), "DEBUG")
Copy link
Owner

Choose a reason for hiding this comment

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

self.log("Parameters for claiming the device: {0}".format(str(claim_params)), "DEBUG")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved

@@ -934,7 +980,7 @@ def get_diff_deleted(self):
function='get_device_list',
params={"serial_number": device["deviceInfo"]["serialNumber"]}
)

self.log("Device details for the serial number {0} are {1}".format(device["deviceInfo"]["serialNumber"], str(multi_device_response)), "DEBUG")
Copy link
Owner

Choose a reason for hiding this comment

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

self.log("Response from 'claim_a_device_to_a_site' API for claiming: {0}".format(str(claim_response)), "DEBUG")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved

@@ -945,22 +991,26 @@ def get_diff_deleted(self):
params={"id": device_id},
)

self.log(str(response))
self.log("Device details for the device deleted with \
Copy link
Owner

Choose a reason for hiding this comment

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

self.log("Device details for the deleted device with serial number '{0}': {1}".format(device["deviceInfo"]["serialNumber"], str(response)), "DEBUG")

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Resolved

@madhansansel madhansansel merged commit 509fb77 into madhansansel:main Jan 30, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants