Exemple #1
0
//Added new case for bmh mode
func (d *driver) GetInstance() (*core.Instance, error) {
	if d.vmh != nil {
		instance := &core.Instance{
			ProviderName: providerName,
			InstanceID:   d.vmh.Vm.Reference().Value,
			Region:       d.arrayID,
			Name:         d.vmh.Vm.Reference().Value,
		}
		return instance, nil
	} else {
		var err error
		mySlice := make([]govmax.HostAdapter, 2)
		mySlice, err = govmax.GetBaremetalHBA()
		if err != nil {
			panic(err)
		}
		instance := &core.Instance{
			ProviderName: providerName,
			InstanceID:   mySlice[0].WWN,
			Region:       d.arrayID,
			Name:         mySlice[0].WWN,
		}
		return instance, nil
	}
}
Exemple #2
0
func (d *driver) Init(r *core.RexRay) error {

	d.r = r

	fields := eff(map[string]interface{}{
		"userName": d.userName(),
		"smisHost": d.smisHost(),
		"smisPort": d.smisPort(),
		"insecure": d.insecure(),
		"sid":      d.sid(),
	})

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

	var err error
	if d.client, err = govmax.New(
		d.smisHost(),
		d.smisPort(),
		d.insecure(),
		d.userName(),
		d.password()); err != nil {
		return goof.WithFieldsE(fields,
			"error creating govmax client", err)
	}

	d.arrayID = d.sid()
	d.volPrefix = d.volumePrefix()

	vmFields := eff(map[string]interface{}{
		"userName": d.vmhUserName(),
		"smisHost": d.vmhHost(),
		"insecure": d.vmhInsecure(),
	})

	if d.vmh, err = govmax.NewVMHost(
		d.vmhInsecure(),
		d.vmhHost(),
		d.vmhUserName(),
		d.vmhPassword(),
	); err != nil {
		return goof.WithFieldsE(vmFields,
			"error retrieving VM host info", err)
	}

	//Added new instanceID for bmh mode
	if d.vmh != nil {
		d.instanceID = d.vmh.Vm.Reference().Value
	} else {
		mySlice := make([]govmax.HostAdapter, 2)
		mySlice, err = govmax.GetBaremetalHBA()
		d.instanceID = mySlice[0].WWN
	}

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

	return nil
}