add droplet() defaults to start state=off

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-31 22:14:11 -05:00
parent efc3032d83
commit d51c4627f7
2 changed files with 23 additions and 10 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt"
"net/http"
pb "go.wit.com/lib/protobuf/virtbuf"
"go.wit.com/log"
)
@ -28,8 +29,20 @@ func importDomain(w http.ResponseWriter, r *http.Request) (string, error) {
fmt.Fprintln(w, result)
return result, errors.New(result)
}
result := "libvirt domain " + name + " found on " + d.Current.Hypervisor
log.Info(result)
start := fmt.Sprintf("%-9s %-20s", d.Current.Hypervisor, name)
if d.Current.State != pb.DropletState_OFF {
result := "libvirt domain " + name + " found on " + d.Current.Hypervisor
log.Info(result)
fmt.Fprintln(w, result)
}
if d.LocalOnly == "" {
result := start + " local duplicate defined (need to resolve this)"
log.Log(WARN, result)
fmt.Fprintln(w, result)
return result, nil
}
result := start + " local ready to import from hypervisor"
log.Log(WARN, result)
fmt.Fprintln(w, result)
return result, nil
}

16
poll.go
View File

@ -35,14 +35,14 @@ func (h *HyperT) pollHypervisor() {
name := fields[1]
start := fmt.Sprintf("%-9s %-20s", h.pb.Hostname, name)
d := me.cluster.FindDropletByName(name)
if d == nil {
log.Log(WARN, start, "local defined domain")
log.Log(WARN, start, "local Running AddDropletLocal()")
log.Log(WARN, start, "local Running AddDropletLocal()")
log.Log(WARN, start, "local Running AddDropletLocal()")
me.cluster.AddDropletLocal(name, h.pb.Hostname)
return
}
if d == nil {
log.Log(WARN, start, "local defined domain")
log.Log(WARN, start, "local Running AddDropletLocal()")
log.Log(WARN, start, "local Running AddDropletLocal()")
log.Log(WARN, start, "local Running AddDropletLocal()")
me.cluster.AddDropletLocal(name, h.pb.Hostname)
return
}
h.lastDroplets[name] = time.Now()
if state == "OFF" {
if d.LocalOnly == "" {