From: Claudio-Daniel Freire Date: Fri, 29 Apr 2011 08:26:53 +0000 (+0200) Subject: server_scp can copy multiple files at once. X-Git-Tag: nepi_v2~104 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=8c1e676f920cefe4330cc0d3f426683f41baf917;p=nepi.git server_scp can copy multiple files at once. This shaves a good 10% runtime from tests, and in some situations would mean a huge improvement (say, with long source lists) --- diff --git a/src/nepi/testbeds/planetlab/application.py b/src/nepi/testbeds/planetlab/application.py index 59332c93..cb396222 100644 --- a/src/nepi/testbeds/planetlab/application.py +++ b/src/nepi/testbeds/planetlab/application.py @@ -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 diff --git a/src/nepi/testbeds/planetlab/tunproto.py b/src/nepi/testbeds/planetlab/tunproto.py index a9f4888a..a9f283e8 100644 --- a/src/nepi/testbeds/planetlab/tunproto.py +++ b/src/nepi/testbeds/planetlab/tunproto.py @@ -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 diff --git a/src/nepi/util/server.py b/src/nepi/util/server.py index f153ab24..8c164fd5 100644 --- a/src/nepi/util/server.py +++ b/src/nepi/util/server.py @@ -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 diff --git a/test/testbeds/planetlab/execute.py b/test/testbeds/planetlab/execute.py index 01671f4c..3ee224e0 100755 --- a/test/testbeds/planetlab/execute.py +++ b/test/testbeds/planetlab/execute.py @@ -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