feat(actions): scoped Proxmox power channel

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
root
2026-06-04 21:40:20 +10:00
parent 2c3d78c99b
commit c9268f8792
2 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
// Proxmox guest power via a SCOPED PVEAPIToken (VM.PowerMgmt on whitelisted guests
// only). PVE enforces permissions server-side; this adapter never builds shell commands.
export async function powerGuest({ node, vmid, op, kindPath = 'lxc' }, {
apiUrl = process.env.PROXMOX_API_URL,
token = process.env.PROXMOX_API_TOKEN,
fetchImpl = fetch
} = {}) {
const url = `${apiUrl}/api2/json/nodes/${node}/${kindPath}/${vmid}/status/${op}`;
const res = await fetchImpl(url, {
method: 'POST',
headers: { Authorization: `PVEAPIToken=${token}` }
});
if (!res.ok) throw new Error(`proxmox ${op} ${vmid}${res.status} ${await res.text?.() ?? ''}`);
const body = await res.json();
return { ok: true, upid: body?.data ?? null };
}