engine, pve : sélection d'objets, empreinte de plan, journal d'apply, CA en ligne

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015a8P6WMRPeqdpd5VCh6jAy
This commit is contained in:
claude BotandClaude Opus 5.5 committed 2026-10-13 15:53:59 +02:00
1 parent 0b53bad1c1
commit b597830360
6 files changed
+326 -8

No files matched your search

+12 -1
View File
@@ -24,6 +24,8 @@ type Result struct {
Client string `json:"client"`
Steps []Step `json:"steps"`
Err error `json:"-"`
notify func(Step)
}
func (r *Result) log(action string, err error) {
@@ -32,6 +34,9 @@ func (r *Result) log(action string, err error) {
s.Error = err.Error()
}
r.Steps = append(r.Steps, s)
if r.notify != nil {
r.notify(s)
}
}
// TaskPoll is the poll interval of the SDN reload task.
@@ -42,9 +47,15 @@ var TaskPoll = 2 * time.Second
// committed with PUT /cluster/sdn. Any failure before the commit rolls the
// pending SDN changes back (POST /cluster/sdn/rollback).
func Apply(ctx context.Context, c *pve.Client, plan Plan) Result {
res := Result{Client: plan.Client}
return ApplyWithLog(ctx, c, plan, nil)
}
// ApplyWithLog is Apply calling notify after each step (live journal of the web UI).
func ApplyWithLog(ctx context.Context, c *pve.Client, plan Plan, notify func(Step)) Result {
res := Result{Client: plan.Client, notify: notify}
if len(plan.Errors) > 0 {
res.Err = fmt.Errorf("plan has %d error(s), nothing applied", len(plan.Errors))
res.log("plan check", res.Err)
return res
}
if _, err := c.CheckVersion(ctx); err != nil {