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:
Pim van Pelt
2022-03-24 10:45:34 +00:00
parent ac5b8fcc8f
commit b43d7903fd
10 changed files with 182 additions and 2 deletions

View File

@ -29,8 +29,14 @@ def get_by_name(yaml, ifname):
return None, None
def is_bondethernet(yaml, ifname):
""" Returns True if the interface name is an existing BondEthernet. """
ifname, iface = get_by_name(yaml, ifname)
return not iface == None
def is_bond_member(yaml, ifname):
""" Returns True if this interface is a member of a BondEthernet """
""" Returns True if this interface is a member of a BondEthernet. """
if not 'bondethernets' in yaml:
return False