Skip to content

Commit

Permalink
Merge pull request #10741 from dahorak/fix-baremetal-ai-deployment-on…
Browse files Browse the repository at this point in the history
…-octo-argo

fix BM AI deployment on octo argo
  • Loading branch information
petr-balogh authored Oct 29, 2024
2 parents 41548df + 7abefd1 commit 0e7dfb8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
14 changes: 12 additions & 2 deletions ocs_ci/deployment/baremetal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1174,7 +1174,12 @@ def set_pxe_boot_and_reboot(self, machine):
f"-P {self.srv_details[machine]['mgmt_password']} "
f"-H {self.srv_details[machine]['mgmt_console']} chassis bootdev pxe"
)
self.helper_node_handler.exec_cmd(cmd=cmd, secrets=secrets)
rc, stdout, stderr = self.helper_node_handler.exec_cmd(
cmd=cmd, secrets=secrets
)
assert (
rc == 0
), f"Command execution failed - rc: {rc}, stdout: '{stdout}', stderr: '{stderr}'"
logger.info(
"Sleeping for 2 Sec to make sure bootdev pxe is set properly using ipmitool cmd"
)
Expand All @@ -1188,7 +1193,12 @@ def set_pxe_boot_and_reboot(self, machine):
f"-P {self.srv_details[machine]['mgmt_password']} "
f"-H {self.srv_details[machine]['mgmt_console']} chassis power on"
)
self.helper_node_handler.exec_cmdrun_cmd(cmd=cmd, secrets=secrets)
rc, stdout, stderr = self.helper_node_handler.exec_cmd(
cmd=cmd, secrets=secrets
)
assert (
rc == 0
), f"Command execution failed - rc: {rc}, stdout: '{stdout}', stderr: '{stderr}'"

elif (
self.srv_details[machine].get("mgmt_provider", "ipmitool") == "ibmcloud"
Expand Down
19 changes: 14 additions & 5 deletions ocs_ci/utility/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,18 +104,25 @@ def _jump_channel(self, jump_host):
logger.debug("SSH Jump host channel were created.")
return jump_channel

def exec_cmd(self, cmd):
def exec_cmd(self, cmd, secrets=None):
"""
Executes command on server
Args:
cmd (str): Command to run on server
secrets (list): A list of secrets to be masked with asterisks
This kwarg is popped in order to not interfere with
subprocess.run(``**kwargs``)
Returns:
tuple: tuple which contains command return code, output and error
"""
logger.info(f"Executing cmd: {cmd} on {self.host}")
# importing it here to avoid circular import issue
from ocs_ci.utility.utils import mask_secrets

masked_cmd = mask_secrets(cmd, secrets)
logger.info(f"Executing cmd: {masked_cmd} on {self.host}")
_, out, err = self.client.exec_command(cmd)
retcode = out.channel.recv_exit_status()
stdout = out.read().decode("utf-8").strip("\n")
Expand All @@ -124,10 +131,12 @@ def exec_cmd(self, cmd):
except UnicodeDecodeError:
stderr = err.read()
logger.debug(f"retcode: {retcode}")
logger.info(f"stdout: {stdout}") if self.stdout else logger.debug(
f"stdout: {stdout}"
masked_stdout = mask_secrets(stdout, secrets)
logger.info(f"stdout: {masked_stdout}") if self.stdout else logger.debug(
f"stdout: {masked_stdout}"
)
logger.debug(f"stderr: {stderr}")
masked_stderr = mask_secrets(stderr, secrets)
logger.debug(f"stderr: {masked_stderr}")
return (retcode, stdout, stderr)

def upload_file(self, localpath, remotepath):
Expand Down

0 comments on commit 0e7dfb8

Please sign in to comment.