feat: add vm power actions

This commit is contained in:
Philipp
2026-06-11 11:29:29 +02:00
parent 262ec4f91b
commit d08e41b013
14 changed files with 541 additions and 16 deletions
+22
View File
@@ -108,6 +108,28 @@ func TestClientGetsTaskStatus(t *testing.T) {
}
}
func TestClientPowersVM(t *testing.T) {
server := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method != http.MethodPost {
t.Fatalf("method = %s, want POST", r.Method)
}
if r.URL.Path != "/api2/json/nodes/pve/qemu/100/status/start" {
t.Fatalf("path = %q", r.URL.Path)
}
_, _ = w.Write([]byte(`{"data":"UPID:pve:1"}`))
}))
defer server.Close()
client := newTestClient(t, server, fingerprintForServer(server))
upid, err := client.PowerVM(context.Background(), "pve", 100, "start")
if err != nil {
t.Fatalf("PowerVM() error = %v", err)
}
if upid != "UPID:pve:1" {
t.Fatalf("UPID = %q, want UPID:pve:1", upid)
}
}
func TestNewClientRejectsInvalidFingerprint(t *testing.T) {
_, err := NewClient(cluster.Cluster{
APIEndpoint: "https://pve.example.test:8006/api2/json",