Ejemplo n.º 1
0
func getLunMaps(initiatorName, volumeID string) ([]*xmsv3.Ref, error) {
	if initiatorName == "" {
		return nil, errors.New("Missing initiatorName")
	}

	initiatorGroup, err := goxtremio.GetInitiatorGroup("", initiatorName)
	if err != nil {
		return nil, err
	}

	lunMaps, err := goxtremio.GetLunMaps()
	if err != nil {
		return nil, err
	}

	var refs []*xmsv3.Ref
	for _, ref := range lunMaps {

		idents := strings.Split(ref.Name, "_")
		if len(idents) < 3 {
			continue
		} else if strconv.Itoa(initiatorGroup.Index) == idents[1] && volumeID == idents[0] {
			refs = append(refs, ref)
		}
	}

	return refs, nil
}
Ejemplo n.º 2
0
func (driver *Driver) AttachVolume(runAsync bool, volumeID, instanceID string) ([]*storagedriver.VolumeAttachment, error) {
	if volumeID == "" {
		return nil, ErrMissingVolumeID
	}

	// doing a lookup here for intiator name as IG name, so limited to IG name as initiator name to work for now
	//1) need to consider when instanceid is blank,need to lookup ig from instanceid

	// if instanceID == "" {
	initiatorGroup, err := goxtremio.GetInitiatorGroup("", driver.Initiator.Name)
	if err != nil {
		return nil, err
	}

	initiatorGroupID := strconv.Itoa(initiatorGroup.Index)

	initiatorGroupIDI, err := strconv.Atoi(initiatorGroupID)
	if err != nil {
		return nil, err
	}
	volumeIDI, err := strconv.Atoi(volumeID)
	if err != nil {
		return nil, err
	}
	req := &xmsv3.PostLunMapsReq{
		VolID: volumeIDI,
		IgID:  initiatorGroupIDI,
	}

	_, err = goxtremio.NewLunMap(req)
	if err != nil {
		return nil, err
	}

	if !runAsync {
		_, err := driver.waitAttach(volumeID)
		if err != nil {
			return nil, err
		}
	} else {
		_, _ = driver.GetVolumeMapping()
	}

	volumeAttachment, err := driver.GetVolumeAttach(volumeID, instanceID)
	if err != nil {
		return nil, err
	}

	return volumeAttachment, nil

}