Ejemplo n.º 1
0
func allocate() {
	//This is the allocate thread.  It set up a client for ctl messages to
	//flunky master.  On each iteration it grabs new nodes from heckle to be
	//allocated and send them off to flunkymaster.
	heckleDaemon.DaemonLog.LogDebug("Starting allocation go routine.")

	for i := range heckleToAllocateChan {
		cm := new(iface.Ctlmsg)
		cm.Image = i.Image
		cm.Addresses = i.Addresses
		cm.AllocNum = uint64(i.AllocNum)
		// FIXME: need to add in extradata

		/*js, _ := json.Marshal(cm)
		buf := bytes.NewBufferString(string(js))*/

		_, err := fs.PostServer("/ctl", cm)
		heckleDaemon.DaemonLog.LogError("Failed to post for allocation of nodes.", err)

		if err == nil {
			allocateToPollingChan <- i.Addresses

			_, err = ps.PostServer("/command/reboot", i.Addresses)
			heckleDaemon.DaemonLog.LogError("Failed to post for reboot of nodes in allocation go routine.", err)
		}
	}
	close(allocateToPollingChan)
}
Ejemplo n.º 2
0
func ControlMsg(nodes []string, times int64) (*bytes.Buffer, *interfaces.Ctlmsg) {
	req := new(interfaces.Ctlmsg)
	req.Addresses = nodes
	req.Time = times
	req.Image = "ubuntu-Rescue"
	resp, _ := json.Marshal(req)
	buf := bytes.NewBufferString(string(resp))
	return buf, req
}