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

Resolved the previous PR comments and have added single addition in P… #48

Merged
merged 4 commits into from
Nov 9, 2023

Conversation

abimishr
Copy link
Collaborator

@abimishr abimishr commented Nov 7, 2023

Problem description: Adding single device in PnP
Fix: Single addition is possible with add_device_method in the playbook
Design consideration: Device is not added
Testing Information: Tested with multiple scenarios and have also added idempotency

template_name = self.want.get("template_name")
if template_name:
if template_list and isinstance(template_list, list):

Copy link
Owner

Choose a reason for hiding this comment

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

we can remove this new line

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is changed

(site_exists, site_id) = self.site_exists()
if not isinstance(self.want.get("site_name"), str) and \
not self.want.get('pnp_params').get('deviceInfo').get('add_device_method'):
self.module.fail_json(msg="Name of the site must be a string", response=[])
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 set the self (status, msg) and return self from here. Check the get_have().check_return_status in main. Can we followup in all the cases?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

self.module.fail_json(msg="Project Not Found or Project is Empty", response=[])

else:
self.module.fail_json(msg="Project Not Found \
Copy link
Owner

Choose a reason for hiding this comment

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

set and return instead of failing Json. this should be taken care in check_return_status..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

else:
self.module.fail_json(msg="Site not found", response=[])
if not self.want.get('pnp_params').get('deviceInfo').get('add_device_method'):
self.module.fail_json(msg="Site not found", response=[])
Copy link
Owner

Choose a reason for hiding this comment

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

set and return instead of failing Json. this should be taken care in check_return_status..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

self.want["vlanId"] = config.get('vlanId')
self.want["ipInterfaceName"] = config.get('ipInterfaceName')
if self.want["pnp_type"] != "Default":

Copy link
Owner

Choose a reason for hiding this comment

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

New line not required

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

self.module.fail_json(msg="Device needs to be added before claiming", response=[])
else:
if not self.want["site_name"]:

Copy link
Owner

Choose a reason for hiding this comment

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

new line not required

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

self.result['diff'] = self.validated_config
self.result['changed'] = True
else:
self.module.fail_json(msg="Device Addition Failed", response=[])
Copy link
Owner

Choose a reason for hiding this comment

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

set and return instead of failing Json. this should be taken care in check_return_status.... We can check the failure condition and return from there itself.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

self.result['diff'] = self.validated_config
self.result['changed'] = True
else:
self.module.fail_json(msg="Device Claim Failed", response=[])
Copy link
Owner

Choose a reason for hiding this comment

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

set and return instead of failing Json. this should be taken care in check_return_status..

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Initialize an instance of class .

Parameters:
module (ModuleType): The Python module associated with this instance.
Copy link
Owner

Choose a reason for hiding this comment

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

we can leave 2 spaces then start with -

 Parameters:
   - module (ModuleType): The Python module associated with this instance.
   
 Attributes:
   - module (ModuleType): The provided module.
   - test_data (dict): The loaded playbook data from the module.
   - playbook_config (dict): The playbook configuration.
   - playbook_config_missing_param (dict): The playbook configuration with missing parameters.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

Mocks the initialization and execution of the Cisco DNA Center SDK to isolate testing from actual SDK operations.

Mocked attributes:
- mock_dnac_init: Mocks the initialization of the DNACSDK class.
Copy link
Owner

Choose a reason for hiding this comment

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

Same style as above

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@abimishr
Copy link
Collaborator Author

abimishr commented Nov 9, 2023

New changes are added

@madhansansel madhansansel merged commit b9331c7 into madhansansel:main Nov 9, 2023
5 checks passed
madhansansel pushed a commit that referenced this pull request May 3, 2024
latest changes 04/15/2024
sonalideepthi777 pushed a commit to sonalideepthi777/madhan-dnacenter-ansible that referenced this pull request Dec 9, 2024
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