move more into add.go

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-10-31 04:29:51 -05:00
parent c2229b65ab
commit 96f29d6f3b
2 changed files with 26 additions and 1 deletions

25
add.go
View File

@ -128,3 +128,28 @@ func (c *Cluster) BlankFields() {
func (epb *Events) AppendEvent(e *Event) { func (epb *Events) AppendEvent(e *Event) {
epb.Events = append(epb.Events, e) 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, ""
}

View File

@ -30,7 +30,7 @@ message Droplet {
string custom_xml = 15; // if needed, 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 // These are passed around while the cluster to monitor and control the systems
// but they are not saved to the config file // but they are not saved to the config file
message Current { message Current {