Add a few additional useful functions
- is_*() returns True if the interface name is of a certain type is_bondethernet() is_loopback() is_bvi() is_bridgedomain() is_vxlan_tunnel() is_phy() - get_phys() by process of elimination, returns all interface names that are supposed to be physical network interfaces. Add unit tests for validator/vxlan_tunnel.py => Notable: while here, fix a bug in get_by_name() Add unit tests for all the is_*() and get_phys() functions.
This commit is contained in:
@ -27,7 +27,14 @@ def get_by_name(yaml, ifname):
|
||||
return ifname, yaml['vxlan_tunnels'][ifname]
|
||||
except:
|
||||
pass
|
||||
return None
|
||||
return None, None
|
||||
|
||||
|
||||
def is_vxlan_tunnel(yaml, ifname):
|
||||
""" Returns True if the interface name is an existing VXLAN Tunnel. """
|
||||
ifname, iface = get_by_name(yaml, ifname)
|
||||
return not iface == None
|
||||
|
||||
|
||||
def vni_unique(yaml, vni):
|
||||
""" Return True if the VNI is unique amongst all VXLANs """
|
||||
@ -42,6 +49,17 @@ def vni_unique(yaml, vni):
|
||||
return ncount < 2
|
||||
|
||||
|
||||
def get_vxlan_tunnels(yaml):
|
||||
""" Returns a list of all VXLAN tunnel interface names. """
|
||||
ret = []
|
||||
if not 'vxlan_tunnels' in yaml:
|
||||
return ret
|
||||
|
||||
for ifname, iface in yaml['vxlan_tunnels'].items():
|
||||
ret.append(ifname)
|
||||
return ret
|
||||
|
||||
|
||||
def validate_vxlan_tunnels(yaml):
|
||||
result = True
|
||||
msgs = []
|
||||
|
Reference in New Issue
Block a user