aboutsummaryrefslogtreecommitdiff
path: root/rumba/testbeds/emulab.py
diff options
context:
space:
mode:
Diffstat (limited to 'rumba/testbeds/emulab.py')
-rw-r--r--rumba/testbeds/emulab.py45
1 files changed, 38 insertions, 7 deletions
diff --git a/rumba/testbeds/emulab.py b/rumba/testbeds/emulab.py
index 66c5b7f..7568815 100644
--- a/rumba/testbeds/emulab.py
+++ b/rumba/testbeds/emulab.py
@@ -102,6 +102,8 @@ class Testbed(mod.Testbed):
Swaps experiment in
@param self: testbed info
+
+ @return: Is the experiment newly swapped in
"""
cmd = '/usr/testbed/bin/sslxmlrpc_client.py swapexp proj=' + \
self.proj_name + \
@@ -109,9 +111,17 @@ class Testbed(mod.Testbed):
self.exp_name + \
' direction=in'
- output = ssh.execute_command(self, self.ops_ssh_config, cmd)
+ try:
+ ssh.execute_command(self, self.ops_ssh_config, cmd)
+ except ssh.SSHException as e:
+ line = re.findall(r'not swapped out', str(e))
+ if line:
+ logger.info("Experiment is already swapped in.")
+ return False
+ else:
+ raise e
- return output
+ return True
def _create_experiment(self, experiment):
"""
@@ -142,9 +152,14 @@ class Testbed(mod.Testbed):
'" exp="' + exp_name + '" noswapin=true ' + \
'nsfilepath="' + dest_file_name + '"'
- ssh.execute_command(self, self.ops_ssh_config, cmd, time_out=None)
- ssh.execute_command(self, self.ops_ssh_config, 'rm ' + dest_file_name)
- logger.info("New experiment succesfully created.")
+ try:
+ ssh.execute_command(self, self.ops_ssh_config, cmd, time_out=None)
+ logger.info("New experiment succesfully created.")
+ except:
+ logger.info("Experiment already exists.")
+ finally:
+ ssh.execute_command(self, self.ops_ssh_config,
+ 'rm ' + dest_file_name)
def generate_ns_script(self, experiment):
"""
@@ -250,6 +265,22 @@ class Testbed(mod.Testbed):
def swap_in(self, experiment):
self._create_experiment(experiment)
- self.swap_exp_in()
- self.wait_until_nodes_up()
+ wait = self.swap_exp_in()
+ if wait:
+ self.wait_until_nodes_up()
self.complete_experiment_graph(experiment)
+
+
+ def swap_out(self, experiment):
+ """
+ Swaps experiment out
+
+ @param self: testbed info
+ """
+ cmd = '/usr/testbed/bin/sslxmlrpc_client.py swapexp proj=' + \
+ self.proj_name + \
+ ' exp=' + \
+ self.exp_name + \
+ ' direction=out'
+
+ ssh.execute_command(self, self.ops_ssh_config, cmd)