summaryrefslogtreecommitdiff
path: root/src/op_mode
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-08 20:35:06 +0200
committerChristian Poessinger <christian@poessinger.com>2020-04-08 20:36:30 +0200
commitc497007369bf53aa99399a9ede4b52fc2d50b563 (patch)
treefe2ae86d8517f2dca48690153d7562662bfecafd /src/op_mode
parent53754fcbbf926eaa353e1cd5f12ad1faed668ac1 (diff)
downloadvyos-1x-c497007369bf53aa99399a9ede4b52fc2d50b563.tar.gz
vyos-1x-c497007369bf53aa99399a9ede4b52fc2d50b563.zip
op-mode: dns: forwarding: cleanup
Diffstat (limited to 'src/op_mode')
-rwxr-xr-xsrc/op_mode/dns_forwarding_reset.py17
1 files 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)