use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method findSnapshotsByProject.
private List<BlockSnapshotRestRep> findSnapshotsByProject(ViPRCoreClient client, URI project) {
log.info("Finding snapshots by project {}", project);
List<SearchResultResourceRep> snapshotRefs = client.blockSnapshots().performSearchBy(SearchConstants.PROJECT_PARAM, project);
List<URI> ids = new ArrayList<>();
for (SearchResultResourceRep ref : snapshotRefs) {
ids.add(ref.getId());
}
List<BlockSnapshotRestRep> snapshots = client.blockSnapshots().getByIds(ids, null);
log.info("Got snapshots: [{}]", snapshots.size());
return snapshots;
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class GetBlockResource method executeTask.
@SuppressWarnings("incomplete-switch")
@Override
public BlockObjectRestRep executeTask() throws Exception {
ViPRCoreClient client = getClient();
ResourceType volumeType = ResourceType.fromResourceId(resourceId.toString());
switch(volumeType) {
case VOLUME:
VolumeRestRep volume = client.blockVolumes().get(resourceId);
if (volume != null) {
return volume;
}
break;
case BLOCK_SNAPSHOT:
BlockSnapshotRestRep snapshot = client.blockSnapshots().get(resourceId);
if (snapshot != null) {
return snapshot;
}
break;
}
throw stateException("GetBlockResource.illegalState.notFound", resourceId);
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getVolumeSnapshotOptionsForProject.
private List<AssetOption> getVolumeSnapshotOptionsForProject(AssetOptionsContext ctx, URI project) {
final ViPRCoreClient client = api(ctx);
List<BlockSnapshotRestRep> snapshots = findSnapshotsByProject(client, project);
List<BlockSnapshotRestRep> filteredSnap = new ArrayList<>();
for (BlockSnapshotRestRep snapshot : snapshots) {
if (!isSnapshotRPBookmark(snapshot)) {
filteredSnap.add(snapshot);
}
}
return constructSnapshotOptions(client, project, filteredSnap);
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationSnapshotCopySetsForRestore.
private Set<String> getApplicationSnapshotCopySetsForRestore(AssetOptionsContext ctx, URI application) {
Set<String> restoreCopySets = new HashSet<String>();
Set<String> copySetNames = api(ctx).application().getVolumeGroupSnapshotSets(application).getCopySets();
boolean isRP = false;
NamedVolumesList volsInApp = api(ctx).application().getVolumeByApplication(application);
if (volsInApp != null && volsInApp.getVolumes() != null && !volsInApp.getVolumes().isEmpty()) {
VolumeRestRep firstVol = api(ctx).blockVolumes().get(volsInApp.getVolumes().get(0).getId());
isRP = BlockStorageUtils.isRPVolume(firstVol);
}
if (isRP) {
for (String copySetName : copySetNames) {
VolumeGroupCopySetParam input = new VolumeGroupCopySetParam();
input.setCopySetName(copySetName);
SnapshotList snapshots = api(ctx).application().getVolumeGroupSnapshotsForSet(application, input);
if (snapshots != null && snapshots.getSnapList() != null && !snapshots.getSnapList().isEmpty()) {
BlockSnapshotRestRep snapRep = api(ctx).blockSnapshots().get(snapshots.getSnapList().get(0));
if (snapRep != null) {
VolumeRestRep parentVol = api(ctx).blockVolumes().get(snapRep.getParent());
if (BlockStorageUtils.isRPSourceVolume(parentVol)) {
restoreCopySets.add(copySetName);
}
}
}
}
} else {
restoreCopySets.addAll(copySetNames);
}
return restoreCopySets;
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method addVolume.
/**
* Add the volume and its snapshots to the 'blockObjects' list.
*
* When the method completes the snapshots that have been added to the blockObjects list will be removed from the snapshots list.
*/
protected static void addVolume(List<BlockObjectRestRep> blockObjects, VolumeRestRep volume, List<BlockSnapshotRestRep> snapshots) {
blockObjects.add(volume);
if (CollectionUtils.isNotEmpty(snapshots)) {
// use an iterator so we can do proper removes
Iterator<BlockSnapshotRestRep> snapshotIter = snapshots.iterator();
while (snapshotIter.hasNext()) {
BlockSnapshotRestRep snap = snapshotIter.next();
if (ResourceUtils.idEquals(snap.getParent(), volume)) {
blockObjects.add(snap);
snapshotIter.remove();
}
}
}
}
Aggregations