From fbf1e87b391bf75e2fb20cf93c7d35d98f745e48 Mon Sep 17 00:00:00 2001 From: Mathieu Broillet Date: Wed, 14 Jun 2023 14:30:25 +0200 Subject: [PATCH] added exception to scp --- src/lxc/commands_utils.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lxc/commands_utils.py b/src/lxc/commands_utils.py index cf1d06d..2a3b48a 100644 --- a/src/lxc/commands_utils.py +++ b/src/lxc/commands_utils.py @@ -198,8 +198,10 @@ def copy_local_file_to_lxc(lxc: LXC, path: Path, destination: str): Path to the destination in the LXC """ - proxmox_utils.run_command_locally(command=f"scp -B {str(path)} {lxc.get_ssh_string()}:{destination}", - return_status_code=True) + command = proxmox_utils.run_command_locally(command=f"scp -B {str(path)} {lxc.get_ssh_string()}:{destination}", + return_status_code=True) + if command.returncode != 0: + raise Exception(f"Unable to copy file {str(path)} to LXC {lxc.get_id()} at {destination}, probably SSH key issue") def copy_local_folder_to_lxc(lxc: LXC, path: Path, destination: str): @@ -215,8 +217,10 @@ def copy_local_folder_to_lxc(lxc: LXC, path: Path, destination: str): Path to the destination in the LXC """ - proxmox_utils.run_command_locally(command=f"scp -B -r {str(path)} {lxc.get_ssh_string()}:{destination}", - return_status_code=True) + command = proxmox_utils.run_command_locally(command=f"scp -B -r {str(path)} {lxc.get_ssh_string()}:{destination}", + return_status_code=True) + if command.returncode != 0: + raise Exception(f"Unable to copy file {str(path)} to LXC {lxc.get_id()} at {destination}, probably SSH key issue") def run_docker_command(lxc: LXC, container: str, command: str):