diff --git a/importDomain.go b/importDomain.go index 59c6398..ffc0614 100644 --- a/importDomain.go +++ b/importDomain.go @@ -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 } diff --git a/poll.go b/poll.go index 2e3637e..916eef9 100644 --- a/poll.go +++ b/poll.go @@ -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 == "" {