Skip to content

[minor_changes]Adding guidelines for Ansible ACI module developement (DCNE-80) #761

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

anvitha-jain
Copy link
Collaborator

@anvitha-jain anvitha-jain commented May 14, 2025

solves #278

@anvitha-jain anvitha-jain self-assigned this May 14, 2025
@anvitha-jain anvitha-jain added the documentation Improvements or additions to documentation label May 14, 2025
@github-actions github-actions bot changed the title [minor_changes]Adding guidelines for Ansible ACI module developement [minor_changes]Adding guidelines for Ansible ACI module developement (DCNE-80) Jun 4, 2025
Copy link
Collaborator

@akinross akinross left a comment

Choose a reason for hiding this comment

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

sanity fails

@anvitha-jain anvitha-jain requested review from samiib and akinross June 17, 2025 16:25

.. code-block:: python

#aci.get_diff(aci_class='l3extRsNodeL3OutAtt')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need commented line here?

Copy link
Collaborator Author

@anvitha-jain anvitha-jain Jun 24, 2025

Choose a reason for hiding this comment

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

yes, currently it's the only way to show diff

type: str
choices: [ absent, present, query ]
default: present
extends_documentation_fragment:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we include some sample notes and seealso sections?
If yes, please take care of the other places.

Copy link
Collaborator

@sajagana sajagana left a comment

Choose a reason for hiding this comment

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

Can we also mention the black formatting and flake8 checks in a few points?

from ansible_collections.cisco.aci.plugins.module_utils.aci import ACIModule, aci_argument_spec
from ansible.module_utils.basic import AnsibleModule

8. In the main function, the argument_spec variable defines all the arguments necessary for this module and is based on aci_argument_spec. We add all the arguments we defined previously in the documentation section to this variable. In our case, we would add description, prefix, track_policy, preference, and bfd to the section below and remove router_id and router_id_as_loopback.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps we could also cover the types of relationships and go deeper into the other options for type like list and how that would be used and implimented.

* the object_id (usually the name)
* the configurable properties of the object
* the object_id of each parent up to the root (usually the name)
* The child classes that have a 1-to-1 relationship with the main object don't need their own dedicated module and can be incorporated into the parent module. If the relationship is 1-to-many/many-to-many, this child class will need a dedicated module.
Copy link
Collaborator

Choose a reason for hiding this comment

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

For one of the modules I worked on, I think it was a one-to-many case but I did not need to create a new module and still maintained desired functionality. Perhaps there could be some elaboration on the relationships.

---------------------------------------
The following imports are standard across ACI modules:

.. code-block:: python
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps you could also elaborate on the environment that needs to be set before we are able to run a module or tests, including versions for libraries and venv activation and setup(this part might not be necessary just personal recommendation). Perhaps a small paragraph on what the environment needs to look like or how to set up the environment with docker incase someone wants to containerize.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Requirements to run the module is available in GuitHub in the Readme file section, this file only talks about building the module.

Let's build a test file for our l3out static routes using the existing test for l3out logical node:
aci_l3out_logical_node -> aci_l3out_static_routes

1. In the **tests** directory of our collection, we have the **integration** directory. The **integration** directory consists of **targets**, which has directories for all the test files of modules that currently exist in our collection. We go to the **targets** directory and copy the aci_l3out_logical_node directory, then paste it in the same directory as aci_l3out_static_routes, which should be the same as the name of our module. Upon opening the directory, we find the main.yml file. We open this file and make the following changes.
Copy link
Collaborator

@DevSinha13 DevSinha13 Jun 24, 2025

Choose a reason for hiding this comment

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

Do we not need to set up an environment or be in a venv to run the tests aswell?

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 document only refers to the part of building the modules and test cases, how to run/execute them is available in the Readme section of Ansible-ACI github page

'status': ['preview'],
'supported_by': 'community'}

DOCUMENTATION = r'''
Copy link
Collaborator

Choose a reason for hiding this comment

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

If possible could we talk about black formatting, especially when talking with respect to sanity.


Steps required to perform tests:

1. Ansible uses an inventory file to keep track of which hosts are part of your APIC, and how to reach them for running commands and playbooks using credentials for the APIC. To update the inventory, go to **ansible-aci -> tests -> integration -> inventory.networking** and update the file with the credentials of your APIC.
Copy link
Collaborator

@DevSinha13 DevSinha13 Jun 24, 2025

Choose a reason for hiding this comment

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

Perhaps you could include some common pitfalls that could be addressed or avoided, also I think formatting standards should also be outlined more explicitly including whitespace and empty lines at the end of modules.

),


14. The payload function is followed by get_diff(), which is used to get the difference between the proposed and existing configurations of 'ipRouteP'. Here, the aci_class is changed to the class name your module is going to manage.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you add another example of the get_diff functionality especially when it comes to redundancy of configs.


Steps required to perform tests:

1. Ansible uses an inventory file to keep track of which hosts are part of your APIC, and how to reach them for running commands and playbooks using credentials for the APIC. To update the inventory, go to **ansible-aci -> tests -> integration -> inventory.networking** and update the file with the credentials of your APIC.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also I would elaborate a little on how to create a inventory file for the test cases and with the APIC information, and login information.

Copy link
Collaborator

@samiib samiib left a comment

Choose a reason for hiding this comment

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

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate Cisco ACI development and scenario guides to this collection. (DCNE-80)
6 participants