server_scp can copy multiple files at once.
authorClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Fri, 29 Apr 2011 08:26:53 +0000 (10:26 +0200)
committerClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Fri, 29 Apr 2011 08:26:53 +0000 (10:26 +0200)
This shaves a good 10% runtime from tests, and in some situations would mean a huge improvement (say, with long source lists)

src/nepi/testbeds/planetlab/application.py
src/nepi/testbeds/planetlab/tunproto.py
src/nepi/util/server.py
test/testbeds/planetlab/execute.py

index 59332c9..cb39622 100644 (file)
@@ -260,17 +260,16 @@ class Application(object):
             sources = self.sources.split(' ')
             
             # Copy all sources
-            for source in sources:
-                (out,err),proc = server.popen_scp(
-                    source,
-                    "%s@%s:%s" % (self.slicename, self.node.hostname, 
-                        os.path.join(self.home_path,'.'),),
-                    ident_key = self.ident_path,
-                    server_key = self.node.server_key
-                    )
-            
-                if proc.wait():
-                    raise RuntimeError, "Failed upload source file %r: %s %s" % (source, out,err,)
+            (out,err),proc = server.popen_scp(
+                sources,
+                "%s@%s:%s" % (self.slicename, self.node.hostname, 
+                    os.path.join(self.home_path,'.'),),
+                ident_key = self.ident_path,
+                server_key = self.node.server_key
+                )
+        
+            if proc.wait():
+                raise RuntimeError, "Failed upload source file %r: %s %s" % (source, out,err,)
             
         if self.buildDepends:
             # Install build dependencies
index a9f4888..a9f283e 100644 (file)
@@ -60,23 +60,15 @@ class TunProtoBase(object):
             raise RuntimeError, "Unconnected TUN - missing node"
         
         # Install the tun_connect script and tunalloc utility
-        source = os.path.join(os.path.dirname(__file__), 'scripts', 'tun_connect.py')
+        sources = [
+            os.path.join(os.path.dirname(__file__), 'scripts', 'tun_connect.py'),
+            os.path.join(os.path.dirname(__file__), 'scripts', 'tunalloc.c'),
+        ]
         dest = "%s@%s:%s" % (
             local.node.slicename, local.node.hostname, 
             os.path.join(self.home_path,'.'),)
         (out,err),proc = server.popen_scp(
-            source,
-            dest,
-            ident_key = local.node.ident_path,
-            server_key = local.node.server_key
-            )
-    
-        if proc.wait():
-            raise RuntimeError, "Failed upload TUN connect script %r: %s %s" % (source, out,err,)
-
-        source = os.path.join(os.path.dirname(__file__), 'scripts', 'tunalloc.c')
-        (out,err),proc = server.popen_scp(
-            source,
+            sources,
             dest,
             ident_key = local.node.ident_path,
             server_key = local.node.server_key
index f153ab2..8c164fd 100644 (file)
@@ -415,6 +415,9 @@ def popen_scp(source, dest,
         read and written into dest.
         
         In these modes, recursive cannot be True.
+        
+        Source can be a list of files to copy to a single destination,
+        in which case it is advised that the destination be a folder.
         """
         
         if isinstance(source, file) or isinstance(dest, file) \
@@ -569,7 +572,10 @@ def popen_scp(source, dest,
                 # Create a temporary server key file
                 tmp_known_hosts = _make_server_key_args(
                     server_key, host, port, args)
-            args.append(source)
+            if isinstance(source,list):
+                args.extend(source)
+            else:
+                args.append(source)
             args.append(dest)
 
             # connects to the remote host and starts a remote connection
index 01671f4..3ee224e 100755 (executable)
@@ -56,7 +56,8 @@ class PlanetLabExecuteTestCase(unittest.TestCase):
 
         instance.do_setup()
         instance.do_create()
-        instance.do_connect()
+        instance.do_connect_init()
+        instance.do_connect_compl()
         instance.do_preconfigure()
         
         # Manually replace netref
@@ -101,7 +102,8 @@ class PlanetLabExecuteTestCase(unittest.TestCase):
 
         instance.do_setup()
         instance.do_create()
-        instance.do_connect()
+        instance.do_connect_init()
+        instance.do_connect_compl()
         instance.do_preconfigure()
         instance.do_configure()
         
@@ -137,7 +139,8 @@ class PlanetLabExecuteTestCase(unittest.TestCase):
 
         instance.do_setup()
         instance.do_create()
-        instance.do_connect()
+        instance.do_connect_init()
+        instance.do_connect_compl()
         instance.do_preconfigure()
         instance.do_configure()
         
@@ -194,7 +197,8 @@ echo 'OKIDOKI'
 
         instance.do_setup()
         instance.do_create()
-        instance.do_connect()
+        instance.do_connect_init()
+        instance.do_connect_compl()
         instance.do_preconfigure()
         instance.do_configure()
         
@@ -237,7 +241,8 @@ echo 'OKIDOKI'
 
         instance.do_setup()
         instance.do_create()
-        instance.do_connect()
+        instance.do_connect_init()
+        instance.do_connect_compl()
         instance.do_preconfigure()
         instance.do_configure()
         
@@ -283,7 +288,8 @@ echo 'OKIDOKI'
         try:
             instance.do_setup()
             instance.do_create()
-            instance.do_connect()
+            instance.do_connect_init()
+            instance.do_connect_compl()
             instance.do_preconfigure()
             instance.do_configure()
             self.fail("Usage of TUN without emulation should fail")
@@ -322,7 +328,8 @@ echo 'OKIDOKI'
 
         instance.do_setup()
         instance.do_create()
-        instance.do_connect()
+        instance.do_connect_init()
+        instance.do_connect_compl()
         instance.do_preconfigure()
         
         # Manually replace netref