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

Fix(cv_device_v3): Fix strict mode not inheriting configlets from containers #424

Conversation

guillaumeVilar
Copy link
Contributor

@guillaumeVilar guillaumeVilar commented Dec 3, 2021

Change Summary

Fix device_v3 module strict mode not getting configlets from parent containers.

Related Issue(s)

Fixes #353
Fixes #400

Component(s) name

arista.cvp.cv_device_v3

Proposed changes

The way I implemented the fix is by constructing a list of configlets applied to the container's parent of the devices.
This is implemented in the function device_tools.py:__get_configlet_list_inherited_from_container.

  1. API call to get topology information: __cv_client.api.filter_topology()
  2. For each parent container we are doing 1 API call to get the list of configlets attached with:
    __cv_client.api.get_configlets_by_container_id(container_id)

The number of API calls made is (1 + n) where n is the number of containers to explore.

All the API informations are cached in the attribute self.__containers_configlet_list_cache to avoid any unnecessary API call to the CVP server.

How to test

Apply some configlets to devices and remove them with the strict state enabled.
Example (The configlets TO_DETACH and TO_DETACH2 are applied at the device level, some configlets need also to be applied at the containers level):

- hosts: cv_server
  vars:
    devices: 
      - fqdn: gigi-DC1-LEAF1A
        parentContainerName: LEAFS
        configlets:
          - AVD-gigi_gigi-DC1-LEAF1A
          # - TO_DETACH
          # - TO_DETACH2
  tasks:
    - name: "configlet device test"
      arista.cvp.cv_device_v3:
        devices: "{{devices}}"
        state: present
        apply_mode: strict
      register: CV_DEVICE_OUTPUT

The expected output is to have the configlets TO_DETACH and TO_DETACH2 removed. The configlets applied at container level must be kept.

Checklist

  • A test has been written
  • The previous tests all passed

Repository Checklist

  • My code has been rebased from devel before I start
  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation and documentation have been updated accordingly. (check the box if not applicable)
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

@github-actions github-actions bot requested a review from titom73 December 3, 2021 11:57
@github-actions github-actions bot added module: cv_device_v3 Issue related to cv_device module in v3 module_utils: cv_client cv_client implementation issue labels Dec 3, 2021
@guillaumeVilar guillaumeVilar marked this pull request as draft December 3, 2021 12:01
@guillaumeVilar guillaumeVilar changed the title Fix(device_v3): Fix strict mode not inheriting configlets from containers Fix(cv_device_v3): Fix strict mode not inheriting configlets from containers Dec 3, 2021
@guillaumeVilar guillaumeVilar marked this pull request as ready for review December 7, 2021 14:30
Copy link
Contributor

@noredistribution noredistribution left a comment

Choose a reason for hiding this comment

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

LGTM, also tested and worked like a charm!

Copy link
Contributor

@titom73 titom73 left a comment

Choose a reason for hiding this comment

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

LGTM!

@titom73 titom73 merged commit 96f69c5 into aristanetworks:devel Dec 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: cv_device_v3 Issue related to cv_device module in v3 module_utils: cv_client cv_client implementation issue
Projects
None yet
3 participants