summaryrefslogtreecommitdiff
path: root/python/vyos/ifconfig/vrrp.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-09-21 20:31:06 +0200
committerChristian Poessinger <christian@poessinger.com>2021-09-21 21:35:04 +0200
commit761631d662ccc18827d017d197c0e0100ac36219 (patch)
treecdfe8a4cc633b6f9685392d6b4026b1c06d9a424 /python/vyos/ifconfig/vrrp.py
parent590cf0e626f6a5e813ec4f3021c028a5e098e27d (diff)
downloadvyos-1x-761631d662ccc18827d017d197c0e0100ac36219.tar.gz
vyos-1x-761631d662ccc18827d017d197c0e0100ac36219.zip
vrrp: keepalived: T3847: migrate to get_config_dict()
Diffstat (limited to 'python/vyos/ifconfig/vrrp.py')
-rw-r--r--python/vyos/ifconfig/vrrp.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/python/vyos/ifconfig/vrrp.py b/python/vyos/ifconfig/vrrp.py
index 481b0284a..47aaadecd 100644
--- a/python/vyos/ifconfig/vrrp.py
+++ b/python/vyos/ifconfig/vrrp.py
@@ -22,6 +22,7 @@ from time import sleep
from tabulate import tabulate
from vyos import util
+from vyos.configquery import ConfigTreeQuery
class VRRPError(Exception):
pass
@@ -39,7 +40,6 @@ class VRRP(object):
'json': '/tmp/keepalived.json',
'daemon': '/etc/default/keepalived',
'config': '/run/keepalived/keepalived.conf',
- 'vyos': '/run/keepalived/keepalived_config.dict',
}
_signal = {
@@ -111,17 +111,20 @@ class VRRP(object):
@classmethod
def disabled(cls):
- if not os.path.exists(cls.location['vyos']):
- return []
-
disabled = []
- config = json.loads(util.read_file(cls.location['vyos']))
-
- # add disabled groups to the list
- for group in config['vrrp_groups']:
- if group['disable']:
- disabled.append(
- [group['name'], group['interface'], group['vrid'], 'DISABLED', ''])
+ base = ['high-availability', 'vrrp']
+ conf = ConfigTreeQuery()
+ if conf.exists(base):
+ # Read VRRP configuration directly from CLI
+ vrrp_config_dict = conf.get_config_dict(base, key_mangling=('-', '_'),
+ get_first_key=True)
+
+ # add disabled groups to the list
+ if 'group' in vrrp_config_dict:
+ for group, group_config in vrrp_config_dict['group'].items():
+ if 'disable' not in group_config:
+ continue
+ disabled.append([group, group_config['interface'], group_config['vrid'], 'DISABLED', ''])
# return list with disabled instances
return disabled