From efc3032d8352a05226956eb13011a985f3e7caba Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 31 Oct 2024 17:17:10 -0500 Subject: [PATCH] cleaning up debgging for import Signed-off-by: Jeff Carr --- poll.go | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/poll.go b/poll.go index bac7fc0..2e3637e 100644 --- a/poll.go +++ b/poll.go @@ -33,40 +33,28 @@ func (h *HyperT) pollHypervisor() { } state := fields[0] name := fields[1] - if state == "OFF" { - d := me.cluster.FindDropletByName(name) + 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 } + h.lastDroplets[name] = time.Now() + if state == "OFF" { if d.LocalOnly == "" { - log.Log(WARN, "local", h.pb.Hostname, name, "duplicate defined (need to resolve this)") + log.Log(WARN, start, "local duplicate defined (need to resolve this)") continue } - log.Log(WARN, "local", h.pb.Hostname, name, "ready to import from hypervisor") + log.Log(WARN, start, "local 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") - 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 }