Exemplo n.º 1
0
func (driver *Driver) CreateSnapshot(notUsed bool, snapshotName, volumeID, description string) ([]*storagedriver.Snapshot, error) {
	volume, err := goxtremio.GetVolume(volumeID, "")
	if err != nil {
		return nil, err
	}

	var snapList []*xmsv3.SnapListItem
	snapList = append(snapList, &xmsv3.SnapListItem{
		AncestorVolID: volume.Name,
		SnapVolName:   snapshotName,
	})

	//getfolder of volume
	req := &xmsv3.PostSnapshotsReq{
		SnapList: snapList,
		FolderID: "/",
	}

	postSnapshotsResp, err := goxtremio.NewSnapshot(req)
	if err != nil {
		return nil, err
	}

	index := getIndex(postSnapshotsResp.Links[0].Href)
	snapshot, err := driver.GetSnapshot("", index, "")
	if err != nil {
		return nil, err
	}

	return snapshot, nil
}
Exemplo n.º 2
0
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
}
Exemplo n.º 3
0
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
}