func (driver *Driver) getVolumesSig() (string, error) { volumes, err := goxtremio.GetVolumes() if err != nil { return "", err } var volumesNameHref sort.StringSlice for _, volume := range volumes { volumesNameHref = append(volumesNameHref, fmt.Sprintf("%s-%s", volume.Name, volume.Href)) } volumesNameHref.Sort() return strings.Join(volumesNameHref, ";"), err }
func (driver *Driver) updateVolumesSig() error { oldVolumesSig := driver.VolumesSig checkSig, volumesSig, err := driver.isVolumesSigEqual() if err != nil { return err } oldLunMapsSig := driver.LunMapsSig checkMapsSig, lunMapsSig, err := driver.isLunMapsSigEqual() if err != nil { return err } if checkSig && checkMapsSig { return nil } if oldVolumesSig != "" || oldLunMapsSig != "" { log.Println("volumeSig or volumeMapsSig updated") } volumes, err := goxtremio.GetVolumes() if err != nil { return err } for _, volume := range volumes { index := getIndex(volume.Href) volumeDetail, err := goxtremio.GetVolume(index, "") if err != nil { return err } driver.VolumesByNAA[volumeDetail.NaaName] = volumeDetail } driver.VolumesSig = volumesSig driver.LunMapsSig = lunMapsSig return nil }
func (driver *Driver) getVolume(volumeID, volumeName string) ([]*xmsv3.Volume, error) { var volumes []*xmsv3.Volume if volumeID != "" || volumeName != "" { volume, err := goxtremio.GetVolume(volumeID, volumeName) if err != nil { return nil, err } volumes = append(volumes, volume) } else { allVolumes, err := goxtremio.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, &xmsv3.Volume{ Name: volume.Name, Index: index, }) } } return volumes, nil }