From 3feaa93ba0d6cb2a1cff6591871f25701a3f70b1 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 26 Sep 2024 16:59:44 +0200 Subject: [PATCH] cls_cmd: print the host on which a command is executed --- ci-scripts/cls_cmd.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ci-scripts/cls_cmd.py b/ci-scripts/cls_cmd.py index c934479dbe..cef99964be 100644 --- a/ci-scripts/cls_cmd.py +++ b/ci-scripts/cls_cmd.py @@ -101,7 +101,7 @@ class LocalCmd(Cmd): def run(self, line, timeout=300, silent=False, reportNonZero=True): if not silent: - logging.info(line) + logging.info(f"local> {line}") try: if line.strip().endswith('&'): # if we wait for stdout, subprocess does not return before the end of the command @@ -168,6 +168,7 @@ class RemoteCmd(Cmd): def __init__(self, hostname, d=None): cIdx = 0 + self.hostname = hostname logging.getLogger('paramiko').setLevel(logging.ERROR) # prevent spamming through Paramiko self.client = paramiko.SSHClient() self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) @@ -205,7 +206,7 @@ class RemoteCmd(Cmd): def run(self, line, timeout=300, silent=False, reportNonZero=True): if not silent: - logging.info(line) + logging.info(f"ssh[{self.hostname}]> {line}") if self.cwd: line = f"cd {self.cwd} && {line}" try: @@ -235,7 +236,7 @@ class RemoteCmd(Cmd): # if recursive is True, tgt must be a directory (and src is file or directory) # if recursive is False, tgt and src must be a file name def copyout(self, src, tgt, recursive=False): - logging.debug(f"copyout: local:{src} -> remote:{tgt}") + logging.debug(f"copyout: local:{src} -> {self.hostname}:{tgt}") if recursive: tmpfile = f"{uuid.uuid4()}.tar" abstmpfile = f"/tmp/{tmpfile}" @@ -253,7 +254,7 @@ class RemoteCmd(Cmd): # if recursive is True, tgt must be a directory (and src is file or directory) # if recursive is False, tgt and src must be a file name def copyin(self, src, tgt, recursive=False): - logging.debug(f"copyin: remote:{src} -> local:{tgt}") + logging.debug(f"copyin: {self.hostname}:{src} -> local:{tgt}") if recursive: tmpfile = f"{uuid.uuid4()}.tar" abstmpfile = f"/tmp/{tmpfile}"