Beispiel #1
0
func (d *driver) getVolume(volumeID, volumeName string) ([]xtio.Volume, error) {
	fields := eff(map[string]interface{}{
		"volumeID":   volumeID,
		"volumeName": volumeName,
	})

	var volumes []xtio.Volume
	if volumeID != "" || volumeName != "" {
		volume, err := d.client.GetVolume(volumeID, volumeName)
		if err != nil {
			return nil, goof.WithFieldsE(fields, "error getting volume", err)
		}
		volumes = append(volumes, volume)
	} else {
		allVolumes, err := d.client.GetVolumes()
		if err != nil {
			return nil, goof.WithFieldsE(fields, "error getting volumes", err)
		}
		for _, volume := range allVolumes {
			hrefFields := strings.Split(volume.Href, "/")
			index, _ := strconv.Atoi(hrefFields[len(hrefFields)-1])
			volumes = append(volumes,
				xtio.VolumeCtorNameIndex(volume.Name, index))
		}
	}
	return volumes, nil
}
Beispiel #2
0
func (d *xtremIODriver) getVolume(volumeID, volumeName string) ([]xtio.Volume, error) {
	var volumes []xtio.Volume
	if volumeID != "" || volumeName != "" {
		volume, err := d.client.GetVolume(volumeID, volumeName)
		if err != nil {
			return nil, err
		}
		volumes = append(volumes, volume)
	} else {
		allVolumes, err := d.client.GetVolumes()
		if err != nil {
			return nil, err
		}
		for _, volume := range allVolumes {
			hrefFields := strings.Split(volume.Href, "/")
			index, _ := strconv.Atoi(hrefFields[len(hrefFields)-1])
			volumes = append(volumes,
				xtio.VolumeCtorNameIndex(volume.Name, index))
		}
	}
	return volumes, nil
}