Rewrite 'exists' to 'get_by_name'

This commit is contained in:
Pim van Pelt
2022-03-13 10:44:59 +00:00
parent 61b6c01e73
commit 3d6903bfdc
3 changed files with 33 additions and 23 deletions

View File

@ -4,14 +4,14 @@ class NullHandler(logging.Handler):
def emit(self, record):
pass
def exists(yaml, ifname):
""" Returns true if ifname exists as a loopback """
def get_by_name(yaml, ifname):
""" Return the loopback by name, if it exists. Return None otherwise. """
try:
if ifname in yaml['loopbacks']:
return True
return yaml['loopbacks'][ifname]
except:
pass
return False
return None
def loopback(args, yaml):