pvl.hosts: fail if no hostfiles are given as input
authorTero Marttila <terom@paivola.fi>
Sun, 01 Mar 2015 23:16:18 +0200
changeset 670 b95ad8c8bb4e
parent 669 83e9bff09a0b
child 671 72143af5afbd
pvl.hosts: fail if no hostfiles are given as input
bin/pvl.hosts-dhcp
bin/pvl.hosts-forward
bin/pvl.hosts-reverse
--- a/bin/pvl.hosts-dhcp	Sun Mar 01 22:39:05 2015 +0200
+++ b/bin/pvl.hosts-dhcp	Sun Mar 01 23:16:18 2015 +0200
@@ -18,6 +18,10 @@
     # input
     options, args = pvl.args.parse(parser, argv)
     
+    if not args:
+        log.fatal("no hosts given as input")
+        return 1
+    
     hosts = pvl.hosts.apply(options, args)
 
     # process
--- a/bin/pvl.hosts-forward	Sun Mar 01 22:39:05 2015 +0200
+++ b/bin/pvl.hosts-forward	Sun Mar 01 23:16:18 2015 +0200
@@ -39,8 +39,12 @@
 
         log.info("using given hostpath for zone origin: %s", origin)
 
+    elif args:
+        log.fatal("--zone-origin is required if passing multiple hostfiles")
+        return 1
+
     else:
-        log.fatal("--zone-origin is required if passing multiple hostfiles")
+        log.fatal("no hosts given as input")
         return 1
     
     hosts = pvl.hosts.apply(options, args)
--- a/bin/pvl.hosts-reverse	Sun Mar 01 22:39:05 2015 +0200
+++ b/bin/pvl.hosts-reverse	Sun Mar 01 23:16:18 2015 +0200
@@ -46,8 +46,12 @@
         else:
             log.info("using given hosts path %s for reverse --zone-prefix: %s", zone_prefix, prefix)
 
+    elif args:
+        log.fatal("--zone-prefix is required if passing multiple hosts files")
+        return 1
+
     else:
-        log.fatal("--zone-prefix is required if passing multiple hosts files")
+        log.fatal("no hosts given as input")
         return 1
  
     if options.unknown_host and not options.hosts_domain: