- jump_host_name = self._config.get("jump_host", None)
- self.jump_connection = None
- if jump_host_name is not None:
- host = self._context.get(jump_host_name, None)
-
- LOG.debug("jump_host ip:%s user:%s", host['ip'], host['user'])
- self.jump_connection = ssh.SSH.from_node(
- host,
- # why do we allow pwd for password?
- defaults={"user": "root", "password": host.get("pwd")}
- )
- self.jump_connection.wait(timeout=600)
- LOG.debug("ssh jump host success!")
-
- if self.jump_connection is not None:
- with open(self.recovery_script, "r") as stdin_file:
- self.jump_connection.execute(
- "sudo /bin/bash -s {0} {1} {2} {3}".format(
- self.ipmi_ip, self.ipmi_user, self.ipmi_pwd, "on"),
- stdin=stdin_file)
- else:
- _execute_shell_command(
- "sudo /bin/bash -s {0} {1} {2} {3}".format(
- self.ipmi_ip, self.ipmi_user, self.ipmi_pwd, "on"),
- stdin=open(self.recovery_script, "r"))
+ LOG.info("Recover fault START")
+ cmd = "sudo /bin/bash -s {0} {1} {2} {3}".format(
+ self.ipmi_ip, self.ipmi_user, self.ipmi_pwd, "on")
+ with open(self.recovery_script, "r") as stdin_file:
+ if self.jump_connection is not None:
+ self.jump_connection.execute(cmd, stdin=stdin_file)
+ else:
+ _execute_shell_command(cmd, stdin=stdin_file)
+ LOG.info("Recover fault END")