From 96f29d6f3b696347dea1c22a0f3bda834a136d32 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 31 Oct 2024 04:29:51 -0500 Subject: [PATCH] move more into add.go Signed-off-by: Jeff Carr --- add.go | 25 +++++++++++++++++++++++++ droplet.proto | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) 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 {