Assert that is_l2() interfaces cannot have LCP or address; Fix consistency on 'be' vs 'have' an LCP.

This commit is contained in:
Pim van Pelt
2022-03-22 14:54:09 +00:00
parent 6688c6b243
commit 077d49cb88
5 changed files with 20 additions and 10 deletions

View File

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

View File

@ -5,7 +5,8 @@ test:
- "interface .* has an address but no LCP" - "interface .* has an address but no LCP"
- "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"
count: 6 - "interface .* is in L2 mode but has an address"
count: 8
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:

View File

@ -2,11 +2,13 @@ test:
description: "L2 cross connect targets cannot have an IP address or LCP" description: "L2 cross connect targets cannot have an IP address or LCP"
errors: errors:
expected: expected:
- "interface .* has l2xc so it cannot be an LCP" - "interface .* has l2xc so it cannot have an LCP"
- "interface .* has l2xc so it cannot have an address" - "interface .* has l2xc so it cannot have an address"
- "interface .* l2xc target .* cannot be an LCP" - "interface .* l2xc target .* cannot have an LCP"
- "interface .* l2xc target .* cannot have an address" - "interface .* l2xc target .* cannot have an address"
count: 6 - "interface .* is in L2 mode but has LCP name .*"
- "interface .* is in L2 mode but has an address"
count: 9
--- ---
interfaces: interfaces:
GigabitEthernet1/0/0: GigabitEthernet1/0/0:

View File

@ -3,7 +3,7 @@ test:
errors: errors:
expected: expected:
- "sub-interface .* l2xc target .* cannot have an address" - "sub-interface .* l2xc target .* cannot have an address"
- "sub-interface .* l2xc target .* cannot be an LCP" - "sub-interface .* l2xc target .* cannot have an LCP"
count: 2 count: 2
--- ---
interfaces: interfaces:

View File

@ -371,6 +371,12 @@ def validate_interfaces(yaml):
if iface_address and not iface_lcp: if iface_address and not iface_lcp:
msgs.append("interface %s has an address but no LCP" % ifname) msgs.append("interface %s has an address but no LCP" % ifname)
result = False result = False
if is_l2(yaml, ifname) and iface_lcp:
msgs.append("interface %s is in L2 mode but has LCP name %s" % (ifname, iface_lcp))
result = False
if is_l2(yaml, ifname) and iface_address:
msgs.append("interface %s is in L2 mode but has an address" % ifname)
result = False
if iface_lcp and not lcp.is_unique(yaml, iface_lcp): 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)) msgs.append("interface %s does not have a unique LCP name %s" % (ifname, iface_lcp))
result = False result = False
@ -386,7 +392,7 @@ def validate_interfaces(yaml):
msgs.append("interface %s has l2xc so it cannot have sub-interfaces" % (ifname)) msgs.append("interface %s has l2xc so it cannot have sub-interfaces" % (ifname))
result = False result = False
if iface_lcp: if iface_lcp:
msgs.append("interface %s has l2xc so it cannot be an LCP" % (ifname)) msgs.append("interface %s has l2xc so it cannot have an LCP" % (ifname))
result = False result = False
if iface_address: if iface_address:
msgs.append("interface %s has l2xc so it cannot have an address" % (ifname)) msgs.append("interface %s has l2xc so it cannot have an address" % (ifname))
@ -408,7 +414,7 @@ def validate_interfaces(yaml):
msgs.append("interface %s l2xc target %s is in a bridgedomain" % (ifname, iface['l2xc'])) msgs.append("interface %s l2xc target %s is in a bridgedomain" % (ifname, iface['l2xc']))
result = False result = False
if has_lcp(yaml, iface['l2xc']): if has_lcp(yaml, iface['l2xc']):
msgs.append("interface %s l2xc target %s cannot be an LCP" % (ifname, iface['l2xc'])) msgs.append("interface %s l2xc target %s cannot have an LCP" % (ifname, iface['l2xc']))
result = False result = False
if has_address(yaml, iface['l2xc']): if has_address(yaml, iface['l2xc']):
msgs.append("interface %s l2xc target %s cannot have an address" % (ifname, iface['l2xc'])) msgs.append("interface %s l2xc target %s cannot have an address" % (ifname, iface['l2xc']))
@ -465,7 +471,7 @@ def validate_interfaces(yaml):
result = False result = False
if 'l2xc' in sub_iface: if 'l2xc' in sub_iface:
if has_lcp(yaml, sub_ifname): if has_lcp(yaml, sub_ifname):
msgs.append("sub-interface %s has l2xc so it cannot be an LCP" % (sub_ifname)) msgs.append("sub-interface %s has l2xc so it cannot have an LCP" % (sub_ifname))
result = False result = False
if has_address(yaml, sub_ifname): if has_address(yaml, sub_ifname):
msgs.append("sub-interface %s has l2xc so it cannot have an address" % (sub_ifname)) msgs.append("sub-interface %s has l2xc so it cannot have an address" % (sub_ifname))
@ -487,7 +493,7 @@ def validate_interfaces(yaml):
msgs.append("sub-interface %s l2xc target %s is in a bridgedomain" % (sub_ifname, sub_iface['l2xc'])) msgs.append("sub-interface %s l2xc target %s is in a bridgedomain" % (sub_ifname, sub_iface['l2xc']))
result = False result = False
if has_lcp(yaml, sub_iface['l2xc']): if has_lcp(yaml, sub_iface['l2xc']):
msgs.append("sub-interface %s l2xc target %s cannot be an LCP" % (sub_ifname, sub_iface['l2xc'])) msgs.append("sub-interface %s l2xc target %s cannot have an LCP" % (sub_ifname, sub_iface['l2xc']))
result = False result = False
if has_address(yaml, sub_iface['l2xc']): if has_address(yaml, sub_iface['l2xc']):
msgs.append("sub-interface %s l2xc target %s cannot have an address" % (sub_ifname, sub_iface['l2xc'])) msgs.append("sub-interface %s l2xc target %s cannot have an address" % (sub_ifname, sub_iface['l2xc']))