Example #1
0
func New(name string) (daemon *Daemon, err error) {
	daemon = new(Daemon)
	daemon.Name = name
	daemon.stat.StartTime = time.Now().Unix()

	daemon.DaemonLog = NewDaemonLogger("/var/log/", daemon.Name)
	daemon.Cfg = NewConfigInfo(FileDir+name+".conf", daemon.DaemonLog)
	daemon.AuthN = NewAuthInfo(FileDir+"users.db", daemon.DaemonLog)
	if user, ok := daemon.Cfg.Data["user"]; ok {
		daemon.User = user
	}

	if password, ok := daemon.Cfg.Data["password"]; ok {
		daemon.Password = password
	}

	daemon.Comm, err = fnet.NewCommunication(FileDir+"components.conf", daemon.User, daemon.Password)
	if err != nil {
		return
	}

	location, ok := daemon.Comm.Locations[name]
	if !ok {
		err = errors.New("Component lookup failure")
	}

	daemon.URL = location
	return
}
Example #2
0
func NewClient() (comm fnet.Communication, err error) {
	user, password, err := GetUserAuth()
	if err != nil {
		return
	}

	comm, err = fnet.NewCommunication("/etc/heckle/components.conf", user, password)
	return
}
Example #3
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()
}