From 91c87d35e3c9eeee43788f4acab2e6567bbb9c7d Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Fri, 12 Jan 2018 16:07:52 +0100 Subject: testbeds: Add check for jFed return value This adds a check for the return value whenever jFed is called. It avoids Rumba trying to continue on an experiment that failed to swap in. Fixes #37 --- rumba/testbeds/jfed.py | 50 +++++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/rumba/testbeds/jfed.py b/rumba/testbeds/jfed.py index ac54042..5bf07d4 100644 --- a/rumba/testbeds/jfed.py +++ b/rumba/testbeds/jfed.py @@ -195,10 +195,13 @@ class Testbed(mod.Testbed): file.close() def swap_out(self, experiment): - subprocess.call(["java", "-jar", self.jfed_jar, "delete", "-S", - self.proj_name, "-s", - self.exp_name, "-p", self.cert_file, - "-P", self.password]) + try: + subprocess.check_call(["java", "-jar", self.jfed_jar, "delete", + "-S", self.proj_name, "-s", self.exp_name, + "-p", self.cert_file, "-P", self.password]) + except subprocess.CalledProcessError as e: + logger.error("jFed returned with error " + str(e.returncode)) + raise def swap_in(self, experiment): for node in experiment.nodes: @@ -211,23 +214,32 @@ class Testbed(mod.Testbed): node.ssh_config.username = self.username node.ssh_config.password = self.password - subprocess.call(["java", "-jar", self.jfed_jar, "create", "-S", - self.proj_name, "--rspec", - self.rspec, "-s", - self.exp_name, "-p", self.cert_file, "-k", - "usercert,userkeys,shareduserallkeys", - "--create-slice", - "--manifest", self.manifest, - "-P", self.password, - "-e", self.exp_hours]) + logger.info("Launching jFed...") + + try: + subprocess.check_call(["java", "-jar", self.jfed_jar, "create", + "-S", self.proj_name, "--rspec", + self.rspec, "-s", self.exp_name, "-p", + self.cert_file, "-k", + "usercert,userkeys,shareduserallkeys", + "--create-slice", "--manifest", + self.manifest, "-P", self.password, + "-e", self.exp_hours]) + except subprocess.CalledProcessError as e: + logger.error("jFed returned with error " + str(e.returncode)) + raise if "exogeni" in self.auth_name: - subprocess.call(["java", "-jar", self.jfed_jar, - "manifest", "-S", self.proj_name, - "-s", self.exp_name, - "-p", self.cert_file, - "--manifest", self.manifest, - "-P", self.password]) + try: + subprocess.check_call(["java", "-jar", self.jfed_jar, + "manifest", "-S", self.proj_name, + "-s", self.exp_name, + "-p", self.cert_file, + "--manifest", self.manifest, + "-P", self.password]) + except subprocess.CalledProcessError as e: + logger.error("jFed returned with error " + str(e.returncode)) + raise rspec = xml.parse(self.manifest) xml_nodes = rspec.getElementsByTagName("node") -- cgit v1.2.3