use of org.apache.cloudstack.storage.datastore.api.SnapshotDef in project cloudstack by apache.
the class ScaleIOGatewayClientImpl method takeSnapshot.
@Override
public SnapshotGroup takeSnapshot(final Map<String, String> srcVolumeDestSnapshotMap) {
Preconditions.checkArgument(srcVolumeDestSnapshotMap != null && !srcVolumeDestSnapshotMap.isEmpty(), "srcVolumeDestSnapshotMap cannot be null");
final List<SnapshotDef> defs = new ArrayList<>();
for (final String volumeId : srcVolumeDestSnapshotMap.keySet()) {
final SnapshotDef snapshotDef = new SnapshotDef();
snapshotDef.setVolumeId(volumeId);
String snapshotName = srcVolumeDestSnapshotMap.get(volumeId);
if (StringUtils.isNotEmpty(snapshotName)) {
snapshotDef.setSnapshotName(srcVolumeDestSnapshotMap.get(volumeId));
}
defs.add(snapshotDef);
}
final SnapshotDefs snapshotDefs = new SnapshotDefs();
snapshotDefs.setSnapshotDefs(defs.toArray(new SnapshotDef[0]));
return post("/instances/System/action/snapshotVolumes", snapshotDefs, SnapshotGroup.class);
}
use of org.apache.cloudstack.storage.datastore.api.SnapshotDef in project cloudstack by apache.
the class ScaleIOGatewayClientImpl method takeSnapshot.
@Override
public Volume takeSnapshot(final String volumeId, final String snapshotVolumeName) {
Preconditions.checkArgument(StringUtils.isNotEmpty(volumeId), "Volume id cannot be null");
Preconditions.checkArgument(StringUtils.isNotEmpty(snapshotVolumeName), "Snapshot name cannot be null");
final SnapshotDef[] snapshotDef = new SnapshotDef[1];
snapshotDef[0] = new SnapshotDef();
snapshotDef[0].setVolumeId(volumeId);
snapshotDef[0].setSnapshotName(snapshotVolumeName);
final SnapshotDefs snapshotDefs = new SnapshotDefs();
snapshotDefs.setSnapshotDefs(snapshotDef);
SnapshotGroup snapshotGroup = post("/instances/System/action/snapshotVolumes", snapshotDefs, SnapshotGroup.class);
if (snapshotGroup != null) {
List<String> volumeIds = snapshotGroup.getVolumeIds();
if (volumeIds != null && !volumeIds.isEmpty()) {
return getVolume(volumeIds.get(0));
}
}
return null;
}
Aggregations