diff options
Diffstat (limited to 'python/vyos/util.py')
-rw-r--r-- | python/vyos/util.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index 3d5bbf094..16cfae92d 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -321,3 +321,22 @@ def mac2eui64(mac, prefix=None): return str(net[euil]) except: # pylint: disable=bare-except return + +def is_bridge_member(interface): + """ + Checks if passed interfaces is part of a bridge device or not. + + Returns a tuple: + False, None -> Not part of a bridge + True, bridge-name -> If it is assigned to a bridge + """ + from vyos.config import Config + c = Config() + base = ['interfaces', 'bridge'] + for bridge in c.list_nodes(base): + members = c.list_nodes(base + [bridge, 'member', 'interface']) + if interface in members: + return (True, bridge) + + return False, None + |