Assert is_l2() on sub-ints cannot have address or LCP

This commit is contained in:
Pim van Pelt
2022-03-22 15:02:38 +00:00
parent 077d49cb88
commit 7303adb74a
4 changed files with 13 additions and 3 deletions

View File

@ -4,7 +4,8 @@ test:
expected: expected:
- "bridgedomain .* member .* has an LCP" - "bridgedomain .* member .* has an LCP"
- "interface .* is in L2 mode but has LCP name .*" - "interface .* is in L2 mode but has LCP name .*"
count: 5 - "sub-interface .* is in L2 mode but has LCP name .*"
count: 6
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:

View File

@ -6,7 +6,8 @@ test:
- "sub-interface .* has an address but .* does not have LCP" - "sub-interface .* has an address but .* does not have LCP"
- "bridgedomain .* member .* has an address" - "bridgedomain .* member .* has an address"
- "interface .* is in L2 mode but has an address" - "interface .* is in L2 mode but has an address"
count: 8 - "sub-interface .* is in L2 mode but has an address"
count: 9
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:

View File

@ -4,7 +4,9 @@ test:
expected: expected:
- "sub-interface .* l2xc target .* cannot have an address" - "sub-interface .* l2xc target .* cannot have an address"
- "sub-interface .* l2xc target .* cannot have an LCP" - "sub-interface .* l2xc target .* cannot have an LCP"
count: 2 - "sub-interface .* is in L2 mode but has an address"
- "sub-interface .* is in L2 mode but has LCP name .*"
count: 4
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:

View File

@ -435,6 +435,9 @@ def validate_interfaces(yaml):
result = False result = False
sub_lcp = get_lcp(yaml, sub_ifname) sub_lcp = get_lcp(yaml, sub_ifname)
if is_l2(yaml, sub_ifname) and sub_lcp:
msgs.append("sub-interface %s is in L2 mode but has LCP name %s" % (sub_ifname, sub_lcp))
result = False
if sub_lcp and not lcp.is_unique(yaml, sub_lcp): if sub_lcp and not lcp.is_unique(yaml, sub_lcp):
msgs.append("sub-interface %s does not have a unique LCP name %s" % (sub_ifname, sub_lcp)) msgs.append("sub-interface %s does not have a unique LCP name %s" % (sub_ifname, sub_lcp))
result = False result = False
@ -459,6 +462,9 @@ def validate_interfaces(yaml):
if not iface_lcp: if not iface_lcp:
msgs.append("sub-interface %s has an address but %s does not have LCP" % (sub_ifname, ifname)) msgs.append("sub-interface %s has an address but %s does not have LCP" % (sub_ifname, ifname))
result = False result = False
if is_l2(yaml, sub_ifname):
msgs.append("sub-interface %s is in L2 mode but has an address" % sub_ifname)
result = False
for a in sub_iface['addresses']: for a in sub_iface['addresses']:
if not address.is_allowed(yaml, sub_ifname, sub_iface['addresses'], a): if not address.is_allowed(yaml, sub_ifname, sub_iface['addresses'], a):
msgs.append("sub-interface %s IP address %s conflicts with another" % (sub_ifname, a)) msgs.append("sub-interface %s IP address %s conflicts with another" % (sub_ifname, a))