last commit before import attempt

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-11-01 02:00:46 -05:00
parent ca9ad75283
commit 83faa62e18
4 changed files with 64 additions and 13 deletions

View File

@ -53,6 +53,13 @@ func dumpDroplets(w http.ResponseWriter, full bool) {
fmt.Fprintln(w, header, "(should be on). todo: start() here")
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 {
var filenames string
for _, disk := range d.Disks {

18
http.go
View File

@ -68,8 +68,8 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, result)
return
}
log.Info("virtigo import ends here")
fmt.Fprintln(w, "virtigo import ends here")
log.Info("virtigo import ended here with error = nil")
fmt.Fprintln(w, "virtigo import ends here with error = nil")
return
}
@ -90,6 +90,20 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
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" {
dumpDroplets(w, false)
return

View File

@ -19,8 +19,8 @@ func importDomain(w http.ResponseWriter, r *http.Request) (string, error) {
fmt.Fprintln(w, result)
return "", errors.New(result)
}
log.Warn("name is", name)
fmt.Fprintln(w, "name is", name)
log.Warn("importDomain() START name is", name)
fmt.Fprintln(w, "importDomain() START name is", name)
d := me.cluster.FindDropletByName(name)
if d == nil {
@ -29,22 +29,43 @@ func importDomain(w http.ResponseWriter, r *http.Request) (string, error) {
fmt.Fprintln(w, result)
return result, errors.New(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)
}
start := d.SprintHeader()
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)
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.Hostname
log.Log(WARN, result)
fmt.Fprintln(w, result)
return result, nil
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
ok, output := h.start(d)
if ok {
return result + output, nil
}
return result + output, errors.New("start " + name + " on hypervisor " + h.pb.Hostname)
}

View File

@ -11,6 +11,15 @@ import (
"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() {
url := "http://" + h.pb.Hostname + ":2520/vms"
log.Log(POLL, "wget url =", url)