Beispiel #1
0
func Init(id int32, cfg *module.ModuleConfig) (module.Module, error) {

	osdm, osdmErr := osm.NewOSDriverManager(cfg.Config)
	if osdmErr != nil {
		return nil, osdmErr
	}
	if len(osdm.Drivers) == 0 {
		return nil, errors.New("no os drivers initialized")
	}

	sdm, sdmErr := storage.NewStorageDriverManager(cfg.Config)
	if sdmErr != nil {
		return nil, sdmErr
	}
	if len(sdm.Drivers) == 0 {
		return nil, errors.New("no storage drivers initialized")
	}

	vdm, vdmErr := volume.NewVolumeDriverManager(cfg.Config, osdm, sdm)
	if vdmErr != nil {
		return nil, vdmErr
	}
	if len(vdm.Drivers) == 0 {
		return nil, errors.New("no volume drivers initialized")
	}

	return &Module{
		id:   id,
		vdm:  vdm,
		name: MOD_NAME,
		desc: MOD_DESC,
		addr: cfg.Address,
	}, nil
}
Beispiel #2
0
func initDriverManagers() error {

	var osdmErr error
	osdm, osdmErr = osm.NewOSDriverManager(c)
	if osdmErr != nil {
		return osdmErr
	}

	var sdmErr error
	sdm, sdmErr = storage.NewStorageDriverManager(c)
	if sdmErr != nil {
		return sdmErr
	}

	var vdmErr error
	vdm, vdmErr = volume.NewVolumeDriverManager(c, osdm, sdm)
	if vdmErr != nil {
		return vdmErr
	}

	return nil
}