func (sthw SpawnTwelveHourWarning) ShouldExecute(ctx triggerContext) (bool, error) { if ctx.host == nil || ctx.host.ExpirationTime.IsZero() || ctx.host.ExpirationTime.Sub(time.Now()) > (12*time.Hour) { return false, nil } rec, err := alertrecord.FindOne(alertrecord.ByHostAlertRecordType(ctx.host.Id, alertrecord.SpawnHostTwelveHourWarning)) if err != nil { return false, err } return rec == nil, nil }
func (sthw SlowProvisionWarning) ShouldExecute(ctx triggerContext) (bool, error) { // don't execute if the host is actually provisioned, or if it's been less than 20 minutes // since creation time if ctx.host.Provisioned == true || ctx.host.CreationTime.Before(time.Now().Add(-20*time.Minute)) { return false, nil } rec, err := alertrecord.FindOne(alertrecord.ByHostAlertRecordType(ctx.host.Id, alertrecord.SlowProvisionWarning)) if err != nil { return false, err } return rec == nil, nil }