rename machine.host to machine.target_host
This commit is contained in:
parent
6e57122da8
commit
2315dba2a9
@ -13,7 +13,7 @@ def create_backup(machine: Machine, provider: str | None = None) -> None:
|
|||||||
backup_scripts = json.loads(machine.eval_nix("config.clanCore.backups"))
|
backup_scripts = json.loads(machine.eval_nix("config.clanCore.backups"))
|
||||||
if provider is None:
|
if provider is None:
|
||||||
for provider in backup_scripts["providers"]:
|
for provider in backup_scripts["providers"]:
|
||||||
proc = machine.host.run(
|
proc = machine.target_host.run(
|
||||||
["bash", "-c", backup_scripts["providers"][provider]["create"]],
|
["bash", "-c", backup_scripts["providers"][provider]["create"]],
|
||||||
)
|
)
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
@ -23,7 +23,7 @@ def create_backup(machine: Machine, provider: str | None = None) -> None:
|
|||||||
else:
|
else:
|
||||||
if provider not in backup_scripts["providers"]:
|
if provider not in backup_scripts["providers"]:
|
||||||
raise ClanError(f"provider {provider} not found")
|
raise ClanError(f"provider {provider} not found")
|
||||||
proc = machine.host.run(
|
proc = machine.target_host.run(
|
||||||
["bash", "-c", backup_scripts["providers"][provider]["create"]],
|
["bash", "-c", backup_scripts["providers"][provider]["create"]],
|
||||||
)
|
)
|
||||||
if proc.returncode != 0:
|
if proc.returncode != 0:
|
||||||
|
@ -19,7 +19,7 @@ class Backup:
|
|||||||
def list_provider(machine: Machine, provider: str) -> list[Backup]:
|
def list_provider(machine: Machine, provider: str) -> list[Backup]:
|
||||||
results = []
|
results = []
|
||||||
backup_metadata = json.loads(machine.eval_nix("config.clanCore.backups"))
|
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"]],
|
["bash", "-c", backup_metadata["providers"][provider]["list"]],
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
check=False,
|
check=False,
|
||||||
|
@ -20,7 +20,7 @@ def restore_service(
|
|||||||
env["JOB"] = backup.job_name
|
env["JOB"] = backup.job_name
|
||||||
env["FOLDERS"] = ":".join(folders)
|
env["FOLDERS"] = ":".join(folders)
|
||||||
|
|
||||||
proc = machine.host.run(
|
proc = machine.target_host.run(
|
||||||
[
|
[
|
||||||
"bash",
|
"bash",
|
||||||
"-c",
|
"-c",
|
||||||
@ -34,7 +34,7 @@ def restore_service(
|
|||||||
f"failed to run preRestoreScript: {backup_folders[service]['preRestoreScript']}, error was: {proc.stdout}"
|
f"failed to run preRestoreScript: {backup_folders[service]['preRestoreScript']}, error was: {proc.stdout}"
|
||||||
)
|
)
|
||||||
|
|
||||||
proc = machine.host.run(
|
proc = machine.target_host.run(
|
||||||
[
|
[
|
||||||
"bash",
|
"bash",
|
||||||
"-c",
|
"-c",
|
||||||
@ -48,7 +48,7 @@ def restore_service(
|
|||||||
f"failed to restore backup: {backup_metadata['providers'][provider]['restore']}"
|
f"failed to restore backup: {backup_metadata['providers'][provider]['restore']}"
|
||||||
)
|
)
|
||||||
|
|
||||||
proc = machine.host.run(
|
proc = machine.target_host.run(
|
||||||
[
|
[
|
||||||
"bash",
|
"bash",
|
||||||
"-c",
|
"-c",
|
||||||
|
@ -19,7 +19,7 @@ def install_nixos(machine: Machine, kexec: str | None = None) -> None:
|
|||||||
log.info(f"using secret store: {secrets_module.SecretStore}")
|
log.info(f"using secret store: {secrets_module.SecretStore}")
|
||||||
secret_store = secrets_module.SecretStore(machine=machine)
|
secret_store = secrets_module.SecretStore(machine=machine)
|
||||||
|
|
||||||
h = machine.host
|
h = machine.target_host
|
||||||
target_host = f"{h.user or 'root'}@{h.host}"
|
target_host = f"{h.user or 'root'}@{h.host}"
|
||||||
log.info(f"target host: {target_host}")
|
log.info(f"target host: {target_host}")
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ class Machine:
|
|||||||
return Path(self.flake_path)
|
return Path(self.flake_path)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def host(self) -> Host:
|
def target_host(self) -> Host:
|
||||||
return parse_deployment_address(
|
return parse_deployment_address(
|
||||||
self.name, self.target_host_address, meta={"machine": self}
|
self.name, self.target_host_address, meta={"machine": self}
|
||||||
)
|
)
|
||||||
|
@ -182,7 +182,7 @@ def get_selected_machines(machine_names: list[str], flake_dir: Path) -> HostGrou
|
|||||||
hosts = []
|
hosts = []
|
||||||
for name in machine_names:
|
for name in machine_names:
|
||||||
machine = Machine(name=name, flake=flake_dir)
|
machine = Machine(name=name, flake=flake_dir)
|
||||||
hosts.append(machine.host)
|
hosts.append(machine.target_host)
|
||||||
return HostGroup(hosts)
|
return HostGroup(hosts)
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ class SecretStore:
|
|||||||
|
|
||||||
def update_check(self) -> bool:
|
def update_check(self) -> bool:
|
||||||
local_hash = self.generate_hash()
|
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
|
# TODO get the path to the secrets from the machine
|
||||||
["cat", f"{self.machine.secrets_upload_directory}/.pass_info"],
|
["cat", f"{self.machine.secrets_upload_directory}/.pass_info"],
|
||||||
check=False,
|
check=False,
|
||||||
|
@ -22,7 +22,7 @@ def upload_secrets(machine: Machine) -> None:
|
|||||||
return
|
return
|
||||||
with TemporaryDirectory() as tempdir:
|
with TemporaryDirectory() as tempdir:
|
||||||
secret_store.upload(Path(tempdir))
|
secret_store.upload(Path(tempdir))
|
||||||
host = machine.host
|
host = machine.target_host
|
||||||
|
|
||||||
ssh_cmd = host.ssh_cmd()
|
ssh_cmd = host.ssh_cmd()
|
||||||
run(
|
run(
|
||||||
|
Loading…
Reference in New Issue
Block a user