last commit before import attempt
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
ca9ad75283
commit
83faa62e18
7
dump.go
7
dump.go
|
@ -53,6 +53,13 @@ func dumpDroplets(w http.ResponseWriter, full bool) {
|
||||||
fmt.Fprintln(w, header, "(should be on). todo: start() here")
|
fmt.Fprintln(w, header, "(should be on). todo: start() here")
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if d.LocalOnly != "" {
|
||||||
|
// this is supposed to be ON and needs to be turned on
|
||||||
|
fmt.Fprintln(w, header, "this libvirt/domain/xml needs to be imported")
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
if full {
|
if full {
|
||||||
var filenames string
|
var filenames string
|
||||||
for _, disk := range d.Disks {
|
for _, disk := range d.Disks {
|
||||||
|
|
18
http.go
18
http.go
|
@ -68,8 +68,8 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
fmt.Fprintln(w, result)
|
fmt.Fprintln(w, result)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Info("virtigo import ends here")
|
log.Info("virtigo import ended here with error = nil")
|
||||||
fmt.Fprintln(w, "virtigo import ends here")
|
fmt.Fprintln(w, "virtigo import ends here with error = nil")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +90,20 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if route == "/dumpdroplet" {
|
||||||
|
hostname := r.URL.Query().Get("hostname")
|
||||||
|
d := me.cluster.FindDropletByName(hostname)
|
||||||
|
if d == nil {
|
||||||
|
log.Log(WARN, "can not find droplet hostname=", hostname)
|
||||||
|
fmt.Fprintln(w, "can not find droplet hostname=", hostname)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
t := d.FormatTEXT()
|
||||||
|
log.Log(WARN, t)
|
||||||
|
fmt.Fprintln(w, t)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if route == "/dumpdroplets" {
|
if route == "/dumpdroplets" {
|
||||||
dumpDroplets(w, false)
|
dumpDroplets(w, false)
|
||||||
return
|
return
|
||||||
|
|
|
@ -19,8 +19,8 @@ func importDomain(w http.ResponseWriter, r *http.Request) (string, error) {
|
||||||
fmt.Fprintln(w, result)
|
fmt.Fprintln(w, result)
|
||||||
return "", errors.New(result)
|
return "", errors.New(result)
|
||||||
}
|
}
|
||||||
log.Warn("name is", name)
|
log.Warn("importDomain() START name is", name)
|
||||||
fmt.Fprintln(w, "name is", name)
|
fmt.Fprintln(w, "importDomain() START name is", name)
|
||||||
|
|
||||||
d := me.cluster.FindDropletByName(name)
|
d := me.cluster.FindDropletByName(name)
|
||||||
if d == nil {
|
if d == nil {
|
||||||
|
@ -29,22 +29,43 @@ func importDomain(w http.ResponseWriter, r *http.Request) (string, error) {
|
||||||
fmt.Fprintln(w, result)
|
fmt.Fprintln(w, result)
|
||||||
return result, errors.New(result)
|
return result, errors.New(result)
|
||||||
}
|
}
|
||||||
start := fmt.Sprintf("%-9s %-20s", d.Current.Hypervisor, name)
|
start := d.SprintHeader()
|
||||||
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 == "" {
|
if d.LocalOnly == "" {
|
||||||
result := start + " local duplicate defined (need to resolve this)"
|
result := start + " LocalOnly is blank. THIS SHOULD NEVER HAPPEN."
|
||||||
log.Log(WARN, result)
|
log.Log(WARN, result)
|
||||||
fmt.Fprintln(w, result)
|
fmt.Fprintln(w, result)
|
||||||
return result, nil
|
return result, errors.New(result)
|
||||||
}
|
}
|
||||||
result := start + "about to attempt import "
|
result := start + " local FOUND! LocalOnly = " + d.LocalOnly
|
||||||
|
log.Log(WARN, result)
|
||||||
|
fmt.Fprintln(w, result)
|
||||||
|
if d.Current.State != pb.DropletState_OFF {
|
||||||
|
result := "error: libvirt domain " + name + " is not off"
|
||||||
|
log.Info(result)
|
||||||
|
fmt.Fprintln(w, result)
|
||||||
|
return result, errors.New(result)
|
||||||
|
}
|
||||||
|
result = start + "about to attempt import "
|
||||||
result += "(" + d.LocalOnly + ")"
|
result += "(" + d.LocalOnly + ")"
|
||||||
result += " " + d.Hostname
|
result += " " + d.Hostname
|
||||||
log.Log(WARN, result)
|
log.Log(WARN, result)
|
||||||
fmt.Fprintln(w, result)
|
fmt.Fprintln(w, result)
|
||||||
|
|
||||||
|
h := findHypervisorByName(d.Current.Hypervisor)
|
||||||
|
if h == nil {
|
||||||
|
result = "unknown hypervisor = " + d.Current.Hypervisor
|
||||||
|
log.Log(WARN, result)
|
||||||
|
fmt.Fprintln(w, result)
|
||||||
|
return result, errors.New(result)
|
||||||
|
}
|
||||||
|
result = "finally ready to h.start(d)"
|
||||||
|
log.Log(WARN, result)
|
||||||
|
fmt.Fprintln(w, result)
|
||||||
return result, nil
|
return result, nil
|
||||||
|
|
||||||
|
ok, output := h.start(d)
|
||||||
|
if ok {
|
||||||
|
return result + output, nil
|
||||||
|
}
|
||||||
|
return result + output, errors.New("start " + name + " on hypervisor " + h.pb.Hostname)
|
||||||
}
|
}
|
||||||
|
|
9
poll.go
9
poll.go
|
@ -11,6 +11,15 @@ import (
|
||||||
"google.golang.org/protobuf/types/known/timestamppb"
|
"google.golang.org/protobuf/types/known/timestamppb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func findHypervisorByName(name string) *HyperT {
|
||||||
|
for _, h := range me.hypers {
|
||||||
|
if h.pb.Hostname == name {
|
||||||
|
return h
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (h *HyperT) pollHypervisor() {
|
func (h *HyperT) pollHypervisor() {
|
||||||
url := "http://" + h.pb.Hostname + ":2520/vms"
|
url := "http://" + h.pb.Hostname + ":2520/vms"
|
||||||
log.Log(POLL, "wget url =", url)
|
log.Log(POLL, "wget url =", url)
|
||||||
|
|
Loading…
Reference in New Issue