diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-03-14 14:57:13 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-14 14:57:13 +0100 |
commit | 2785a486f798c5e36d59c58720334f7bdffcbb3e (patch) | |
tree | 1510d0c47d32b6fd5153c8d7a1775cf367cb6022 /python/vyos | |
parent | 0f24c5b25bc277e0604608710cf81225d765b3be (diff) | |
parent | 7d67e8609471b6a5c9761a99301f368bd6747e13 (diff) | |
download | vyos-1x-2785a486f798c5e36d59c58720334f7bdffcbb3e.tar.gz vyos-1x-2785a486f798c5e36d59c58720334f7bdffcbb3e.zip |
Merge pull request #770 from c-po/vrf-dynamic-routing
VRF: support for dynamic routing protocols OSPF and BGP
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/util.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index 17a7dda91..e4de56cdb 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -646,7 +646,7 @@ def dict_search(path, dict): c = c.get(p, {}) return c.get(parts[-1], None) -def get_json_iface_options(interface): +def get_interface_config(interface): """ Returns the used encapsulation protocol for given interface. If interface does not exist, None is returned. """ @@ -655,3 +655,16 @@ def get_json_iface_options(interface): from json import loads tmp = loads(cmd(f'ip -d -j link show {interface}'))[0] return tmp + +def get_all_vrfs(): + """ Return a dictionary of all system wide known VRF instances """ + from json import loads + tmp = loads(cmd('ip -j vrf list')) + # Result is of type [{"name":"red","table":1000},{"name":"blue","table":2000}] + # so we will re-arrange it to a more nicer representation: + # {'red': {'table': 1000}, 'blue': {'table': 2000}} + data = {} + for entry in tmp: + name = entry.pop('name') + data[name] = entry + return data |