rm old code

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-11-06 02:41:06 -06:00
parent 80ff65c6d2
commit 0da809ae42
1 changed files with 0 additions and 74 deletions

View File

@ -9,80 +9,6 @@ import (
pb "go.wit.com/lib/protobuf/virtbuf" pb "go.wit.com/lib/protobuf/virtbuf"
) )
// attempts to create a new virtual machine
/*
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)
log.Info(result)
fmt.Fprintln(w, result)
return result, err
}
var d *pb.Droplet
d = new(pb.Droplet)
if err := d.UnmarshalJSON(msg); err != nil {
log.Info("UnmarshalJSON() failed", err)
if err := d.Unmarshal(msg); err != nil {
log.Info("droplet protobuf.Unmarshal() failed", err)
return "", err
}
}
d.StartState = pb.DropletState_OFF
d.SetState(pb.DropletState_OFF)
d.Memory = 2048 * 1024 * 1024
d.Cpus = 2
log.Info("Got msg:", string(msg))
log.Info("hostname =", d.Hostname)
name := d.Hostname
// don't continue past here if the grid is unstable anyway
// because this will add the droplet to cluster.Droplets
if s, err := isClusterStable(); err != nil {
log.Info(s)
fmt.Fprintln(w, s)
return s, err
}
tmpd := me.cluster.FindDropletByName(name)
if tmpd != nil {
result := "create error: Droplet " + name + " is already defined"
log.Info(result)
fmt.Fprintln(w, result)
return result, errors.New(result)
}
if d.Uuid == "" {
u := uuid.New()
d.Uuid = u.String()
}
if len(d.Networks) == 0 {
var newNet *pb.Network
newNet = new(pb.Network)
newNet.Mac = getNewMac()
d.Networks = append(d.Networks, newNet)
// d.AddDefaultNetwork(mac)
}
me.cluster.AddDroplet(d)
result, err := startDroplet(d)
if err != nil {
log.Info(result)
log.Info("startDroplet(d) failed:", err)
fmt.Fprintln(w, result)
fmt.Fprintln(w, "startDroplet(d) failed:", err)
return result, err
}
fmt.Fprintln(w, result)
fmt.Fprintln(w, "START=OK")
return result, nil
}
*/
// for now, because sometimes this should write to stdout and // for now, because sometimes this should write to stdout and
// sometimes to http socket, it returns a string // sometimes to http socket, it returns a string
func startDroplet(d *pb.Droplet) (string, error) { func startDroplet(d *pb.Droplet) (string, error) {