summaryrefslogtreecommitdiff
path: root/importDomain.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-11-01 02:00:46 -0500
committerJeff Carr <[email protected]>2024-11-01 02:00:46 -0500
commit83faa62e1835f2c674147cab282194ad0bcb117d (patch)
tree489a3ee433136607faf8b1f6659f7e89ca431844 /importDomain.go
parentca9ad75283333529b611d73acd9762d0fc36053b (diff)
last commit before import attempt
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'importDomain.go')
-rw-r--r--importDomain.go41
1 files changed, 31 insertions, 10 deletions
diff --git a/importDomain.go b/importDomain.go
index c50ef60..f71d0b0 100644
--- a/importDomain.go
+++ b/importDomain.go
@@ -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)
+ start := d.SprintHeader()
+ if d.LocalOnly == "" {
+ result := start + " LocalOnly is blank. THIS SHOULD NEVER HAPPEN."
+ log.Log(WARN, result)
+ fmt.Fprintln(w, result)
+ return result, errors.New(result)
+ }
+ result := start + " local FOUND! LocalOnly = " + d.LocalOnly
+ log.Log(WARN, result)
+ fmt.Fprintln(w, result)
if d.Current.State != pb.DropletState_OFF {
- result := "libvirt domain " + name + " found on " + d.Current.Hypervisor
+ result := "error: libvirt domain " + name + " is not off"
log.Info(result)
fmt.Fprintln(w, result)
+ return result, errors.New(result)
}
- if d.LocalOnly == "" {
- result := start + " local duplicate defined (need to resolve this)"
+ result = start + "about to attempt import "
+ result += "(" + d.LocalOnly + ")"
+ result += " " + d.Hostname
+ log.Log(WARN, 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, nil
+ return result, errors.New(result)
}
- result := start + "about to attempt import "
- result += "(" + d.LocalOnly + ")"
- result += " " + d.Hostname
+ 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)
}