diff options
Diffstat (limited to 'python/vyos/configdict.py')
-rw-r--r-- | python/vyos/configdict.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/python/vyos/configdict.py b/python/vyos/configdict.py index cdcd3f9ea..99c1ae2e4 100644 --- a/python/vyos/configdict.py +++ b/python/vyos/configdict.py @@ -17,10 +17,12 @@ A library for retrieving value dicts from VyOS configs in a declarative fashion. """ import os +import json from vyos.util import dict_search from vyos.xml import defaults from vyos import ConfigError +from vyos.util import cmd def retrieve_config(path_hash, base_path, config): """ @@ -420,6 +422,26 @@ def get_interface_dict(config, base, ifname=''): dict = get_removed_vlans(config, dict) return dict +def get_vlan_ids(interface): + """ + Get the VLAN ID of the interface bound to the bridge + """ + vlan_ids = set() + + bridge_status = cmd('bridge -j vlan show', shell=True) + vlan_filter_status = json.loads(bridge_status) + + if vlan_filter_status is not None: + for interface_status in vlan_filter_status: + ifname = interface_status['ifname'] + if interface == ifname: + vlans_status = interface_status['vlans'] + for vlan_status in vlans_status: + vlan_id = vlan_status['vlan'] + vlan_ids.add(vlan_id) + + return vlan_ids + def get_accel_dict(config, base, chap_secrets): """ |