Skip to content

Commit

Permalink
Fix(eos_validate_state): Fix the DHCP not recognized error for STUN a…
Browse files Browse the repository at this point in the history
…nd Connectivity tests (#4764)
  • Loading branch information
MaheshGSLAB authored Dec 2, 2024
1 parent 98df6ce commit 7d41e7a
Show file tree
Hide file tree
Showing 16 changed files with 2,627 additions and 2,549 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,12 @@ ethernet_interfaces:
description: mpls-sp-1_DC1-MPLS-4
- name: Ethernet4
peer_type: l3_interface
ip_address: 100.64.4.2/24
ip_address: dhcp
shutdown: false
switchport:
enabled: false
description: isp-1_DC1-INET-4
dhcp_client_accept_default_route: true
loopback_interfaces:
- name: Loopback0
description: ROUTER_ID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,11 @@ ethernet_interfaces:
ip_address: 1.1.1.1/24
peer: dc2-leaf2b
peer_interface: Ethernet2
- name: Ethernet16
description: Test_dhcp_interface_connectivity
ip_address: dhcp
peer: dc2-leaf3b.arista.com
peer_interface: Ethernet16
mlag_configuration:
domain_id: DC2_L3_LEAF3
local_interface: Vlan4094
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,11 @@ ethernet_interfaces:
peer: dc2-leaf3-fw1
peer_interface: e1
peer_type: firewall
- name: Ethernet16
description: Test_dhcp_interface_connectivity
ip_address: dhcp
peer: dc2-leaf3a.arista.com
peer_interface: Ethernet16
mlag_configuration:
domain_id: DC2_L3_LEAF3
local_interface: Vlan4094
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,6 @@ anta.tests.stun:
stun_clients:
- source_address: 172.18.4.2
source_port: 4500
- VerifyStunClient:
result_overwrite:
custom_field: 'Source IPv4 Address: 100.64.4.2 Source Port: 4500'
stun_clients:
- source_address: 100.64.4.2
source_port: 4500
- VerifyStunClient:
stun_clients:
- public_address: 172.18.3.21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ anta.tests.connectivity:
port: Ethernet15
result_overwrite:
custom_field: 'Local: Ethernet15 - Remote: dc2-leaf2b Ethernet2'
- VerifyLLDPNeighbors:
neighbors:
- neighbor_device: dc2-leaf3b.arista.com
neighbor_port: Ethernet16
port: Ethernet16
result_overwrite:
custom_field: 'Local: Ethernet16 - Remote: dc2-leaf3b.arista.com Ethernet16'
- VerifyReachability:
hosts:
- destination: 10.255.255.120
Expand Down Expand Up @@ -343,6 +350,12 @@ anta.tests.interfaces:
status: up
result_overwrite:
custom_field: Interface Ethernet15 - Test_type_routed = 'up'
- VerifyInterfacesStatus:
interfaces:
- name: Ethernet16
status: up
result_overwrite:
custom_field: Interface Ethernet16 - Test_dhcp_interface_connectivity = 'up'
- VerifyInterfacesStatus:
interfaces:
- name: Port-Channel3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,12 @@ anta.tests.interfaces:
status: adminDown
result_overwrite:
custom_field: Interface Ethernet11 - dc2-leaf3-fw1_e1 = 'adminDown'
- VerifyInterfacesStatus:
interfaces:
- name: Ethernet16
status: adminDown
result_overwrite:
custom_field: Interface Ethernet16 - Test_dhcp_interface_connectivity = 'adminDown'
- VerifyInterfacesStatus:
interfaces:
- name: Port-Channel3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ wan_router: # dynamic_key: node_type
static_routes:
- prefix: 172.18.0.0/16
- name: Ethernet4
ip_address: 100.64.4.2/24
ip_address: dhcp
wan_carrier: isp-1
wan_circuit_id: DC1-INET-4
peer_ip: 100.64.4.1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ custom_structured_configuration_ethernet_interfaces:
- name: Ethernet4
validate_lldp: false

- name: Ethernet16
description: Test_dhcp_interface_connectivity
ip_address: dhcp
peer: dc2-leaf3b.arista.com
peer_interface: Ethernet16

custom_structured_configuration_port_channel_interfaces:
- name: Port-Channel11
description: dc2-leaf3-fw1_PortChannel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ custom_structured_configuration_ethernet_interfaces:
channel_group:
id: 11
mode: active
- name: Ethernet16
description: Test_dhcp_interface_connectivity
ip_address: dhcp
peer: dc2-leaf3a.arista.com
peer_interface: Ethernet16

custom_structured_configuration_port_channel_interfaces:
- name: Port-Channel11
Expand Down
2,526 changes: 1,264 additions & 1,262 deletions ansible_collections/arista/avd/molecule/eos_validate_state/reports/FABRIC-state.csv

Large diffs are not rendered by default.

2,540 changes: 1,271 additions & 1,269 deletions ansible_collections/arista/avd/molecule/eos_validate_state/reports/FABRIC-state.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -757,15 +757,6 @@
],
"description": "Verifies the STUN client is configured with the specified IPv4 source address and port. Validate the public IP and port if provided."
},
{
"name": "dc1-wan2",
"test": "VerifyStunClient",
"categories": [
"stun"
],
"description": "Verifies the STUN client is configured with the specified IPv4 source address and port. Validate the public IP and port if provided.",
"custom_field": "Source IPv4 Address: 100.64.4.2 Source Port: 4500"
},
{
"name": "dc1-wan2",
"test": "VerifyStunClient",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@
"description": "Verifies that the provided LLDP neighbors are connected properly.",
"custom_field": "Local: Ethernet15 - Remote: dc2-leaf2b Ethernet2"
},
{
"name": "dc2-leaf3a.arista.com",
"test": "VerifyLLDPNeighbors",
"categories": [
"connectivity"
],
"description": "Verifies that the provided LLDP neighbors are connected properly.",
"custom_field": "Local: Ethernet16 - Remote: dc2-leaf3b.arista.com Ethernet16"
},
{
"name": "dc2-leaf3a.arista.com",
"test": "VerifyLLDPNeighbors",
Expand Down Expand Up @@ -500,6 +509,15 @@
"description": "Verifies the status of the provided interfaces.",
"custom_field": "Interface Ethernet15 - Test_type_routed = 'up'"
},
{
"name": "dc2-leaf3a.arista.com",
"test": "VerifyInterfacesStatus",
"categories": [
"interfaces"
],
"description": "Verifies the status of the provided interfaces.",
"custom_field": "Interface Ethernet16 - Test_dhcp_interface_connectivity = 'up'"
},
{
"name": "dc2-leaf3a.arista.com",
"test": "VerifyInterfacesStatus",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,15 @@
"description": "Verifies the status of the provided interfaces.",
"custom_field": "Interface Ethernet11 - dc2-leaf3-fw1_e1 = 'adminDown'"
},
{
"name": "dc2-leaf3b.arista.com",
"test": "VerifyInterfacesStatus",
"categories": [
"interfaces"
],
"description": "Verifies the status of the provided interfaces.",
"custom_field": "Interface Ethernet16 - Test_dhcp_interface_connectivity = 'adminDown'"
},
{
"name": "dc2-leaf3b.arista.com",
"test": "VerifyInterfacesStatus",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,26 @@ def get_interface_ip(self, interface_model: str, interface_name: str, host: str
interfaces = get(host_struct_cfg, interface_model, default=[])
interface = get_item(interfaces, "name", interface_name, default={})
ip_address = get(interface, "ip_address")
if ip_address is None:
if ip_address is None or ip_address == "dhcp":
log_msg = f"Host '{host or self.device_name}' interface '{interface_name}' IP address is unavailable. {self.__class__.__name__} is skipped."
LOGGER.warning(log_msg)
return None

return ip_address

def is_dhcp_interface(self, interface: dict) -> bool:
"""Check if the interface is a DHCP interface.
Args:
----
interface (dict): The interface to verify.
Returns:
-------
bool: True if the interface is a DHCP interface, False otherwise.
"""
return interface["ip_address"] == "dhcp"

def is_subinterface(self, interface: dict) -> bool:
"""Check if the interface is a subinterface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def test_definition(self) -> dict | None:
if not self.validate_data(data=interface, data_path=f"ethernet_interfaces.[{idx}]", required_keys=required_keys, shutdown=False):
continue

if self.is_dhcp_interface(interface):
LOGGER.info("Interface '%s' is a DHCP interface. %s is skipped.", interface["name"], self.__class__.__name__)
continue

if not self.is_peer_available(peer := interface["peer"]):
continue

Expand Down Expand Up @@ -88,6 +92,10 @@ def test_definition(self) -> dict | None:
if not self.validate_data(data=interface, data_path=f"vlan_interfaces.[{idx}]", required_keys=required_keys, type="inband_mgmt", shutdown=False):
continue

if self.is_dhcp_interface(interface):
LOGGER.info("Interface '%s' is a DHCP interface. %s is skipped.", interface["name"], self.__class__.__name__)
continue

vrf = interface.get("vrf", "default")

src_ip = str(ip_interface(interface["ip_address"]).ip)
Expand Down

0 comments on commit 7d41e7a

Please sign in to comment.