summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-01-13 22:17:08 +0100
committerGitHub <noreply@github.com>2022-01-13 22:17:08 +0100
commit97472739b4432cdbf8f73275ab00876add071692 (patch)
tree75a2c949d30e91d8224b9d48ba9b21af3abfbbfd
parentb3fc933da9b93f3eefc10ea0dabcc63372bf982f (diff)
parent6cdeb472d924ec66fe74e17559e942ab5f55d45f (diff)
downloadvyos-1x-97472739b4432cdbf8f73275ab00876add071692.tar.gz
vyos-1x-97472739b4432cdbf8f73275ab00876add071692.zip
Merge pull request #1166 from sever-sever/T4182
vrrp: T4182: Check if VRRP configured in op mode
-rwxr-xr-xsrc/op_mode/vrrp.py13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/op_mode/vrrp.py b/src/op_mode/vrrp.py
index 2c1db20bf..dab146d28 100755
--- a/src/op_mode/vrrp.py
+++ b/src/op_mode/vrrp.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
#
-# Copyright (C) 2018 VyOS maintainers and contributors
+# Copyright (C) 2018-2022 VyOS maintainers and contributors
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 or later as
@@ -23,6 +23,7 @@ import tabulate
import vyos.util
+from vyos.configquery import ConfigTreeQuery
from vyos.ifconfig.vrrp import VRRP
from vyos.ifconfig.vrrp import VRRPError, VRRPNoData
@@ -35,7 +36,17 @@ group.add_argument("-d", "--data", action="store_true", help="Print detailed VRR
args = parser.parse_args()
+def is_configured():
+ """ Check if VRRP is configured """
+ config = ConfigTreeQuery()
+ if not config.exists(['high-availability', 'vrrp', 'group']):
+ return False
+ return True
+
# Exit early if VRRP is dead or not configured
+if is_configured() == False:
+ print('VRRP not configured!')
+ exit(0)
if not VRRP.is_running():
print('VRRP is not running')
sys.exit(0)