From 9fc8158f98ba7154da9867d9a28f00e39f76d0e0 Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Thu, 25 Jun 2020 09:22:46 +0300 Subject: T2487: add an exception for the case when VRRP stats aren't available. --- src/op_mode/vrrp.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/op_mode') diff --git a/src/op_mode/vrrp.py b/src/op_mode/vrrp.py index e024d7f63..2c1db20bf 100755 --- a/src/op_mode/vrrp.py +++ b/src/op_mode/vrrp.py @@ -24,7 +24,7 @@ import tabulate import vyos.util from vyos.ifconfig.vrrp import VRRP -from vyos.ifconfig.vrrp import VRRPError +from vyos.ifconfig.vrrp import VRRPError, VRRPNoData parser = argparse.ArgumentParser() @@ -40,12 +40,16 @@ if not VRRP.is_running(): print('VRRP is not running') sys.exit(0) -if args.summary: - print(VRRP.format(VRRP.collect('json'))) -elif args.statistics: - print(VRRP.collect('stats')) -elif args.data: - print(VRRP.collect('state')) -else: - parser.print_help() +try: + if args.summary: + print(VRRP.format(VRRP.collect('json'))) + elif args.statistics: + print(VRRP.collect('stats')) + elif args.data: + print(VRRP.collect('state')) + else: + parser.print_help() + sys.exit(1) +except VRRPNoData as e: + print(e) sys.exit(1) -- cgit v1.2.3