Make code match documentation :-)
Bridge Domains must be [1,16M), Loopbacks must be [0,4096). Loopbacks should be allowed to have an address without an LCP. => Reuse the unittest file for the bounds check for loopbacks. => Add a new unittest file for the bounds check for bridgedomains.
This commit is contained in:
@ -99,6 +99,10 @@ def validate_bridgedomains(yaml):
|
||||
if instance == 0:
|
||||
msgs.append("bridgedomain %s is reserved" % ifname)
|
||||
result = False
|
||||
elif instance > 16777215:
|
||||
msgs.append("bridgedomain %s has instance %d which is too large" % (ifname, instance))
|
||||
result = False
|
||||
|
||||
if 'bvi' in iface:
|
||||
bviname = iface['bvi']
|
||||
if (None,None) == loopback.get_by_name(yaml, bviname):
|
||||
|
@ -61,8 +61,9 @@ def validate_loopbacks(yaml):
|
||||
|
||||
for ifname, iface in yaml['loopbacks'].items():
|
||||
logger.debug("loopback %s" % iface)
|
||||
if 'addresses' in iface and not 'lcp' in iface:
|
||||
msgs.append("loopback %s has an address but no LCP" % ifname)
|
||||
instance = int(ifname[4:])
|
||||
if instance > 4095:
|
||||
msgs.append("loopback %s has instance %d which is too large" % (ifname, instance))
|
||||
result = False
|
||||
if 'lcp' in iface and not lcp.is_unique(yaml, iface['lcp']):
|
||||
msgs.append("loopback %s does not have a unique LCP name %s" % (ifname, iface['lcp']))
|
||||
|
15
unittest/yaml/error-bridgedomain9.yaml
Normal file
15
unittest/yaml/error-bridgedomain9.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
test:
|
||||
description: "BridgeDomain instance must be between 1 and 16M"
|
||||
errors:
|
||||
expected:
|
||||
- "bridgedomain bd0 is reserved"
|
||||
- "bridgedomain .* has instance .* which is too large"
|
||||
count: 2
|
||||
---
|
||||
bridgedomains:
|
||||
bd0:
|
||||
description: "Reserved in VPP"
|
||||
bd16777215:
|
||||
description: "Cool."
|
||||
bd16777216:
|
||||
description: "Not cool."
|
@ -1,12 +1,12 @@
|
||||
test:
|
||||
description: "Cannot give an IP address to a loopback without LCP"
|
||||
description: "Loopback instances must be between 0 and 4095"
|
||||
errors:
|
||||
expected:
|
||||
- "loopback .* has an address but no LCP"
|
||||
- "loopback .* has instance 4096 which is too large"
|
||||
count: 1
|
||||
---
|
||||
loopbacks:
|
||||
loop10:
|
||||
description: "Loopback instance loop10, with address, but no LCP"
|
||||
mtu: 9216
|
||||
addresses: [ 192.0.2.1/29 ]
|
||||
loop4095:
|
||||
description: "Cool."
|
||||
loop4096:
|
||||
description: "Not cool."
|
||||
|
Reference in New Issue
Block a user