diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-12-12 21:44:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-12 21:44:37 +0100 |
commit | 505c5efaf1e852a3e90276baacdb235c4c3e41b2 (patch) | |
tree | 1eb2ee75b5b4343df2152a9b85cbb303aa41ce4f /python/vyos/configdict.py | |
parent | e6e87c839f8dc458dcf2962ea936329e972fbafc (diff) | |
parent | d03176d70e6390f42c4e46451770dc5f86864bac (diff) | |
download | vyos-1x-505c5efaf1e852a3e90276baacdb235c4c3e41b2.tar.gz vyos-1x-505c5efaf1e852a3e90276baacdb235c4c3e41b2.zip |
Merge pull request #638 from jack9603301/T3114
interfaces: T3114: Fix VLAN-aware bridge setting failure
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): """ |