ready for import local domain request to hypervisors
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
b4ef8b76b1
commit
b28ae96cd4
2
http.go
2
http.go
|
@ -60,7 +60,7 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
|||
if route == "/import" {
|
||||
log.Info("virtigo import starts here")
|
||||
fmt.Fprintln(w, "virtigo import starts here")
|
||||
result, err := create(w, r)
|
||||
result, err := importDomain(w, r)
|
||||
if err != nil {
|
||||
log.Info("virtigo import failed")
|
||||
log.Info(result)
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
// attempts to create a new virtual machine
|
||||
|
||||
func importDomain(w http.ResponseWriter, r *http.Request) (string, error) {
|
||||
name := r.URL.Query().Get("domainName")
|
||||
if name == "" {
|
||||
result := "start failed. name is blank " + r.URL.Path
|
||||
log.Warn(result)
|
||||
fmt.Fprintln(w, result)
|
||||
return "", errors.New(result)
|
||||
}
|
||||
log.Warn("name is", name)
|
||||
fmt.Fprintln(w, "name is", name)
|
||||
|
||||
d := me.cluster.FindDropletByName(name)
|
||||
if d == nil {
|
||||
result := "libvirt domain " + name + " could not be found on any hypervisor"
|
||||
log.Info(result)
|
||||
fmt.Fprintln(w, result)
|
||||
return result, errors.New(result)
|
||||
}
|
||||
result := "libvirt domain " + name + " found on " + d.Current.Hypervisor
|
||||
log.Info(result)
|
||||
fmt.Fprintln(w, result)
|
||||
return result, nil
|
||||
}
|
12
poll.go
12
poll.go
|
@ -36,11 +36,15 @@ func (h *HyperT) pollHypervisor() {
|
|||
if state == "OFF" {
|
||||
d := me.cluster.FindDropletByName(name)
|
||||
if d == nil {
|
||||
log.Log(WARN, "locally defined:", h.pb.Hostname, fields, "not imported")
|
||||
} else {
|
||||
log.Log(WARN, "locally defined:", h.pb.Hostname, fields, d.Hostname)
|
||||
log.Log(WARN, "locally defined domain:", h.pb.Hostname, fields)
|
||||
log.Log(WARN, "neeed to add a local droplet protobuf")
|
||||
me.cluster.AddDropletLocal(name, h.pb.Hostname)
|
||||
return
|
||||
}
|
||||
// skip locally defined libvirt vms
|
||||
if d.LocalOnly == "" {
|
||||
log.Log(WARN, "ready to import", d.Hostname, "from", h.pb.Hostname)
|
||||
}
|
||||
log.Log(WARN, "duplicate local droplet", h.pb.Hostname, fields, "need to resolve this")
|
||||
continue
|
||||
}
|
||||
h.lastDroplets[name] = time.Now()
|
||||
|
|
Loading…
Reference in New Issue