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

Refactor(eos_cli_config_gen): Add support to set vlan and vni ranges in vxlan interface #4749

Draft
wants to merge 8 commits into
base: devel
Choose a base branch
from

Conversation

laxmikantchintakindi
Copy link
Contributor

@laxmikantchintakindi laxmikantchintakindi commented Nov 21, 2024

Change Summary

Add support to set vlan and vni ranges in vxlan interface

Related Issue(s)

Fixes #4664

Component(s) name

arista.avd.eos_cli_config_gen

Proposed changes

Add support to set vlan and vni ranges in vxlan interface.

How to test

Checklist

User Checklist

  • N/A

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.
  • I have updated molecule CI testing accordingly. (check the box if not applicable)

Copy link

Review docs on Read the Docs

To test this pull request:

# Create virtual environment for this testing below the current directory
python -m venv test-avd-pr-4749
# Activate the virtual environment
source test-avd-pr-4749/bin/activate
# Install all requirements including PyAVD
pip install "pyavd[ansible] @ git+https://github.com/laxmikantchintakindi/avd.git@refactor/eos_cli/vxlan_vni#subdirectory=python-avd" --force
# Point Ansible collections path to the Python virtual environment
export ANSIBLE_COLLECTIONS_PATH=$VIRTUAL_ENV/ansible_collections
# Install Ansible collection
ansible-galaxy collection install git+https://github.com/laxmikantchintakindi/avd.git#/ansible_collections/arista/avd/,refactor/eos_cli/vxlan_vni --force
# Optional: Install AVD examples
cd test-avd-pr-4749
ansible-playbook arista.avd.install_examples

@github-actions github-actions bot added role: eos_cli_config_gen issue related to eos_cli_config_gen role state: CI Updated CI scenario have been updated in the PR state: Documentation role Updated labels Nov 21, 2024
Copy link

sonarcloud bot commented Nov 21, 2024

@Shivani-gslab Shivani-gslab marked this pull request as ready for review November 22, 2024 12:49
@Shivani-gslab Shivani-gslab requested review from a team as code owners November 22, 2024 12:49
@Shivani-gslab Shivani-gslab marked this pull request as draft November 22, 2024 12:56
…/vxlan-interface.j2

Co-authored-by: Shivani-gslab <145646625+Shivani-gslab@users.noreply.github.com>
Comment on lines 78 to 99
{% set all_vlans = vxlan_config.vxlan.vlans | map(attribute='id') | map('arista.avd.range_expand') | sum(start=[]) %}
{% for all_vlans_item in all_vlans | arista.avd.natural_sort %}
{% for vxlan_vlans in vxlan_config.vxlan.vlans %}
{% set vlans = vxlan_vlans.id | arista.avd.range_expand %}
{% if all_vlans_item in vlans %}
{% if vxlan_vlans.vni is arista.avd.defined %}
{% set vlan_idx = vlans.index(all_vlans_item) %}
{% set vlan_vnis = vxlan_vlans.vni | arista.avd.range_expand %}
{% set vlan_vni = vlan_vnis[vlan_idx] %}
{% else %}
{% set vlan_vni = '-' %}
{% endif %}
{% set multicast_group = vxlan_vlans.multicast_group | arista.avd.default('-') %}
{% if vxlan_vlans.flood_vteps is arista.avd.defined %}
{% set flood_list = vxlan_vlans.flood_vteps | join('<br/>') %}
{% else %}
{% set flood_list = '-' %}
{% endif %}
| {{ all_vlans_item }} | {{ vlan_vni }} | {{ flood_list }} | {{ multicast_group }} |
{% endif %}
{% endfor %}
{% endfor %}
Copy link
Contributor

Choose a reason for hiding this comment

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

it could be more optimized like this (discussed with @Vibhu-gslab)

Suggested change
{% set all_vlans = vxlan_config.vxlan.vlans | map(attribute='id') | map('arista.avd.range_expand') | sum(start=[]) %}
{% for all_vlans_item in all_vlans | arista.avd.natural_sort %}
{% for vxlan_vlans in vxlan_config.vxlan.vlans %}
{% set vlans = vxlan_vlans.id | arista.avd.range_expand %}
{% if all_vlans_item in vlans %}
{% if vxlan_vlans.vni is arista.avd.defined %}
{% set vlan_idx = vlans.index(all_vlans_item) %}
{% set vlan_vnis = vxlan_vlans.vni | arista.avd.range_expand %}
{% set vlan_vni = vlan_vnis[vlan_idx] %}
{% else %}
{% set vlan_vni = '-' %}
{% endif %}
{% set multicast_group = vxlan_vlans.multicast_group | arista.avd.default('-') %}
{% if vxlan_vlans.flood_vteps is arista.avd.defined %}
{% set flood_list = vxlan_vlans.flood_vteps | join('<br/>') %}
{% else %}
{% set flood_list = '-' %}
{% endif %}
| {{ all_vlans_item }} | {{ vlan_vni }} | {{ flood_list }} | {{ multicast_group }} |
{% endif %}
{% endfor %}
{% endfor %}
{% for vxlan_vlans in vxlan_config.vxlan.vlans %}
{% set vlans = vxlan_vlans.id | arista.avd.range_expand %}
{% if vxlan_vlans.vni is arista.avd.defined %}
{% set vlan_vni = vxlan_vlans.vni | arista.avd.range_expand %}
{% endif %}
{% set multicast_group = vxlan_vlans.multicast_group | arista.avd.default('-') %}
{% if vxlan_vlans.flood_vteps is arista.avd.defined %}
{% set flood_list = vxlan_vlans.flood_vteps | join('<br/>') %}
{% endif %}
{% for idx in range(vlans | length) %}
| {{ vlans[idx] }} | {{ vlan_vni[idx] | arista.avd.default("-") }} | {{ flood_list | arista.avd.default("-") }} | {{ multicast_group }} |
{% endfor %}
{% endfor %}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not sorting the vlan ids in documentation which is hard to read when there are large no of vlans. Also if you add one more item {id:113, multicast_group:239.1.1.1} for host one, it creates a new row for vlan 113.

@laxmikantchintakindi
Copy link
Contributor Author

laxmikantchintakindi commented Nov 29, 2024

Shall I add ability to set multicast_group on vlan ranges?

vxlan_interface:
  vxlan1:
    description: DC1-LEAF2A_VTEP
    vxlan:
        - id: 113,115-118
          vni: 10113,10115-10118
          multicast_group: 239.1.1.1

This will result in below commands:

vxlan vlan 113,115-118 vni 10113,10115-10118
vxlan vlan 113 multicast group 239.1.1.1
vxlan vlan 115 multicast group 239.1.1.1
vxlan vlan 116 multicast group 239.1.1.1
vxlan vlan 117 multicast group 239.1.1.1
vxlan vlan 118 multicast group 239.1.1.1

@gmuloc @ClausHolbechArista

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
role: eos_cli_config_gen issue related to eos_cli_config_gen role state: CI Updated CI scenario have been updated in the PR state: Documentation role Updated
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add range support for Vxlan vlan vni mapping under interface vxlan 1
3 participants