// BackCompat ensures keys can be used from old configurations.
func BackCompat(config gofig.Config) {
	ec2Checks := [][]string{
		{ConfigEBSAccessKey, ConfigEC2AccessKey},
		{ConfigEBSSecretKey, ConfigEC2SecretKey},
		{ConfigEBSRegion, ConfigEC2Region},
		{ConfigEBSEndpoint, ConfigEC2Endpoint},
		{ConfigEBSMaxRetries, ConfigEC2MaxRetries},
		{ConfigEBSTag, ConfigEC2Tag},
		{ConfigEBSRexrayTag, ConfigEC2RexrayTag},
		{ConfigEBSKmsKeyID, ConfigEC2KmsKeyID},
	}
	for _, check := range ec2Checks {
		if !config.IsSet(check[0]) && config.IsSet(check[1]) {
			log.Debug(config.Get(check[1]))
			config.Set(check[0], config.Get(check[1]))
		}
	}

	awsChecks := [][]string{
		{ConfigEBSAccessKey, ConfigAWSAccessKey},
		{ConfigEBSSecretKey, ConfigAWSSecretKey},
		{ConfigEBSRegion, ConfigAWSRegion},
		{ConfigEBSEndpoint, ConfigAWSEndpoint},
		{ConfigEBSMaxRetries, ConfigAWSMaxRetries},
		{ConfigEBSTag, ConfigAWSTag},
		{ConfigEBSRexrayTag, ConfigAWSRexrayTag},
		{ConfigEBSKmsKeyID, ConfigAWSKmsKeyID},
	}
	for _, check := range awsChecks {
		if !config.IsSet(check[0]) && config.IsSet(check[1]) {
			log.Debug(config.Get(check[1]))
			config.Set(check[0], config.Get(check[1]))
		}
	}
}
Exemple #2
0
func setHost(
	ctx apitypes.Context,
	config gofig.Config,
	host string) apitypes.Context {
	ctx = ctx.WithValue(context.HostKey, host)
	ctx.WithField("host", host).Debug("set host in context")
	config.Set(apitypes.ConfigHost, host)
	ctx.WithField("host", host).Debug("set host in config")
	return ctx
}
Exemple #3
0
// InitializeDefaultModules initializes the default modules.
func InitializeDefaultModules(
	ctx apitypes.Context,
	config gofig.Config) (<-chan error, error) {

	modTypesRwl.RLock()
	defer modTypesRwl.RUnlock()

	var (
		err  error
		mod  *Instance
		errs <-chan error
	)

	// enable path caching for the modules
	config.Set(apitypes.ConfigIgVolOpsPathCacheEnabled, true)

	ctx, config, errs, err = util.ActivateLibStorage(ctx, config)
	if err != nil {
		return nil, err
	}

	modConfigs, err := getConfiguredModules(ctx, config)
	if err != nil {
		return nil, err
	}

	ctx.WithField("len(modConfigs)", len(modConfigs)).Debug(
		"got configured modules")

	for _, mc := range modConfigs {

		ctx.WithField("name", mc.Name).Debug(
			"creating libStorage client for module instance")

		if mc.Client, err = util.NewClient(ctx, mc.Config); err != nil {
			panic(err)
		}

		if mod, err = InitializeModule(ctx, mc); err != nil {
			return nil, err
		}

		modInstances[mod.Name] = mod
	}

	return errs, nil
}
Exemple #4
0
// ActivateLibStorage activates libStorage and returns a possibly mutated
// context.
func ActivateLibStorage(
	ctx apitypes.Context,
	config gofig.Config) (apitypes.Context, gofig.Config, <-chan error, error) {

	config = config.Scope("rexray")

	// set the `libstorage.service` property to the value of
	// `rexray.storageDrivers` if the former is not defined and the
	// latter is
	if !config.IsSet(apitypes.ConfigService) &&
		config.IsSet("rexray.storageDrivers") {
		if sd := config.GetStringSlice("rexray.storageDrivers"); len(sd) > 0 {
			config.Set(apitypes.ConfigService, sd[0])
		} else if sd := config.GetString("rexray.storageDrivers"); sd != "" {
			config.Set(apitypes.ConfigService, sd)
		}
	}

	if !config.IsSet(apitypes.ConfigIgVolOpsMountPath) {
		config.Set(apitypes.ConfigIgVolOpsMountPath, LibFilePath("volumes"))
	}

	var (
		err  error
		errs <-chan error
	)

	ctx, config, errs, err = activateLibStorage(ctx, config)
	if err != nil {
		return ctx, config, errs, err
	}

	return ctx, config, errs, nil
}
// BackCompat ensures keys can be used from old configurations.
func BackCompat(config gofig.Config) {
	checks := [][]string{
		{ConfigIgVolOpsMountPreempt, ConfigOldIntegrationVolMountPreempt},
		{ConfigIgVolOpsCreateDisable, ConfigOldIntegrationVolCreateDisable},
		{ConfigIgVolOpsRemoveDisable, ConfigOldIntegrationVolRemoveDisable},
		{ConfigIgVolOpsUnmountIgnoreUsed, ConfigOldIntegrationVolUnmountIgnoreUsed},
		{ConfigIgVolOpsPathCacheEnabled, ConfigOldIntegrationVolPathCache},
		{ConfigIgVolOpsCreateDefaultFsType, ConfigOldDockerFsType},
		{ConfigIgVolOpsCreateDefaultType, ConfigOldDockerVolumeType},
		{ConfigIgVolOpsCreateDefaultIOPS, ConfigOldDockerIOPS},
		{ConfigIgVolOpsCreateDefaultSize, ConfigOldDockerSize},
		{ConfigIgVolOpsCreateDefaultAZ, ConfigOldDockerAvailabilityZone},
		{ConfigIgVolOpsMountPath, ConfigOldDockerMountDirPath},
		{ConfigIgVolOpsMountRootPath, ConfigOldDockerLinuxVolumeRootPath},
	}
	for _, check := range checks {
		if !config.IsSet(check[0]) && config.IsSet(check[1]) {
			log.Debug(config.Get(check[1]))
			config.Set(check[0], config.Get(check[1]))
		}
	}
}