Merge with head
authorClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Fri, 30 Sep 2011 06:26:47 +0000 (08:26 +0200)
committerClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Fri, 30 Sep 2011 06:26:47 +0000 (08:26 +0200)
src/nepi/testbeds/planetlab/application.py
src/nepi/testbeds/planetlab/interfaces.py
src/nepi/testbeds/planetlab/node.py

index 3d680ea..1552cbb 100644 (file)
@@ -290,13 +290,22 @@ class Dependency(object):
         kill_agent = "kill $SSH_AGENT_PID"
         
         waitmaster = (
-            "{ . ./.ssh-agent.sh ; "
+            "{ "
+            "echo 'Checking master reachability' ; "
+            "if ping -c 3 %(master_host)s ; then "
+            "echo 'Master node reachable' ; "
+            "else "
+            "echo 'MASTER NODE UNREACHABLE' && "
+            "exit 1 ; "
+            "fi ; "
+            ". ./.ssh-agent.sh ; "
             "while [[ $(. ./.ssh-agent.sh > /dev/null ; ssh -q -o UserKnownHostsFile=%(hostkey)s %(sshopts)s %(master)s cat %(token_path)s.retcode || /bin/true) != %(token)s ]] ; do sleep 5 ; done ; "
             "if [[ $(. ./.ssh-agent.sh > /dev/null ; ssh -q -o UserKnownHostsFile=%(hostkey)s %(sshopts)s %(master)s cat %(token_path)s || /bin/true) != %(token)s ]] ; then echo BAD TOKEN ; exit 1 ; fi ; "
             "}" 
         ) % {
             'hostkey' : 'master_known_hosts',
             'master' : "%s@%s" % (self._master.node.slicename, self._master.node.hostname),
+            'master_host' : self._master.node.hostname,
             'token_path' : os.path.join(self._master.home_path, 'build.token'),
             'token' : server.shell_escape(self._master._master_token),
             'sshopts' : sshopts,
@@ -1054,6 +1063,7 @@ class YumDependency(Dependency):
                            r'The GPG keys listed for the ".*" repository are already installed but they are not correct for this package'
                            r'|Error: Cannot retrieve repository metadata (repomd.xml) for repository: .*[.] Please verify its path and try again'
                            r'|Error: disk I/O error'
+                           r'|MASTER NODE UNREACHABLE'
                            r')', 
                            re.I)
         return badre.search(out) or badre.search(err)
index 4c04e90..e9abf11 100644 (file)
@@ -170,7 +170,11 @@ class TunIface(object):
         # Generate an initial random cryptographic key to use for tunnelling
         # Upon connection, both endpoints will agree on a common one based on
         # this one.
-        self.tun_key = os.urandom(32).encode("base64").strip()
+        self.tun_key = ( ''.join(map(chr, [ 
+                    r.getrandbits(8) 
+                    for i in xrange(32) 
+                    for r in (random.SystemRandom(),) ])
+                ).encode("base64").strip() )        
         
 
     def __str__(self):
index b8407e2..61c73e8 100644 (file)
@@ -322,7 +322,15 @@ class Node(object):
     
     def unassign_node(self):
         self._node_id = None
-        self.__dict__.update(self.__orig_attrs)
+        
+        try:
+            orig_attrs = self.__orig_attrs
+        except AttributeError:
+            return
+            
+        for key, value in __orig_attrs.iteritems():
+            setattr(self, key, value)
+        del self.__orig_attrs
     
     def rate_nodes(self, nodes):
         rates = collections.defaultdict(int)
@@ -396,7 +404,10 @@ class Node(object):
             orig_attrs['server_key'] = self.server_key
             self.server_key = info['ssh_rsa_key']
         
-        self.__orig_attrs = orig_attrs
+        try:
+            self.__orig_attrs
+        except AttributeError:
+            self.__orig_attrs = orig_attrs
 
     def validate(self):
         if self.home_path is None: