Ejemplo n.º 1
0
/*
Initialize the application
*/
func (a *App) InitializeApplication(sysConfig conf.SkyringCollection, configDir string) error {

	// Load the event type details
	if err := application.LoadEventTypes(
		configDir,
		fmt.Sprintf("%s.evt", models.ENGINE_NAME)); err != nil {
		logger.Get().Error("Failed to initialize event types. error: %v",
			err)
		return err
	}

	if err := initializeNodeManager(sysConfig.NodeManagementConfig); err != nil {
		logger.Get().Error("Unable to create node manager")
		return err
	}
	/*
		TODO : This will be removed after porting all the existing things into newer scheme
	*/
	// Create DB session
	if err := db.InitDBSession(sysConfig.DBConfig); err != nil {
		logger.Get().Error("Unable to initialize DB")
		return err
	}
	if err := db.InitMonitoringDB(sysConfig.TimeSeriesDBConfig); err != nil {
		logger.Get().Error("Unable to initialize monitoring DB")
		return err
	}

	//Initialize the DB provider
	if err := initializeDb(sysConfig.DBConfig); err != nil {
		logger.Get().Error("Unable to initialize the authentication provider: %s", err)
		return err
	}

	//Initialize the auth provider
	if err := initializeAuth(sysConfig.Authentication); err != nil {
		logger.Get().Error("Unable to initialize the authentication provider: %s", err)
		return err
	}

	//Initialize the task manager
	if err := initializeTaskManager(); err != nil {
		logger.Get().Error("Unable to initialize the task manager: %s", err)
		return err
	}

	//Initialize the lock manager
	if err := initializeLockManager(); err != nil {
		logger.Get().Error("Unable to initialize the lock manager: %s", err)
		return err
	}

	//Initialize the Defaults
	if err := initializeDefaults(); err != nil {
		logger.Get().Error("Unable to initialize the Defaults: %s", err)
		return err
	}

	if err := application.initializeMonitoringManager(sysConfig.TimeSeriesDBConfig); err != nil {
		logger.Get().Error("Unable to create monitoring manager")
		os.Exit(1)
	}

	// Initialize keys
	if err := createEncKeys(); err != nil {
		logger.Get().Error("Unable to create encryption details")
		return err
	}

	return nil
}
Ejemplo n.º 2
0
func main() {
	confStr := make([]byte, base64.StdEncoding.DecodedLen(len(os.Args[1])))
	l, _ := base64.StdEncoding.Decode(confStr, []byte(os.Args[1]))

	key, err := ioutil.ReadFile(models.SKYRING_ENC_KEY_FILE)
	if err != nil {
		panic(fmt.Sprintf("Reading enc key failed. error: %v", err))
	}
	cfgs, err := crypto.Decrypt(key, []byte(confStr[:l]))

	var config conf.SkyringCollection
	if err := json.Unmarshal(cfgs, &config); err != nil {
		panic(fmt.Sprintf("Reading configurations failed. error: %v", err))
	}
	conf.SystemConfig = config

	var eventTypes = make(map[string]string)
	if err := json.Unmarshal([]byte(os.Args[2]), &eventTypes); err != nil {
		panic(fmt.Sprintf("Reading event types failed. error: %v", err))
	}
	provider.EventTypes = eventTypes

	var providerConfig conf.ProviderInfo
	if err := json.Unmarshal([]byte(os.Args[3]), &providerConfig); err != nil {
		panic(fmt.Sprintf("Reading provider configurations failed. error: %v", err))
	}
	bigfin_conf.ProviderConfig = providerConfig

	// Initialize the logger
	level, err := logging.LogLevel(config.Logging.Level.String())
	if err != nil {
		level = logging.DEBUG
	}
	if err := logger.Init(
		"bigfin",
		fmt.Sprintf("%s/bigfin.log", filepath.Dir(config.Logging.Filename)),
		true,
		level); err != nil {
		panic(fmt.Sprintf("log init failed. %s", err))
	}

	if err := db.InitDBSession(config.DBConfig); err != nil {
		logger.Get().Fatalf("Unable to initialize DB. error: %v", err)
	}

	//Initialize the DB provider
	if err := provider.InitializeDb(); err != nil {
		logger.Get().Error("Unable to initialize the DB provider: %s", err)
	}

	// Initialize the task manager
	if err := task.InitializeTaskManager(); err != nil {
		logger.Get().Fatalf("Failed to initialize task manager. error: %v", err)
	}

	if err := provider.InitMonitoringManager(); err != nil {
		logger.Get().Fatalf("Error initializing the monitoring manager: %v", err)
	}

	if err := provider.InitInstaller(); err != nil {
		logger.Get().Fatalf("Error initializing the Installer: %v", err)
	}

	schedule.InitShechuleManager()
	if err := provider.ScheduleRbdEventEmitter(); err != nil {
		logger.Get().Error("Error while initializing RbdEventer scheduler: %v", err)
	}

	// Initialize ceph http client
	client.InitCephApiSession()

	provd := &provider.CephProvider{}
	p := pie.NewProvider()
	if err := p.RegisterName(bigfin_conf.ProviderName, provd); err != nil {
		logger.Get().Fatalf("Failed to register plugin. error: %v", err)
	}
	p.ServeCodec(jsonrpc.NewServerCodec)
}