aristanetworks / ansible-cvp

Ansible modules for Arista CloudVision
http://cvp.avd.sh
Apache License 2.0
66 stars 61 forks source link

configlets_notes for cv_configlet_v3 using CVP 2021.1.0 #371

Closed gmoisio closed 3 years ago

gmoisio commented 3 years ago

Hi all, using configlets_notes for cv_configlet_v3, it looks like the note default message from configlet_tools.py ('Managed by Ansible AVD') is always applied. Thanks Regards

ksator commented 3 years ago

This feature was introduced with this change with the addition of the variable configlets_notes in the module cv_configlet.py

configlets_notes = str(module.params['configlets_notes'])

The module cv_configlet.py uses the variable configlets_notes in the function add_note_to_configlet.
The function add_note_to_configlet is defined in cvprac

ksator commented 3 years ago

The module cv_configlet_v3.py uses the variable configlets_notes

configlets_notes=dict(type='str',  default='Managed by Ansible', required=False))

The module cv_configlet_v3.py imports code from module_utils/configlet_tools.py
from ansible_collections.arista.cvp.plugins.module_utils.configlet_tools import ConfigletInput, CvConfigletTools

The module_utils/configlet_tools.py uses

...
configlets_notes = note
...
def create(self, to_create, note: str = 'Managed by Ansible AVD'):
...
def update(self, to_update: list, note: str = 'Managed by Ansible AVD'):
...

The module_utils/configlet_tools.py uses the variable configlets_notes in the function add_note_to_configlet from cvprac

ksator commented 3 years ago

Hello @gmoisio, I did not yet test this feature with cv_configlet_v3.py.
But I dont see where the value of the variable configlets_notes is passed in the module cv_configlet_v3.py.
So I suspect this is why the variable configlets_notes always uses it's default value (Managed by Ansible) ...
i.e something like this configlets_notes = str(module.params['configlets_notes']) should be added to cv_configlet_v3.py

gmoisio commented 3 years ago

Thank you Khelil to take it into account.

titom73 commented 3 years ago

configlets_note var is not propagated through cv_configlet_v3 and hence, function rely on default value set per function (create and update)

A PR is comming this week to fix this issue.