rename machine.host to machine.target_host

This commit is contained in:
Jörg Thalheim 2024-02-06 15:55:34 +01:00
parent 6e57122da8
commit 2315dba2a9
8 changed files with 11 additions and 11 deletions

View File

@ -13,7 +13,7 @@ def create_backup(machine: Machine, provider: str | None = None) -> None:
backup_scripts = json.loads(machine.eval_nix("config.clanCore.backups"))
if provider is None:
for provider in backup_scripts["providers"]:
proc = machine.host.run(
proc = machine.target_host.run(
["bash", "-c", backup_scripts["providers"][provider]["create"]],
)
if proc.returncode != 0:
@ -23,7 +23,7 @@ def create_backup(machine: Machine, provider: str | None = None) -> None:
else:
if provider not in backup_scripts["providers"]:
raise ClanError(f"provider {provider} not found")
proc = machine.host.run(
proc = machine.target_host.run(
["bash", "-c", backup_scripts["providers"][provider]["create"]],
)
if proc.returncode != 0:

View File

@ -19,7 +19,7 @@ class Backup:
def list_provider(machine: Machine, provider: str) -> list[Backup]:
results = []
backup_metadata = json.loads(machine.eval_nix("config.clanCore.backups"))
proc = machine.host.run(
proc = machine.target_host.run(
["bash", "-c", backup_metadata["providers"][provider]["list"]],
stdout=subprocess.PIPE,
check=False,

View File

@ -20,7 +20,7 @@ def restore_service(
env["JOB"] = backup.job_name
env["FOLDERS"] = ":".join(folders)
proc = machine.host.run(
proc = machine.target_host.run(
[
"bash",
"-c",
@ -34,7 +34,7 @@ def restore_service(
f"failed to run preRestoreScript: {backup_folders[service]['preRestoreScript']}, error was: {proc.stdout}"
)
proc = machine.host.run(
proc = machine.target_host.run(
[
"bash",
"-c",
@ -48,7 +48,7 @@ def restore_service(
f"failed to restore backup: {backup_metadata['providers'][provider]['restore']}"
)
proc = machine.host.run(
proc = machine.target_host.run(
[
"bash",
"-c",

View File

@ -19,7 +19,7 @@ def install_nixos(machine: Machine, kexec: str | None = None) -> None:
log.info(f"using secret store: {secrets_module.SecretStore}")
secret_store = secrets_module.SecretStore(machine=machine)
h = machine.host
h = machine.target_host
target_host = f"{h.user or 'root'}@{h.host}"
log.info(f"target host: {target_host}")

View File

@ -92,7 +92,7 @@ class Machine:
return Path(self.flake_path)
@property
def host(self) -> Host:
def target_host(self) -> Host:
return parse_deployment_address(
self.name, self.target_host_address, meta={"machine": self}
)

View File

@ -182,7 +182,7 @@ def get_selected_machines(machine_names: list[str], flake_dir: Path) -> HostGrou
hosts = []
for name in machine_names:
machine = Machine(name=name, flake=flake_dir)
hosts.append(machine.host)
hosts.append(machine.target_host)
return HostGroup(hosts)

View File

@ -86,7 +86,7 @@ class SecretStore:
def update_check(self) -> bool:
local_hash = self.generate_hash()
remote_hash = self.machine.host.run(
remote_hash = self.machine.target_host.run(
# TODO get the path to the secrets from the machine
["cat", f"{self.machine.secrets_upload_directory}/.pass_info"],
check=False,

View File

@ -22,7 +22,7 @@ def upload_secrets(machine: Machine) -> None:
return
with TemporaryDirectory() as tempdir:
secret_store.upload(Path(tempdir))
host = machine.host
host = machine.target_host
ssh_cmd = host.ssh_cmd()
run(