ssh: refactor callers to use new Host interface

This commit is contained in:
DavHau
2025-07-29 16:39:59 +07:00
committed by Jörg Thalheim
parent c33fd4e504
commit b74193514d
24 changed files with 56 additions and 54 deletions

View File

@@ -10,7 +10,7 @@ def create_backup(machine: Machine, provider: str | None = None) -> None:
if not backup_scripts["providers"]:
msg = "No providers specified"
raise ClanError(msg)
with host.ssh_control_master() as ssh:
with host.host_connection() as ssh:
for provider in backup_scripts["providers"]:
proc = ssh.run(
[backup_scripts["providers"][provider]["create"]],
@@ -23,7 +23,7 @@ def create_backup(machine: Machine, provider: str | None = None) -> None:
if provider not in backup_scripts["providers"]:
msg = f"provider {provider} not found"
raise ClanError(msg)
with host.ssh_control_master() as ssh:
with host.host_connection() as ssh:
proc = ssh.run(
[backup_scripts["providers"][provider]["create"]],
)

View File

@@ -43,7 +43,7 @@ def list_provider(machine: Machine, host: Remote, provider: str) -> list[Backup]
def list_backups(machine: Machine, provider: str | None = None) -> list[Backup]:
backup_metadata = machine.select("config.clan.core.backups")
results = []
with machine.target_host().ssh_control_master() as host:
with machine.target_host().host_connection() as host:
if provider is None:
for _provider in backup_metadata["providers"]:
results += list_provider(machine, host, _provider)

View File

@@ -20,7 +20,7 @@ def restore_service(
# FIXME: If we have too many folder this might overflow the stack.
env["FOLDERS"] = ":".join(set(folders))
with host.ssh_control_master() as ssh:
with host.host_connection() as ssh:
if pre_restore := backup_folders[service]["preRestoreCommand"]:
proc = ssh.run(
[pre_restore],
@@ -58,7 +58,7 @@ def restore_backup(
service: str | None = None,
) -> None:
errors = []
with machine.target_host().ssh_control_master() as host:
with machine.target_host().host_connection() as host:
if service is None:
backup_folders = machine.select("config.clan.core.state")
for _service in backup_folders: