From c9e5a20101ad740f51978f80d72756f9f6cbda3b Mon Sep 17 00:00:00 2001
From: Thierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Date: Fri, 16 Sep 2011 19:00:24 +0200
Subject: [PATCH] sense first, load starting second, minimize the risk for
 concurrently assigning the same IP

---
 system/Substrate.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/system/Substrate.py b/system/Substrate.py
index f57172d..2e54cba 100644
--- a/system/Substrate.py
+++ b/system/Substrate.py
@@ -141,9 +141,9 @@ class Pool:
             return (i.hostname,i.userdata)
         raise Exception,"No IP address available in pool %s"%self.message
 
-# OS-dependent ping option (support for macos, for convenience)
+    # OS-dependent ping option (support for macos, for convenience)
     ping_timeout_option = None
-# checks whether a given hostname/ip responds to ping
+    # checks whether a given hostname/ip responds to ping
     def check_ping (self,hostname):
         if not Pool.ping_timeout_option:
             (status,osname) = commands.getstatusoutput("uname -s")
@@ -660,8 +660,8 @@ class Substrate:
         if options.ips_vplc:
             vplc_hostname=options.ips_vplc.pop()
         else:
-            self.vplc_pool.load_starting()
             self.vplc_pool.sense()
+            self.vplc_pool.load_starting()
             (vplc_hostname,unused)=self.vplc_pool.next_free()
         vplc_ip = self.vplc_pool.get_ip(vplc_hostname)
         self.vplc_pool.add_starting(vplc_hostname)
@@ -729,8 +729,8 @@ class Substrate:
                 vnode_hostname=options.ips_vnode.pop()
                 mac=self.vnode_pool.retrieve_userdata(vnode_hostname)
             else:
-                self.vnode_pool.load_starting()
                 self.vnode_pool.sense()
+                self.vnode_pool.load_starting()
                 (vnode_hostname,mac)=self.vnode_pool.next_free()
             ip=self.vnode_pool.get_ip (vnode_hostname)
             self.vnode_pool.add_starting(vnode_hostname)
-- 
2.47.0