Exemple #1
0
func (d *driver) Init(r *core.RexRay) error {

	d.r = r
	d.volumesByNaa = map[string]xtio.Volume{}

	fields := eff(map[string]interface{}{
		"endpoint":         d.endpoint(),
		"userName":         d.userName(),
		"deviceMapper":     d.deviceMapper(),
		"multipath":        d.multipath(),
		"remoteManagement": d.remoteManagement(),
		"insecure":         d.insecure(),
	})

	if d.password() == "" {
		fields["password"] = ""
	} else {
		fields["password"] = "******"
	}

	if !isXtremIOAttached() && !d.remoteManagement() {
		return goof.WithFields(fields, "device not detected")
	}

	var err error

	if d.client, err = xtio.NewClientWithArgs(
		d.endpoint(),
		d.insecure(),
		d.userName(),
		d.password()); err != nil {
		return goof.WithFieldsE(fields,
			"error creating xtremio client", err)
	}

	if !d.remoteManagement() {
		var iqn string
		if iqn, err = getIQN(); err != nil {
			return goof.WithFieldsE(fields,
				"error getting IQN", err)
		}
		if d.initiator, err = d.client.GetInitiator("", iqn); err != nil {
			return goof.WithFieldsE(fields,
				"error getting initiator", err)
		}
	}

	log.WithField("provider", providerName).Info("storage driver initialized")

	return nil
}
Exemple #2
0
func (d *xtremIODriver) Init(r *core.RexRay) error {

	d.r = r
	d.volumesByNaa = map[string]xtio.Volume{}

	fields := eff(map[string]interface{}{
		"endpoint":         r.Config.XtremIOEndpoint,
		"userName":         r.Config.XtremIOUserName,
		"deviceMapper":     r.Config.XtremIODeviceMapper,
		"multipath":        r.Config.XtremIOMultipath,
		"remoteManagement": r.Config.XtremIORemoteManagement,
		"insecure":         r.Config.XtremIOInsecure,
	})

	if r.Config.XtremIoPassword == "" {
		fields["password"] = ""
	} else {
		fields["password"] = "******"
	}

	if !isXtremIOAttached() && !d.r.Config.XtremIORemoteManagement {
		return errors.WithFields(fields, "device not detected")
	}

	var err error

	if d.client, err = xtio.NewClientWithArgs(
		r.Config.XtremIOEndpoint,
		r.Config.XtremIOInsecure,
		r.Config.XtremIOUserName,
		r.Config.XtremIoPassword); err != nil {
		return errors.WithFieldsE(fields,
			"error creating xtremio client", err)
	}

	if !d.r.Config.XtremIORemoteManagement {
		var iqn string
		if iqn, err = getIQN(); err != nil {
			return err
		}
		if d.initiator, err = d.client.GetInitiator("", iqn); err != nil {
			return err
		}
	}

	log.WithField("provider", providerName).Debug("storage driver initialized")

	return nil
}
Exemple #3
0
func Init(cfg *config.Config) (storage.Driver, error) {

	fields := eff(map[string]interface{}{
		"endpoint":         cfg.XtremIoEndpoint,
		"userName":         cfg.XtremIoUserName,
		"deviceMapper":     cfg.XtremIoDeviceMapper,
		"multipath":        cfg.XtremIoMultipath,
		"remoteManagement": cfg.XtremIoRemoteManagement,
		"insecure":         cfg.XtremIoInsecure,
	})

	if cfg.XtremIoPassword == "" {
		fields["password"] = ""
	} else {
		fields["password"] = "******"
	}

	if !isXtremIOAttached() && !cfg.XtremIoRemoteManagement {
		return nil, errors.WithFields(fields, "device not detected")
	}

	client, cErr := xtio.NewClientWithArgs(
		cfg.XtremIoEndpoint,
		cfg.XtremIoInsecure,
		cfg.XtremIoUserName,
		cfg.XtremIoPassword)

	if cErr != nil {
		return nil,
			errors.WithFieldsE(fields, "error creating xtremio client", cErr)
	}

	var iqn string
	var ini xtio.Initiator
	if !cfg.XtremIoRemoteManagement {
		var iqnErr error
		iqn, iqnErr = getIQN()
		if iqnErr != nil {
			return nil, iqnErr
		}

		var iniErr error
		ini, iniErr = client.GetInitiator("", iqn)
		if iniErr != nil {
			return nil, iniErr
		}
	}

	useDeviceMapper, _ := strconv.ParseBool(os.Getenv("REXRAY_XTREMIO_DM"))
	useMultipath, _ := strconv.ParseBool(os.Getenv("REXRAY_XTREMIO_MULTIPATH"))

	driver := &Driver{
		Client:          client,
		Initiator:       ini,
		UseDeviceMapper: useDeviceMapper,
		UseMultipath:    useMultipath,
		Config:          cfg,
		VolumesByNAA:    map[string]xtio.Volume{},
	}

	log.WithField("provider", ProviderName).Debug(
		"storage driver initialized")

	return driver, nil
}