summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/vrrp.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/op_mode/vrrp.py b/src/op_mode/vrrp.py
index 8d1369823..8a993f92c 100755
--- a/src/op_mode/vrrp.py
+++ b/src/op_mode/vrrp.py
@@ -18,12 +18,28 @@
import sys
import time
import argparse
-
+import json
import tabulate
import vyos.keepalived
import vyos.util
+config_dict_path = '/run/keepalived_config.dict'
+
+
+# get disabled instances from a config
+def vrrp_get_disabled():
+ # read the dictionary file with configuration
+ with open(config_dict_path, 'r') as dict_file:
+ vrrp_config_dict = json.load(dict_file)
+ vrrp_disabled = []
+ # add disabled groups to the list
+ for vrrp_group in vrrp_config_dict['vrrp_groups']:
+ if vrrp_group['disable']:
+ vrrp_disabled.append([vrrp_group['name'], vrrp_group['interface'], vrrp_group['vrid'], 'DISABLED', ''])
+ # return list with disabled instances
+ return vrrp_disabled
+
def print_summary():
try:
@@ -54,10 +70,13 @@ def print_summary():
row = [name, interface, vrid, state, ltrans_time]
groups.append(row)
+ # add to the active list disabled instances
+ groups.extend(vrrp_get_disabled())
headers = ["Name", "Interface", "VRID", "State", "Last Transition"]
output = tabulate.tabulate(groups, headers)
print(output)
+
def print_statistics():
try:
vyos.keepalived.force_stats_dump()
@@ -69,6 +88,7 @@ def print_statistics():
print("VRRP statistics are not available")
sys.exit(1)
+
def print_state_data():
try:
vyos.keepalived.force_state_data_dump()
@@ -80,6 +100,7 @@ def print_state_data():
print("VRRP information is not available")
sys.exit(1)
+
parser = argparse.ArgumentParser()
group = parser.add_mutually_exclusive_group()
group.add_argument("-s", "--summary", action="store_true", help="Print VRRP summary")