Skip to content

Commit

Permalink
[collect] Review suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: Trevor Benson <trevor.benson@gmail.com>
  • Loading branch information
TrevorBenson committed Dec 2, 2024
1 parent 2922e7b commit 3d35b2f
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 11 deletions.
5 changes: 2 additions & 3 deletions sos/collector/sosnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -777,9 +777,8 @@ def execute_sos_command(self):
else:
config_file_arg = (
f'--config-file={self.opts.config_file}')
self.sos_cmd = (
f"{self.sos_cmd} {config_file_arg}"
if config_file_arg else self.sos_cmd)
if config_file_arg:
self.sos_cmd = f"{self.sos_cmd} {config_file_arg}"
res = self.run_command(self.sos_cmd,
timeout=self.opts.timeout,
use_shell=True,
Expand Down
2 changes: 1 addition & 1 deletion sos/collector/transports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ def copy_file_to_remote(self, fname, dest):
if ret:
return True
self.log_info(f"File copy attempt {attempts} failed")
self.log_info("File copy failed after 5 attempts")
self.log_info("File copy failed after 3 attempts")
return False
except Exception as err:
self.log_error("Exception encountered during config copy attempt "
Expand Down
3 changes: 1 addition & 2 deletions sos/collector/transports/control_persist.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ def remote_exec(self):
def _copy_file_to_remote(self, fname, dest):
cmd = (f"/usr/bin/scp -oControlPath={self.control_path} "
f"{fname} {self.opts.ssh_user}@{self.address}:{dest}")
res = sos_get_command_output(cmd,
timeout=10)
res = sos_get_command_output(cmd, timeout=10)
return res['status'] == 0

def _retrieve_file(self, fname, dest):
Expand Down
3 changes: 1 addition & 2 deletions sos/collector/transports/juju.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ def _copy_file_to_remote(self, fname, dest):
model, unit = self.address.split(":")
model_option = f"-m {model}" if model else ""
cmd = f"juju scp {model_option} -- {fname} {unit}:{dest}"
res = sos_get_command_output(cmd,
timeout=15)
res = sos_get_command_output(cmd, timeout=15)
return res["status"] == 0

def _retrieve_file(self, fname, dest):
Expand Down
2 changes: 1 addition & 1 deletion sos/collector/transports/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def _format_cmd_for_exec(self, cmd):
return cmd

def _copy_file_to_remote(self, fname, dest):
pass
return True

def _read_file(self, fname):
if os.path.exists(fname):
Expand Down
3 changes: 1 addition & 2 deletions sos/collector/transports/saltstack.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ def _salt_copy_file(self, node, fname, dest):
Execute cp.get_file on the remote host using SaltStack Master
"""
cmd = f"salt-cp {node} {fname} {dest}"
res = sos_get_command_output(cmd,
timeout=15)
res = sos_get_command_output(cmd, timeout=15)
return res['status'] == 0

def _salt_retrieve_file(self, node, fname, dest):
Expand Down

0 comments on commit 3d35b2f

Please sign in to comment.