]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-deploy.git/commitdiff
host validation ip should be done per subnet, not per ip
authorAlfredo Deza <alfredo.deza@inktank.com>
Wed, 27 Aug 2014 19:19:57 +0000 (15:19 -0400)
committerAlfredo Deza <alfredo.deza@inktank.com>
Wed, 27 Aug 2014 20:41:13 +0000 (16:41 -0400)
Signed-off-by: Alfredo Deza <alfredo.deza@inktank.com>
ceph_deploy/new.py

index 2e24405b5aa06ac0e9cfc56b67cadf782a27193d..d87c3ec95071c77912274f55da567850dc587d02 100644 (file)
@@ -77,29 +77,28 @@ def ssh_copy_keys(hostname, username=None):
 
 def validate_host_ip(ips, subnets):
     """
-    Make sure that a given host will have IP addresses that will be
-    present in one (or all) of the the subnets specified
+    Make sure that a given host all subnets specified will have at least one IP
+    in that range.
     """
     # Make sure we prune ``None`` arguments
     subnets = [s for s in subnets if s is not None]
     validate_one_subnet = len(subnets) == 1
 
-    def ip_in_one_subnet(ip, subnets):
+    def ip_in_one_subnet(ips, subnet):
         """ ensure an ip exists in at least one subnet """
-        for subnet in subnets:
-            if subnet:
-                if net.ip_in_subnet(ip, subnet):
-                    return True
+        for ip in ips:
+            if net.ip_in_subnet(ip, subnet):
+                return True
         return False
 
-    for ip in ips:
-        if ip_in_one_subnet(ip, subnets):
+    for subnet in subnets:
+        if ip_in_one_subnet(ips, subnet):
             if validate_one_subnet:
                 return
             else:  # keep going to make sure the other subnets are ok
                 continue
         else:
-            msg = "IP (%s) is not valid for any of the subnets specified %s" % (ip, str(subnets))
+            msg = "subnet (%s) is not valid for any of the ips found %s" % (subnet, str(ips))
             raise RuntimeError(msg)