// Copyright 2024 WIT.COM Inc Licensed GPL 3.0 package main import ( "strings" "go.wit.com/lib/gui/shell" "go.wit.com/log" ) var urlbase string = "http://zookeeper.grid.wit.com:8080" func send() { } func pingStatus() error { var url string url = urlbase + "/status?hostname=" + me.hostname msg, err := me.machine.Packages.Marshal() if err != nil { log.Info("proto.Marshal() failed:", err) return err } log.Info("proto Marshal len =", len(msg)) body, err := httpPost(url, msg) if err != nil { log.Info("httpPost() failed:", err) return err } test := strings.TrimSpace(string(body)) // log.Info("virtigo returned body:", test) for _, line := range strings.Split(test, "\n") { switch line { case "upgrade": log.Info("should upgrade now") default: log.Info("GOT:", line) } } return nil } func sendMachine() error { var url string url = urlbase + "/machine" msg, err := me.machine.Marshal() if err != nil { log.Info("proto.Marshal() failed:", err) return err } log.Info("proto Marshal len =", len(msg)) body, err := httpPost(url, msg) if err != nil { log.Info("httpPost() failed:", err) return err } test := strings.TrimSpace(string(body)) // log.Info("virtigo returned body:", test) for _, line := range strings.Split(test, "\n") { switch line { case "upgrade": log.Info("zookeeper is healthy") case "apt update": log.Info("machine upgrade now") shell.Run([]string{"apt", "update"}) shell.Run([]string{"apt", "install", "zood"}) default: log.Info("zookeeper is maybe not working GOT:", line) } } return nil }