From 173520b42e1266687ee397302fada281d227b216 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 1 Nov 2024 08:51:25 -0500 Subject: [PATCH] more work on importing Signed-off-by: Jeff Carr --- create.go | 8 +++----- importDomain.go | 13 ++++++++++++- main.go | 3 --- validate.go | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/create.go b/create.go index 9752bb2..1e84b9a 100644 --- a/create.go +++ b/create.go @@ -3,19 +3,16 @@ package main import ( "errors" "fmt" - "io/ioutil" "math/rand" - "net/http" "time" - "github.com/google/uuid" pb "go.wit.com/lib/protobuf/virtbuf" - "go.wit.com/log" ) // attempts to create a new virtual machine -func create(w http.ResponseWriter, r *http.Request) (string, error) { +/* +func oldcreate(w http.ResponseWriter, r *http.Request) (string, error) { msg, err := ioutil.ReadAll(r.Body) // Read the body as []byte if err != nil { result := fmt.Sprintf("ReadAll() error =", err) @@ -84,6 +81,7 @@ func create(w http.ResponseWriter, r *http.Request) (string, error) { fmt.Fprintln(w, "START=OK") return result, nil } +*/ // for now, because sometimes this should write to stdout and // sometimes to http socket, it returns a string diff --git a/importDomain.go b/importDomain.go index 98f506b..9e55f6b 100644 --- a/importDomain.go +++ b/importDomain.go @@ -98,10 +98,21 @@ func importDomain(w http.ResponseWriter, r *http.Request) (string, error) { me.cluster.AddEvent(e) } - log.Warn("Everything worked") result := fmt.Sprintln("importDomain() worked") + + // remote LocalOnly flag + d.LocalOnly = "" + + // probably be safe and don't let this move around the cluster + d.PreferredHypervisor = d.Current.Hypervisor + log.Log(WARN, result) fmt.Fprintln(w, result) + log.Warn("Everything worked. Saving config files") + if err := me.cluster.ConfigSave(); err != nil { + log.Warn("configsave error", err) + os.Exit(-1) + } return result, nil } diff --git a/main.go b/main.go index ce859d2..7e36374 100644 --- a/main.go +++ b/main.go @@ -126,9 +126,6 @@ func main() { log.Info(i, "Event:", e.Droplet, e.FieldName, "orig:", e.OrigVal, "new:", e.NewVal) me.changed = true } - // if err := me.cluster.ConfigSave(); err != nil { - // log.Info("configsave error", err) - // } if me.changed { if err := me.cluster.ConfigSave(); err != nil { diff --git a/validate.go b/validate.go index a822dd0..b6572f5 100644 --- a/validate.go +++ b/validate.go @@ -157,7 +157,7 @@ func ValidateDiskFilenames() ([]*pb.Event, error) { } if !found { log.Info("droplet", d.Hostname, d.Disks) - return nil, errors.New("droplet " + d.Hostname + " has nonstandard disk names") + log.Warn("droplet " + d.Hostname + " has nonstandard disk names") } } return alle, nil