Expand autocreated LCP namelen to all possible (dot1q, qin*) scenarios. Allow manually set LCP to be 15char in length

This commit is contained in:
Pim van Pelt
2022-03-17 00:15:18 +00:00
parent 3663a04cde
commit f921b1721a
4 changed files with 23 additions and 7 deletions

View File

@ -13,13 +13,13 @@ vxlan:
bridgedomain:
description: str(exclude='\'"',len=64,required=False)
mtu: int(min=128,max=9216,required=False)
lcp: str(max=8,matches='[a-z]+[a-z0-9-]{,7}',required=False)
lcp: str(max=15,matches='[a-z]+[a-z0-9-]{,7}',required=False)
addresses: list(ip_interface(),min=1,max=6,required=False)
interfaces: list(str())
---
loopback:
description: str(exclude='\'"',len=64,required=False)
lcp: str(max=8,matches='[a-z]+[a-z0-9-]{,7}',required=False)
lcp: str(max=15,matches='[a-z]+[a-z0-9-]{,7}',required=False)
mtu: int(min=128,max=9216,required=False)
addresses: list(ip_interface(),min=1,max=6,required=False)
---
@ -30,7 +30,7 @@ bondethernet:
interface:
description: str(exclude='\'"',len=64,required=False)
mac: mac(required=False)
lcp: str(max=8,matches='[a-z]+[a-z0-9-]{,7}',required=False)
lcp: str(max=15,matches='[a-z]+[a-z0-9-]{,7}',required=False)
mtu: int(min=128,max=9216,required=False)
addresses: list(ip_interface(),min=1,max=6,required=False)
sub-interfaces: map(include('sub-interface'),key=int(min=1,max=4294967295),required=False)
@ -38,7 +38,7 @@ interface:
---
sub-interface:
description: str(exclude='\'"',len=64,required=False)
lcp: str(max=8,matches='[a-z]+[a-z0-9-]{,7}',required=False)
lcp: str(max=15,matches='[a-z]+[a-z0-9-]{,7}',required=False)
mtu: int(min=128,max=9216,required=False)
addresses: list(ip_interface(),required=False)
encapsulation: include('encapsulation',required=False)

View File

@ -4,7 +4,8 @@ test:
expected:
- "yamale: .* is not a "
- "yamale: .*: Unexpected element"
count: 12
- "Length of .* is greater than 15"
count: 13
---
interfaces:
GigabitEthernet1/0/0:
@ -20,6 +21,7 @@ interfaces:
GigabitEthernet1/0/1:
mtu: 1500
lcp: "a234567890123456"
sub-interfaces:
"string":
description: "the sub-int key should be an int"

View File

@ -2,12 +2,23 @@ test:
description: "The length of the LCP name is too long"
errors:
expected:
- "Length .* is greater than 8"
- "sub-interface .* has LCP with too long name .*"
count: 2
---
interfaces:
GigabitEthernet1/0/0:
lcp: "e01234567"
lcp: "e23456789012"
sub-interfaces:
100:
description: "VLAN 100"
GigabitEthernet1/0/1:
lcp: "e2345678"
sub-interfaces:
100:
description: "VLAN 100"
101:
description: "QinQ 101"
encapsulation:
dot1q: 100
inner-dot1q: 100

View File

@ -334,6 +334,9 @@ def validate_interfaces(yaml):
if iface_lcp and not lcp.is_unique(yaml, iface_lcp):
msgs.append("interface %s does not have a unique LCP name %s" % (ifname, iface_lcp))
result = False
if iface_lcp and len(iface_lcp)>15:
msgs.append("interface %s has LCP with too long name %s" % (fname, iface_lcp))
result = False
if 'addresses' in iface:
for a in iface['addresses']: