cleaning up debgging for import

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-31 17:17:10 -05:00
parent 3562fc780e
commit efc3032d83
1 changed files with 13 additions and 25 deletions

42
poll.go
View File

@ -33,40 +33,28 @@ func (h *HyperT) pollHypervisor() {
}
state := fields[0]
name := fields[1]
if state == "OFF" {
start := fmt.Sprintf("%-9s %-20s", h.pb.Hostname, name)
d := me.cluster.FindDropletByName(name)
if d == nil {
log.Log(WARN, "local", h.pb.Hostname, name, "locally defined domain")
log.Log(WARN, "local", h.pb.Hostname, name, "Running AddDropletLocal()")
log.Log(WARN, "local", h.pb.Hostname, name, "Running AddDropletLocal()")
log.Log(WARN, "local", h.pb.Hostname, name, "Running AddDropletLocal()")
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.LocalOnly == "" {
log.Log(WARN, "local", h.pb.Hostname, name, "duplicate defined (need to resolve this)")
continue
}
log.Log(WARN, "local", h.pb.Hostname, name, "ready to import from hypervisor")
continue
}
h.lastDroplets[name] = time.Now()
// if _, ok := h.lastDroplets[name]; ok {
// h.lastDroplets[name] = time.Now()
// }
// try the protobuf
d := me.cluster.FindDropletByName(name)
if d == nil {
// not sure whawt now?
log.Log(WARN, name, "is unknown on", h.pb.Hostname, "state =", state)
log.Log(WARN, name, "this vm was probably started by hand using virtsh")
log.Log(WARN, name, "todo: import vm from libvrit")
if state == "OFF" {
if d.LocalOnly == "" {
log.Log(WARN, start, "local duplicate defined (need to resolve this)")
continue
}
log.Log(WARN, start, "local ready to import from hypervisor")
continue
}
if state == "ON" {
log.Log(POLL, h.pb.Hostname, "STATE:", state, "HOST:", name, "rest:", fields[2:])
log.Log(INFO, "ALREADY RECORDED", d.Hostname)
log.Log(POLL, start, "STATE:", state, "rest:", fields[2:])
// update the status to ON
d.Current.State = pb.DropletState_ON
@ -81,12 +69,12 @@ func (h *HyperT) pollHypervisor() {
// this should mean a droplet is running where the config file says it probably should be running
if d.PreferredHypervisor == h.pb.Hostname {
log.Log(EVENT, "poll shows new droplet", d.Hostname, "(matches config hypervisor", h.pb.Hostname+")")
log.Log(EVENT, start, "poll shows new droplet", d.Hostname, "(matches config hypervisor", h.pb.Hostname+")")
d.Current.Hypervisor = h.pb.Hostname
continue
}
log.Log(EVENT, "poll shows new droplet", d.Hostname, "on", h.pb.Hostname, "(in config file without preferred hypervisor)")
log.Log(EVENT, start, "poll shows new droplet (in config file without preferred hypervisor)")
d.Current.Hypervisor = h.pb.Hostname
continue
}