Add loopbacks

This commit is contained in:
Pim van Pelt
2022-03-13 10:18:27 +00:00
parent b5d8f03e66
commit edb8e301ff
3 changed files with 25 additions and 0 deletions

View File

@ -51,3 +51,10 @@ interfaces:
dot1ad: 1000
dot1q: 1000
inner-dot1q: 1000
loopbacks:
loop0:
description: "Core: example.ipng.ch"
mtu: 9216
lcp: "loop0"
addresses: [ 192.0.2.1/32, 2001:db8:1::1/128 ]

View File

@ -1,5 +1,12 @@
interfaces: map(include('interface'),key=str(matches='.*GigabitEthernet[0-9]+/[0-9]+/[0-9]+|BondEthernet[0-9]+'))
bondethernets: map(include('bondethernet'),key=str(matches='BondEthernet[0-9]+'))
loopbacks: map(include('loopback'),key=str(matches='loop[0-9]+'))
---
loopback:
description: str(exclude='\'"',required=False)
lcp: str(max=8,matches='[a-z]+[a-z0-9-]{,7}',required=False)
mtu: int(min=128,max=9216)
addresses: list(ip_interface(),min=1,max=6,required=False)
---
bondethernet:
description: str(exclude='\'"',required=False)

View File

@ -4,6 +4,15 @@ class NullHandler(logging.Handler):
def emit(self, record):
pass
def exists(yaml, ifname):
""" Returns true if ifname exists as a loopback """
try:
if ifname in yaml['loopbacks']:
return True
except:
pass
return False
def loopback(args, yaml):
result = True
@ -12,4 +21,6 @@ def loopback(args, yaml):
logger.addHandler(NullHandler())
logger.debug("Validating loopbacks...")
for ifname, iface in yaml['loopbacks'].items():
logger.debug("loopbacks %s" % iface)
return result, msgs