Assert that target unnumbered interfaces AND loopbacks also cannot be unnumbered

This commit is contained in:
Pim van Pelt
2024-04-07 17:15:11 +02:00
parent 6352d6892e
commit 6949e72888
3 changed files with 14 additions and 4 deletions

View File

@ -530,7 +530,7 @@ def validate_interfaces(yaml):
f"interface {ifname} unnumbered target {target} cannot be in L2 mode" f"interface {ifname} unnumbered target {target} cannot be in L2 mode"
) )
result = False result = False
if is_unnumbered(yaml, target): if is_unnumbered(yaml, target) or loopback.is_unnumbered(yaml, target):
msgs.append( msgs.append(
f"interface {ifname} unnumbered target {target} cannot also be unnumbered" f"interface {ifname} unnumbered target {target} cannot also be unnumbered"
) )
@ -692,7 +692,7 @@ def validate_interfaces(yaml):
f"sub-interface {sub_ifname} unnumbered target {target} cannot be in L2 mode" f"sub-interface {sub_ifname} unnumbered target {target} cannot be in L2 mode"
) )
result = False result = False
if is_unnumbered(yaml, target): if is_unnumbered(yaml, target) or loopback.is_unnumbered(yaml, target):
msgs.append( msgs.append(
f"sub-interface {sub_ifname} unnumbered target {target} cannot also be unnumbered" f"sub-interface {sub_ifname} unnumbered target {target} cannot also be unnumbered"
) )

View File

@ -113,7 +113,7 @@ def validate_loopbacks(yaml):
f"loopback {ifname} unnumbered target {target} does not exist" f"loopback {ifname} unnumbered target {target} does not exist"
) )
result = False result = False
if is_unnumbered(yaml, target): if is_unnumbered(yaml, target) or interface.is_unnumbered(yaml, target):
msgs.append( msgs.append(
f"loopback {ifname} unnumbered target {target} cannot also be unnumbered" f"loopback {ifname} unnumbered target {target} cannot also be unnumbered"
) )

View File

@ -6,7 +6,7 @@ test:
- "(sub-)?interface .* unnumbered target .* cannot also be unnumbered" - "(sub-)?interface .* unnumbered target .* cannot also be unnumbered"
- "loopback .* unnumbered target cannot point to itself" - "loopback .* unnumbered target cannot point to itself"
- "loopback .* unnumbered target .* cannot also be unnumbered" - "loopback .* unnumbered target .* cannot also be unnumbered"
count: 12 count: 16
--- ---
loopbacks: loopbacks:
loop0: loop0:
@ -15,6 +15,10 @@ loopbacks:
unnumbered: loop0 unnumbered: loop0
loop2: loop2:
unnumbered: loop2 unnumbered: loop2
loop3:
unnumbered: GigabitEthernet2/0/0
loop4:
unnumbered: GigabitEthernet1/0/0.100
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:
@ -31,6 +35,9 @@ interfaces:
GigabitEthernet2/0/1: GigabitEthernet2/0/1:
description: "Cannot point to Gi2/0/0, as that interface is itself unnumbered" description: "Cannot point to Gi2/0/0, as that interface is itself unnumbered"
unnumbered: GigabitEthernet2/0/0 unnumbered: GigabitEthernet2/0/0
GigabitEthernet2/0/2:
description: "Cannot point to Gi2/0/0, as that interface is itself unnumbered"
unnumbered: loop0
GigabitEthernet3/0/0: GigabitEthernet3/0/0:
sub-interfaces: sub-interfaces:
@ -40,3 +47,6 @@ interfaces:
101: 101:
description: "Cannot point to Gi3/0/0.100, as that interface is itself unnumbered" description: "Cannot point to Gi3/0/0.100, as that interface is itself unnumbered"
unnumbered: GigabitEthernet3/0/0.100 unnumbered: GigabitEthernet3/0/0.100
102:
description: "Cannot point to Gi3/0/0.100, as that interface is itself unnumbered"
unnumbered: loop0