self.con.flush()
def command(self, command):
- self.write("{}\n".format(command))
+ self.write("{}; echo \"END: $?\"\n".format(command))
# We need to read out the prompt for this command first
# If we do not do this we will break the loop immediately
data = self.readline()
self.log_console_line(data.decode())
+ # We saved our exit code in data (the last line)
+ self.log.debug(data.decode())
+ data = data.decode().replace("END: ", "")
+ self.log.debug(data)
+ self.log.debug(data.strip())
+ return data.strip()
+
# A class which define and undefine a virtual network based on an xml file
class network():
def run_recipe(self):
for line in self.recipe.recipe:
return_value = self.virtual_machines[line[0]].cmd(line[2])
- if not return_value and line[1] == "":
- self.log.error("Failed to execute command '{}' on {}".format(line[2],line[0]))
+ self.log.debug("Return value is: {}".format(return_value))
+ if return_value != "0" and line[1] == "":
+ self.log.error("Failed to execute command '{}' on {}, return code: {}".format(line[2],line[0], return_value))
return False
- elif return_value == True and line[1] == "!":
- self.log.error("Succeded to execute command '{}' on {}".format(line[2],line[0]))
+ elif return_value == "0" and line[1] == "!":
+ self.log.error("Succeded to execute command '{}' on {}, return code: {}".format(line[2],line[0],return_value))
return False
+ else:
+ self.log.debug("Command '{}' on {} returned with: {}".format(line[2],line[0],return_value))
def virtual_environ_stop(self):
for name in self.virtual_environ.machine_names: