diff options
Diffstat (limited to 'add.go')
| -rw-r--r-- | add.go | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -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, "" +} |
