diff options
author | jack9603301 <jack9603301@163.com> | 2020-12-13 04:23:50 +0800 |
---|---|---|
committer | jack9603301 <jack9603301@163.com> | 2020-12-13 04:23:50 +0800 |
commit | d03176d70e6390f42c4e46451770dc5f86864bac (patch) | |
tree | 1eb2ee75b5b4343df2152a9b85cbb303aa41ce4f /python/vyos/configdict.py | |
parent | 9863c5773e87a0a40eabdd135f3defb953a364de (diff) | |
download | vyos-1x-d03176d70e6390f42c4e46451770dc5f86864bac.tar.gz vyos-1x-d03176d70e6390f42c4e46451770dc5f86864bac.zip |
interfaces: T3114: Modify the logic of the second addition to complete the setting and streamline the code
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): """ |