Skip to content

Commit

Permalink
Merge branch 'main' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
NilashishC authored Jan 6, 2025
2 parents b39882f + 269c3cc commit ed8fcb3
Show file tree
Hide file tree
Showing 49 changed files with 1,782 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,4 @@ venv.bak/

# mypy
.mypy_cache/
.vscode
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ repos:
- id: update-docs

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
rev: v5.0.0
hooks:
- id: check-merge-conflict
- id: check-symlinks
Expand Down Expand Up @@ -41,11 +41,11 @@ repos:
args: ["--filter-files"]

- repo: https://github.com/psf/black
rev: 24.4.2
rev: 24.10.0
hooks:
- id: black

- repo: https://github.com/pycqa/flake8
rev: 7.0.0
rev: 7.1.1
hooks:
- id: flake8
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ Arista Eos Collection Release Notes

.. contents:: Topics

v10.0.1
=======

Bugfixes
--------

- Adds a missing word in the 'bgp client-to-client reflection' command in eos_bgp_global module.
- Fixes a typo in always-compare-med attribute in eos_bgp_global module.
- Handles exception when translating an unknown port to its service name.

Documentation Changes
---------------------

- Includes a new support related section in the README.

v10.0.0
=======
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ Name | Description
[arista.eos.eos_user](https://github.com/ansible-collections/arista.eos/blob/main/docs/arista.eos.eos_user_module.rst)|Manage the collection of local users on EOS devices
[arista.eos.eos_vlans](https://github.com/ansible-collections/arista.eos/blob/main/docs/arista.eos.eos_vlans_module.rst)|VLANs resource module
[arista.eos.eos_vrf](https://github.com/ansible-collections/arista.eos/blob/main/docs/arista.eos.eos_vrf_module.rst)|Manage VRFs on Arista EOS network devices
[arista.eos.eos_vrf_global](https://github.com/ansible-collections/arista.eos/blob/main/docs/arista.eos.eos_vrf_global_module.rst)|Resource module to configure VRF definitions.

<!--end collection content-->

Expand Down
17 changes: 17 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,23 @@ releases:
- fix_statis_routes_ds_issue.yaml
- lldp_timer_bugfixes.yaml
release_date: "2024-06-10"
10.0.1:
changes:
bugfixes:
- Adds a missing word in the 'bgp client-to-client reflection' command in eos_bgp_global
module.
- Fixes a typo in always-compare-med attribute in eos_bgp_global module.
- Handles exception when translating an unknown port to its service name.
doc_changes:
- Includes a new support related section in the README.
fragments:
- bgp_client.yaml
- fix_typo.yaml
- ignore_219.yaml
- port_exception.yaml
- pylint_fix.yaml
- readme.yaml
release_date: "2024-10-21"
2.0.0:
changes:
bugfixes:
Expand Down
3 changes: 3 additions & 0 deletions changelogs/fragments/add_vrf_global.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- Adds a new module `eos_vrf_global` in favor of `eos_vrf` legacy module to manage VRF global configurations on Arista EOS devices.
3 changes: 0 additions & 3 deletions changelogs/fragments/bgp_client.yaml

This file was deleted.

5 changes: 5 additions & 0 deletions changelogs/fragments/fix_acls_config_drift.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
bugfixes:
- Fixed an issue in the `compare_configs` method where unnecessary negate commands were generated for ACL entries already present in both `have` and `want` configurations.
- Improved validation logic for ACL sequence numbers and content matching to ensure idempotency.
- Prevented redundant configuration updates for Access Control Lists.
3 changes: 0 additions & 3 deletions changelogs/fragments/fix_typo.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions changelogs/fragments/ignore_219.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions changelogs/fragments/pylint_fix.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions changelogs/fragments/readme.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ readme: README.md
repository: https://github.com/ansible-collections/arista.eos
issues: https://github.com/ansible-collections/arista.eos/issues
tags: [arista, eos, networking, eapi]
version: 10.0.0
version: 10.0.1
2 changes: 2 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,5 @@ plugin_routing:
redirect: arista.eos.eos_vlans
vrf:
redirect: arista.eos.eos_vrf
vrf_global:
redirect: arista.eos.eos_vrf_global
1 change: 1 addition & 0 deletions plugins/action/vrf_global.py
Empty file.
60 changes: 60 additions & 0 deletions plugins/module_utils/network/eos/argspec/vrf_global/vrf_global.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
# -*- coding: utf-8 -*-
# Copyright 2024 Red Hat
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function


__metaclass__ = type

#############################################
# WARNING #
#############################################
#
# This file is auto generated by the
# ansible.content_builder.
#
# Manually editing this file is not advised.
#
# To update the argspec make the desired changes
# in the documentation in the module file and re-run
# ansible.content_builder commenting out
# the path to external 'docstring' in build.yaml.
#
##############################################

"""
The arg spec for the eos_vrf_global module
"""


class Vrf_globalArgs(object): # pylint: disable=R0903
"""The arg spec for the eos_vrf_global module"""

argument_spec = {
"config": {
"type": "list",
"elements": "dict",
"options": {
"name": {"type": "str", "required": True},
"description": {"type": "str"},
"rd": {"type": "str"},
},
},
"running_config": {"type": "str"},
"state": {
"choices": [
"parsed",
"gathered",
"deleted",
"merged",
"replaced",
"rendered",
"overridden",
"purged",
],
"default": "merged",
"type": "str",
},
} # pylint: disable=C0301
60 changes: 42 additions & 18 deletions plugins/module_utils/network/eos/config/acls/acls.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import re
import socket

from ansible.module_utils._text import to_text
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down Expand Up @@ -139,37 +140,53 @@ def compare_configs(self, have, want):
commands = []
want = list(itertools.chain(*want))
have = list(itertools.chain(*have))

# Flatten the configurations for comparison
h_index = 0
config = list(want)
config = list(want) # Start with a copy of `want`

for w in want:
access_list = re.findall(r"(ip.*) access-list (.*)", w)
if access_list:
# Check if the whole ACL is already present
if w in have:
h_index = have.index(w)
else:
# Check sequence-specific entries
for num, h in enumerate(have, start=h_index + 1):
if "access-list" not in h:
seq_num = re.search(r"(\d+) (.*)", w)
if seq_num:
have_seq_num = re.search(r"(\d+) (.*)", h)
if seq_num.group(1) == have_seq_num.group(
1,
) and have_seq_num.group(
2,
) != seq_num.group(2):
negate_cmd = "no " + seq_num.group(1)
config.insert(config.index(w), negate_cmd)
if w in h:
config.pop(config.index(w))
break
snum = re.search(r"(\d+) (.*)", w)
if snum:
have_snum = re.search(r"(\d+) (.*)", h)
if have_snum:
snum_group_2 = snum.group(2)
have_snum_group_2 = have_snum.group(2)
# Match sequence number and full content
if (
snum.group(1) == have_snum.group(1)
and snum_group_2 == have_snum_group_2
):
# Entry already exists, skip
config.remove(w)
break
else:
have_snum = re.search(r"(\d+) (.*)", h)
if have_snum:
# Match sequence number and full content
if w == have_snum.group(2):
config.remove(w)
break

# Generate commands for any remaining entries in `config`
for c in config:
access_list = re.findall(r"(ip.*) access-list (.*)", c)
if access_list:
acl_index = config.index(c)
else:
if config[acl_index] not in commands:
commands.append(config[acl_index])
commands.append(c)
commands.append(config[acl_index]) # Add ACL definition
commands.append(c) # Add ACL entry

return commands

def set_state(self, want, have):
Expand Down Expand Up @@ -528,8 +545,15 @@ def add_commands(want):
if "port_protocol" in ace["source"].keys():
for op, val in ace["source"]["port_protocol"].items():
if val.isdigit():
val = socket.getservbyport(int(val))
command = command + " " + op + " " + val.replace("_", "-")
try:
# if its a valid port number, then convert it to service name
# eg: 8082 -> us-cli
val = socket.getservbyport(int(val))
command = command + " " + op + " " + val.replace("_", "-")
except OSError:
# if socket.getservbyport is unable to resolve the port name then directly use the port number
# eg: 50702
command = command + " " + op + " " + to_text(val)
if "destination" in ace.keys():
if "any" in ace["destination"].keys():
command = command + " any"
Expand Down
Empty file.
Loading

0 comments on commit ed8fcb3

Please sign in to comment.