added exception to scp

This commit is contained in:
Mathieu Broillet 2023-06-14 14:30:25 +02:00
parent c6439c6899
commit fbf1e87b39
No known key found for this signature in database
GPG Key ID: 7D4F25BC50A0AA32

View File

@ -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}",
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}",
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):