Search in sources :

Example 1 with SnapshotDefs

use of org.apache.cloudstack.storage.datastore.api.SnapshotDefs 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);
}
Also used : ArrayList(java.util.ArrayList) SnapshotDefs(org.apache.cloudstack.storage.datastore.api.SnapshotDefs) SnapshotDef(org.apache.cloudstack.storage.datastore.api.SnapshotDef)

Example 2 with SnapshotDefs

use of org.apache.cloudstack.storage.datastore.api.SnapshotDefs 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;
}
Also used : SnapshotDefs(org.apache.cloudstack.storage.datastore.api.SnapshotDefs) SnapshotDef(org.apache.cloudstack.storage.datastore.api.SnapshotDef) SnapshotGroup(org.apache.cloudstack.storage.datastore.api.SnapshotGroup)

Aggregations

SnapshotDef (org.apache.cloudstack.storage.datastore.api.SnapshotDef)2 SnapshotDefs (org.apache.cloudstack.storage.datastore.api.SnapshotDefs)2 ArrayList (java.util.ArrayList)1 SnapshotGroup (org.apache.cloudstack.storage.datastore.api.SnapshotGroup)1