Refactor for *_get_by_name()

They now all return a list [ifname, iface]. If no interface was found
they return None,None. If one was found, they return the (string) name
and the dictionary with interface contents.
This commit is contained in:
Pim van Pelt
2022-03-21 01:18:03 +00:00
parent 5247e3a241
commit ba22b1aad8
8 changed files with 84 additions and 61 deletions

View File

@ -23,7 +23,7 @@ def get_by_name(yaml, ifname):
""" Return the loopback by name, if it exists. Return None otherwise. """
try:
if ifname in yaml['loopbacks']:
return yaml['loopbacks'][ifname]
return ifname, yaml['loopbacks'][ifname]
except:
pass
return None