diff --git a/add.go b/add.go index de58295..96f3fcb 100644 --- a/add.go +++ b/add.go @@ -128,3 +128,28 @@ func (c *Cluster) BlankFields() { func (epb *Events) AppendEvent(e *Event) { epb.Events = append(epb.Events, e) } + +// check the cluster and droplet to make sure it's ready to start +func (c *Cluster) DropletReady(d *Droplet) (bool, string) { + if c == nil { + return false, "cluster == nil" + } + if d == nil { + return false, "droplet == nil" + } + if d.Current == nil { + return false, "droplet.Current == nil" + } + // can't start already started droplet + if d.Current.State == DropletState_ON { + return false, "EVENT start droplet is already ON" + } + if d.Current.State != DropletState_OFF { + return false, "EVENT start droplet is not OFF state = " + string(d.Current.State) + } + if d.Current.StartAttempts > 2 { + // reason := "EVENT start droplet has already been started " + d.starts + " times" + return false, fmt.Sprintln("EVENT start droplet has already been started ", d.Current.StartAttempts, " times") + } + return true, "" +} diff --git a/droplet.proto b/droplet.proto index 2c30829..bed3e48 100644 --- a/droplet.proto +++ b/droplet.proto @@ -30,7 +30,7 @@ message Droplet { string custom_xml = 15; // if needed, } -// current settings for things. +// volatile data. the current settings and values of things. // These are passed around while the cluster to monitor and control the systems // but they are not saved to the config file message Current {