Пример #1
0
func NewServiceManager(cfg *config.InventoryConfig, gnatOpts server.Options, log server.Logger) (sm *ServiceManager, err error) {
	sm = &ServiceManager{cfg: cfg, log: log}

	var vc *core.VindaluCore
	if vc, err = core.NewVindaluCore(cfg, log); err != nil {
		return
	}
	// Setup inventory core
	sm.inv = handlers.NewVindaluApiHandler(vc, log)
	//sm.inv = handlers.NewInventory(cfg, sm.dstore, log)

	if err = sm.setupAuth(); err != nil {
		return
	}

	// Store cluster status at init time
	cstatus, cErr := vc.ClusterStatus()
	if cErr != nil {
		sm.log.Noticef("Could not get cluster status\n")
	} else {
		sm.clusterStatus = &cstatus
	}

	// Setup message queue
	err = sm.setupGnatsd(gnatOpts)

	return
}
Пример #2
0
func TestMain(m *testing.M) {

	testInvCfg.Auth.GroupsFile = "../etc/local-groups.json.sample"
	testInvCfg.Events.ConfigFile = "../etc/gnatsd.conf"
	testInvCfg.Auth.Config["htpasswd_file"] = "../etc/htpasswd"

	tv, _ := testInvCfg.Datastore.Config.(map[string]interface{})
	tv["mappings_dir"] = "../etc/mappings"
	tv["index"] = testHandlerIndex
	testInvCfg.Datastore.Config = tv

	vc, err := core.NewVindaluCore(&testInvCfg, testLogger)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	testInv = NewVindaluApiHandler(vc, testLogger)

	os.Exit(m.Run())
}