ajoute le self-healing des VM (sonde de santé, relance automatique, stock écarté) — bloc A, semaine 6
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
b054888f5a
commit
f2649d0f8b
21 changed files with 938 additions and 28 deletions
|
|
@ -8,6 +8,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
|
@ -56,6 +57,22 @@ func lireDomaine(ctx context.Context, instance string) (domaine, error) {
|
|||
return d, err
|
||||
}
|
||||
|
||||
// État libvirt du domaine : « running », « paused », « shut off », « crashed »…
|
||||
func etatDomaine(ctx context.Context, instance string) (string, error) {
|
||||
brut, err := virsh(ctx, "domstate", instance)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return strings.TrimSpace(string(brut)), nil
|
||||
}
|
||||
|
||||
// guest-ping : l'agent répond-il ? Un noyau planté ou une VM gelée ne
|
||||
// répondent plus.
|
||||
func pingAgent(ctx context.Context, instance string) error {
|
||||
_, err := virsh(ctx, "qemu-agent-command", instance, `{"execute":"guest-ping"}`, "--timeout", "3")
|
||||
return err
|
||||
}
|
||||
|
||||
// Lance /bin/sh -c <commande> dans la VM (guest-exec), puis interroge
|
||||
// guest-exec-status jusqu'à la fin du processus.
|
||||
func executer(ctx context.Context, instance, commande string) (int, string, error) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue