Example #1
0
func main() {
	var err error

	powerDaemon, err = daemon.New("power")
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	cms := NewControllerMuxServer()
	err = cms.cm.LoadSentryFromFile("/etc/heckle/power-sentry.db")
	if err != nil {
		fmt.Println("Failed to load sentry database")
		fmt.Println(err)
		os.Exit(1)
	}

	err = cms.cm.LoadIpmiFromFile("/etc/heckle/power-ipmi.db")
	if err != nil {
		fmt.Println("Failed to load ipmi database")
		fmt.Println(err)
		os.Exit(1)
	}

	http.HandleFunc("/status", func(w http.ResponseWriter, req *http.Request) { cms.wrapStatus(w, req) })
	http.HandleFunc("/command/", func(w http.ResponseWriter, req *http.Request) { cms.wrapControl(w, req) })
	err = powerDaemon.ListenAndServe()
	if err != nil {
		os.Exit(1)
	}
}
Example #2
0
func init() {
	flag.BoolVar(&help, "h", false, "Print Usages")
	flag.StringVar(&nodes, "n", " ", "Node to be Checked") //right now need 2 on command line to run one...
	flag.StringVar(&power, "p", " ", "Power Cycle")
	flag.StringVar(&image, "i", "ubuntu-Rescue", "Set node(s) as rescue image")
	flag.StringVar(&server, "S", "http://localhost:8080", "Base Server Address")
	flag.StringVar(&power, "P", "http://localhost:8085", "Power Server Address")

	diagDaemon, _ = daemon.New("diagnostic")
}
Example #3
0
func (fm *Flunkym) init() {
	var err error
	flag.BoolVar(&help, "h", false, "Print usage message")
	flag.Parse()
	if help {
		Usage()
	}
	fmDaemon, err = daemon.New("flunky")
	if err != nil {
		fmt.Println("Could not create daemon")
		os.Exit(1)
	}
	fm.data = make(map[string]*AllocationInfo)
	fm.SetPath(fmDaemon)
	src := rand.NewSource(time.Now().Unix())
	random = rand.New(src)
	random.Seed(time.Now().Unix())
	fm.Load()
	return
}
Example #4
0
func init() {
	//new comments here
	var err error
	flag.Parse()

	heckleDaemon, err = daemon.New("heckle")
	heckleDaemon.DaemonLog.LogError("Failed to create new heckle daemon.", err)
	heckleDaemon.DaemonLog.LogDebug("Initializing variables and setting up daemon.")

	user, pass, _ := heckleDaemon.AuthN.GetUserAuth()
	err = heckleDaemon.AuthN.Authenticate(user, pass, true)
	if err != nil {
		fmt.Println(fmt.Sprintf("You do not have proper permissions to start %s daemon.", heckleDaemon.Name))
		os.Exit(1)
	}

	fmComm, err = fnet.NewCommunication(daemon.FileDir+"components.conf", heckleDaemon.Cfg.Data["username"], heckleDaemon.Cfg.Data["password"])
	heckleDaemon.DaemonLog.LogError("Failed to make new communication structure in heckle for flunkymaster.", err)

	pComm, err = fnet.NewCommunication(daemon.FileDir+"components.conf", heckleDaemon.Cfg.Data["username"], heckleDaemon.Cfg.Data["password"])
	heckleDaemon.DaemonLog.LogError("Failed to make new communication structure in heckle for power.", err)

	fs, err = fmComm.SetupClient("flunky")
	heckleDaemon.DaemonLog.LogError("Failed to setup heckle to flunkymaster communication.", err)

	ps, err = pComm.SetupClient("power")
	heckleDaemon.DaemonLog.LogError("Failed to setup heckle to power communication.", err)

	heckleToAllocateChan = make(chan iface.Listmsg)
	allocateToPollingChan = make(chan []string)
	pollingToHeckleChan = make(chan map[string]*iface.StatusMessage)
	pollingCancelChan = make(chan []string)

	currentRequests = make(map[string]*currentRequestsNode)
	remove = make(map[string]bool)
	toDelete = make(map[string]bool)
	allocationNumber = 1
	getResources()
}