From 4a58352ec271c2de5cebd2cabc266bccb68ac030 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 31 Oct 2024 06:43:14 -0500 Subject: [PATCH] dump more code to virtigoxml Signed-off-by: Jeff Carr --- event.go | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/event.go b/event.go index d5ea351..8f8f19e 100644 --- a/event.go +++ b/event.go @@ -25,37 +25,10 @@ func (h *HyperT) RestartVirtigod() { me.unstable = time.Now() } -// checks if the cluster is ready and stable -func clusterReady() (bool, string) { - last := time.Since(me.unstable) - if last > me.unstableTimeout { - // the cluster has not been stable for 133 seconds - log.Warn("clusterReady() is stable for ", shell.FormatDuration(me.unstableTimeout), " secs") - return true, fmt.Sprintln("clusterReady() is stable ", shell.FormatDuration(me.unstableTimeout), " secs") - } - log.Warn("clusterReady() is unstable for", shell.FormatDuration(last)) - return false, "clusterReady() is unstable for " + shell.FormatDuration(last) -} - -func dropletReady(d *pb.Droplet) (bool, string) { - if d.Current.State == pb.DropletState_ON { - return false, "EVENT start droplet is already ON" - } - 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, "" -} - // this must be bool in string because accumulated output is sometimes // written to STDOUT, sometimes to http func (h *HyperT) start(d *pb.Droplet) (bool, string) { - ready, result := clusterReady() - if !ready { - return false, result - } - ready, result = dropletReady(d) + ready, result := me.cluster.DropletReady(d) if !ready { return false, result } @@ -83,12 +56,3 @@ func (h *HyperT) start(d *pb.Droplet) (bool, string) { return true, result } - -func findDropletByName(name string) *pb.Droplet { - for _, d := range me.cluster.Droplets { - if d.Hostname == name { - return d - } - } - return nil -}