add droplet() defaults to start state=off

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-31 22:14:11 -05:00
parent efc3032d83
commit d51c4627f7
2 changed files with 23 additions and 10 deletions

View File

@ -5,6 +5,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
pb "go.wit.com/lib/protobuf/virtbuf"
"go.wit.com/log" "go.wit.com/log"
) )
@ -28,8 +29,20 @@ 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)
if d.Current.State != pb.DropletState_OFF {
result := "libvirt domain " + name + " found on " + d.Current.Hypervisor result := "libvirt domain " + name + " found on " + d.Current.Hypervisor
log.Info(result) log.Info(result)
fmt.Fprintln(w, 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 return result, nil
} }