summaryrefslogtreecommitdiff
path: root/src/conf_mode/vrf.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-03-07 09:48:32 +0100
committerChristian Poessinger <christian@poessinger.com>2020-03-07 09:48:32 +0100
commitee02d6c2c1d2d8641a20e18cdb847a4129429c08 (patch)
treee9841bdd9ffc4195b1d5550763d0c91dde121ec9 /src/conf_mode/vrf.py
parent300263a4faf5e49d951507889f0cb0face211864 (diff)
downloadvyos-1x-ee02d6c2c1d2d8641a20e18cdb847a4129429c08.tar.gz
vyos-1x-ee02d6c2c1d2d8641a20e18cdb847a4129429c08.zip
vrf: T31: reuse Config in interfaces_with_vrf()
Diffstat (limited to 'src/conf_mode/vrf.py')
-rwxr-xr-xsrc/conf_mode/vrf.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/conf_mode/vrf.py b/src/conf_mode/vrf.py
index 623b7f216..db546956b 100755
--- a/src/conf_mode/vrf.py
+++ b/src/conf_mode/vrf.py
@@ -61,10 +61,11 @@ def list_rules():
answer = loads(check_output(command.split()).decode())
return [_ for _ in answer if _]
-def interfaces_with_vrf(match):
+def interfaces_with_vrf(c, match):
matched = []
- config = Config()
- section = config.get_config_dict('interfaces')
+ old_level = c.get_level()
+ c.set_level(['interfaces'])
+ section = c.get_config_dict([])
for type in section:
interfaces = section[type]
for name in interfaces:
@@ -73,6 +74,8 @@ def interfaces_with_vrf(match):
v = interface.get('vrf', '')
if v == match:
matched.append(name)
+
+ c.set_level(old_level)
return matched
def get_config():
@@ -122,7 +125,7 @@ def get_config():
vrf_inst['description'] = conf.return_value(['description'])
# find member interfaces of this particulat VRF
- vrf_inst['members'] = interfaces_with_vrf(name)
+ vrf_inst['members'] = interfaces_with_vrf(conf, name)
# append individual VRF configuration to global configuration list
vrf_config['vrf_add'].append(vrf_inst)
@@ -140,7 +143,7 @@ def get_config():
}
# find member interfaces of this particulat VRF
- vrf_inst['members'] = interfaces_with_vrf(name)
+ vrf_inst['members'] = interfaces_with_vrf(conf, name)
# append individual VRF configuration to temporary configuration list
tmp.append(vrf_inst)