From c497007369bf53aa99399a9ede4b52fc2d50b563 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Wed, 8 Apr 2020 20:35:06 +0200 Subject: op-mode: dns: forwarding: cleanup --- src/op_mode/dns_forwarding_reset.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/op_mode/dns_forwarding_reset.py b/src/op_mode/dns_forwarding_reset.py index 93c2444b9..dad78d7e8 100755 --- a/src/op_mode/dns_forwarding_reset.py +++ b/src/op_mode/dns_forwarding_reset.py @@ -21,13 +21,12 @@ import os -import sys import argparse -import vyos.config +from sys import exit +from vyos.config import Config from vyos.util import run - parser = argparse.ArgumentParser() parser.add_argument("-a", "--all", action="store_true", help="Reset all cache") parser.add_argument("domain", type=str, nargs="?", help="Domain to reset cache entries for") @@ -36,16 +35,18 @@ if __name__ == '__main__': args = parser.parse_args() # Do nothing if service is not configured - c = vyos.config.Config() - if not c.exists_effective('service dns forwarding'): + c = Config() + if not c.exists_effective(['service', 'dns', 'forwarding']): print("DNS forwarding is not configured") - sys.exit(0) + exit(0) if args.all: run("rec_control wipe-cache \'.$\'") - sys.exit(1) + exit(0) + elif args.domain: run("rec_control wipe-cache \'{0}$\'".format(args.domain)) + else: parser.print_help() - sys.exit(1) + exit(1) -- cgit v1.2.3