59 lines
2.1 KiB
PHP
59 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Proxmox;
|
|
|
|
use App\Models\Host;
|
|
|
|
/**
|
|
* Proxmox VE REST client, addressed per host over its wg_ip with a token.
|
|
* A v1.0 uses it read-only (capacity + reachability); the automation token is
|
|
* bootstrapped over SSH (pveum). Subsystem B extends it with VM lifecycle
|
|
* methods (clone, cloud-init, guestExec …).
|
|
*/
|
|
interface ProxmoxClient
|
|
{
|
|
/** Configure this client for a host (base URL from wg_ip, token from api_token_ref). */
|
|
public function forHost(Host $host): static;
|
|
|
|
/** @return array<int, array<string, mixed>> */
|
|
public function listNodes(): array;
|
|
|
|
/** @return array<string, mixed> */
|
|
public function nodeStatus(string $node): array;
|
|
|
|
/** @return array<int, array<string, mixed>> */
|
|
public function nodeStorage(string $node): array;
|
|
|
|
// --- VM lifecycle (Subsystem B) ---
|
|
|
|
public function nextVmid(): int;
|
|
|
|
/** Clone a template to a new VM; returns the task UPID. */
|
|
public function cloneVm(string $node, int $templateVmid, int $newVmid, string $name): string;
|
|
|
|
/** @param array<string, mixed> $params */
|
|
public function setCloudInit(string $node, int $vmid, array $params): void;
|
|
|
|
public function resizeDisk(string $node, int $vmid, string $disk, string $size): void;
|
|
|
|
/** Start a VM; returns the task UPID. */
|
|
public function startVm(string $node, int $vmid): string;
|
|
|
|
/** @return array<string, mixed> ['status' => 'running'|'stopped', …] */
|
|
public function vmStatus(string $node, int $vmid): array;
|
|
|
|
/** Whether a VM with this id already exists on the node. */
|
|
public function vmExists(string $node, int $vmid): bool;
|
|
|
|
public function guestAgentPing(string $node, int $vmid): bool;
|
|
|
|
/** @return array{exitcode: int, out-data: string} */
|
|
public function guestExec(string $node, int $vmid, string $command): array;
|
|
|
|
/** @return array{status: string, exitstatus?: string} */
|
|
public function taskStatus(string $node, string $upid): array;
|
|
|
|
/** @param array<int, array<string, mixed>> $rules */
|
|
public function applyFirewall(string $node, int $vmid, array $rules): void;
|
|
}
|