use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class TestBlockStorageUtils method prepare.
static List<URI> prepare(ViPRCoreClient client) throws URISyntaxException {
List<URI> returnList = new ArrayList<>();
ProjectRestRep project = client.projects().get(new URI("urn:storageos:Project:3e1ef32b-3091-4a83-9fac-4a2a3bc30413:global"));
for (BlockSnapshotRestRep r : client.blockSnapshots().findByProject(project)) {
returnList.add(r.getId());
}
for (VolumeRestRep r : client.blockVolumes().findByProject(project)) {
returnList.add(r.getId());
}
return returnList;
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method constructSnapshotWithSnapshotSessionOptions.
protected List<AssetOption> constructSnapshotWithSnapshotSessionOptions(List<BlockSnapshotRestRep> snapshots, List<BlockSnapshotSessionRestRep> snapshotSessions) {
List<AssetOption> options = Lists.newArrayList();
// Create a map of linked target URIs to snapshot session names for convenience when creating
// the option labels.
Map<URI, String> linkedSnapshotToSnapshotSessionMap = new HashMap<URI, String>();
for (BlockSnapshotSessionRestRep snapshotSession : snapshotSessions) {
for (RelatedResourceRep linkedTarget : snapshotSession.getLinkedTarget()) {
linkedSnapshotToSnapshotSessionMap.put(linkedTarget.getId(), snapshotSession.getName());
}
}
for (BlockSnapshotRestRep snapshot : snapshots) {
// Ignore RP Bookmarks for snapshot session options
boolean isRPSnapshot = (snapshot.getTechnologyType() != null && snapshot.getTechnologyType().equalsIgnoreCase(RECOVERPOINT_BOOKMARK_SNAPSHOT_TYPE_VALUE));
boolean validSnapshotOption = snapshot.getTechnologyType() == null || !isRPSnapshot;
if (validSnapshotOption) {
options.add(new AssetOption(snapshot.getId(), getBlockSnapshotLinkedLabel(snapshot, linkedSnapshotToSnapshotSessionMap)));
}
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getBlockVolumesWithSnapshot.
@Asset("blockVolumeWithSnapshot")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getBlockVolumesWithSnapshot(AssetOptionsContext context, URI project, String volumeOrConsistencyType) {
final ViPRCoreClient client = api(context);
if (isVolumeType(volumeOrConsistencyType)) {
Set<URI> volIdSet = new HashSet<>();
List<BlockSnapshotRestRep> snapshots = findSnapshotsByProject(client, project);
for (BlockSnapshotRestRep snapshot : snapshots) {
volIdSet.add(snapshot.getParent().getId());
}
// Have to get volumes just as it needs vol's mount point which snapshot doesn't have.
List<VolumeRestRep> volumes = getVolumesByIds(client, volIdSet);
List<VolumeRestRep> filteredVols = new ArrayList<>();
for (VolumeRestRep vol : volumes) {
if (StringUtils.isEmpty(vol.getReplicationGroupInstance())) {
filteredVols.add(vol);
}
}
return createVolumeOptions(client, filteredVols);
} else {
List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).run();
return createBaseResourceOptions(consistencyGroups);
}
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getLinkedSnapshotsForSnapshotSessionVolume.
@Asset("linkedSnapshotsForVolume")
@AssetDependencies({ "snapshotSessionBlockVolume", "blockVolumeOrConsistencyType" })
public List<AssetOption> getLinkedSnapshotsForSnapshotSessionVolume(AssetOptionsContext ctx, URI volumeOrCGId, String volumeOrConsistencyType) {
if (!checkTypeConsistency(volumeOrCGId, volumeOrConsistencyType)) {
warn("Inconsistent types, %s and %s, return empty results", volumeOrCGId, volumeOrConsistencyType);
return new ArrayList<AssetOption>();
}
List<BlockSnapshotRestRep> snapshots = new ArrayList<BlockSnapshotRestRep>();
List<BlockSnapshotSessionRestRep> snapshotSessions = new ArrayList<BlockSnapshotSessionRestRep>();
final ViPRCoreClient client = api(ctx);
if (isVolumeType(volumeOrConsistencyType)) {
snapshots = client.blockSnapshots().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
snapshotSessions = client.blockSnapshotSessions().getByVolume(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
} else {
snapshots = client.blockSnapshots().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotRestRep>());
snapshotSessions = client.blockSnapshotSessions().getByConsistencyGroup(volumeOrCGId, new DefaultResourceFilter<BlockSnapshotSessionRestRep>());
}
return constructSnapshotWithSnapshotSessionOptions(snapshots, snapshotSessions);
}
use of com.emc.storageos.model.block.BlockSnapshotRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method constructSnapshotOptions.
protected List<AssetOption> constructSnapshotOptions(ViPRCoreClient client, URI project, List<BlockSnapshotRestRep> snapshots) {
List<AssetOption> options = Lists.newArrayList();
Map<URI, VolumeRestRep> volumeNames = getProjectVolumeNames(client, project);
for (BlockSnapshotRestRep snapshot : snapshots) {
options.add(new AssetOption(snapshot.getId(), getBlockObjectLabel(client, snapshot, volumeNames)));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
Aggregations