use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getVPlexVolumesInTargetVArray.
/**
* Gets all {@link VolumeRestRep}s that are either in the target VArray or use the target VArray for protection
*
* @param client the ViPR client instance.
* @param targetVArrayId the target VArray ID.
* @param volumes the volumes we are concerned with. (These should be VPlex volumes)
* @return List of {@link VolumeRestRep}s that are VPlex volumes that are in the target VArray
*/
public static List<BlockObjectRestRep> getVPlexVolumesInTargetVArray(ViPRCoreClient client, URI targetVArrayId, List<VolumeRestRep> volumes) {
// collect vpools used by these volumes
Map<URI, BlockVirtualPoolRestRep> vpools = getVpoolsForVolumes(client, volumes);
// sift through the volumes to find ones with the correct VArray
List<BlockObjectRestRep> acceptedVolumes = Lists.newArrayList();
for (VolumeRestRep volume : volumes) {
if (volume.getVirtualArray().getId().equals(targetVArrayId)) {
addVolume(acceptedVolumes, volume);
} else {
// if this volume's HA type is 'distributed' and its distributed VArray matches the target VArray we can accept the volume
URI vpoolId = volume.getVirtualPool().getId();
BlockVirtualPoolRestRep volumeVpool = vpools.get(vpoolId);
if (volumeVpool != null && isVpoolProtectedByVarray(volumeVpool, targetVArrayId)) {
addVolume(acceptedVolumes, volume);
}
}
}
return acceptedVolumes;
}
use of com.emc.storageos.model.block.VolumeRestRep 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.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method findVolumesByProject.
/**
* Find all volumes by a project
* @param client
* @param project
* @return a list of volume REST representations.
*/
private List<VolumeRestRep> findVolumesByProject(ViPRCoreClient client, URI project) {
log.info("Finding volumes by project {}", project);
List<SearchResultResourceRep> volRefs = client.blockVolumes().performSearchBy(SearchConstants.PROJECT_PARAM, project);
List<URI> ids = new ArrayList<>();
for (SearchResultResourceRep volRef : volRefs) {
ids.add(volRef.getId());
}
List<VolumeRestRep> volumes = client.blockVolumes().getByIds(ids, null);
log.info("Got volumes: [{}]", volumes.size());
return volumes;
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getCopyNameByConsistencyGroup.
@Asset("journalCopyName")
@AssetDependencies("rpConsistencyGroupByProject")
public List<AssetOption> getCopyNameByConsistencyGroup(AssetOptionsContext ctx, URI consistencyGroupId) {
ViPRCoreClient client = api(ctx);
List<RelatedResourceRep> volumes = client.blockConsistencyGroups().get(consistencyGroupId).getVolumes();
Set<String> copyNames = Sets.newHashSet();
if (volumes != null && !volumes.isEmpty()) {
RelatedResourceRep volume = volumes.get(0);
VolumeRestRep volumeRep = client.blockVolumes().get(volume);
if (volumeRep.getProtection() != null && volumeRep.getProtection().getRpRep() != null) {
if (volumeRep.getProtection().getRpRep().getCopyName() != null) {
String copyName = volumeRep.getProtection().getRpRep().getCopyName();
copyNames.add(copyName);
}
if (volumeRep.getHaVolumes() != null) {
List<RelatedResourceRep> haVolumes = volumeRep.getHaVolumes();
List<URI> haVolumeIds = new ArrayList<URI>();
for (RelatedResourceRep haVolume : haVolumes) {
haVolumeIds.add(haVolume.getId());
}
List<VolumeRestRep> haVolumeReps = client.blockVolumes().getByIds(haVolumeIds, null);
for (VolumeRestRep haVolumeRep : haVolumeReps) {
if (haVolumeRep.getProtection() != null && haVolumeRep.getProtection().getRpRep() != null && haVolumeRep.getProtection().getRpRep().getCopyName() != null) {
String copyName = haVolumeRep.getProtection().getRpRep().getCopyName();
copyNames.add(copyName);
}
}
}
if (volumeRep.getProtection().getRpRep().getRpTargets() != null) {
List<VirtualArrayRelatedResourceRep> targetVolumes = volumeRep.getProtection().getRpRep().getRpTargets();
List<URI> targetVolumeIds = new ArrayList<URI>();
for (VirtualArrayRelatedResourceRep targetVolume : targetVolumes) {
targetVolumeIds.add(targetVolume.getId());
}
List<VolumeRestRep> targetVolumeReps = client.blockVolumes().getByIds(targetVolumeIds, null);
for (VolumeRestRep targetVolumeRep : targetVolumeReps) {
String copyName = targetVolumeRep.getProtection().getRpRep().getCopyName();
copyNames.add(copyName);
}
}
}
}
List<AssetOption> copyNameAssets = Lists.newArrayList();
for (String copyName : copyNames) {
copyNameAssets.add(newAssetOption(copyName, copyName));
}
AssetOptionsUtils.sortOptionsByLabel(copyNameAssets);
return copyNameAssets;
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getTargetVirtualPoolsForVpool.
@Asset("targetVirtualPool")
@AssetDependencies({ "project", "blockVirtualPool", "virtualPoolChangeOperation", "virtualPoolChangeVolumeWithSourceFilter", "displayJournals" })
public List<AssetOption> getTargetVirtualPoolsForVpool(AssetOptionsContext ctx, URI projectId, URI virtualPoolId, String vpoolChangeOperation, String filteredVolumes, String displayJournals) {
List<URI> volumeIds = Lists.newArrayList();
if (filteredVolumes != null && !filteredVolumes.isEmpty()) {
// Best case we are passed in the volumes selected by the user
// as comma delimited string so we do not have to load them from
// the API.
info("Filtered volumes selected by user: %s", filteredVolumes);
List<String> parsedVolumeIds = TextUtils.parseCSV(filteredVolumes);
for (String id : parsedVolumeIds) {
volumeIds.add(uri(id));
}
} else {
// Worst case we need to get the volumes from the API.
info("Loading all volumes for vpool: %s", virtualPoolId.toString());
List<VolumeRestRep> volumes = null;
if (YES_VALUE.equals(displayJournals)) {
volumes = listJournalVolumes(api(ctx), projectId, new VirtualPoolFilter(virtualPoolId));
} else {
volumes = listSourceVolumes(api(ctx), projectId, new VirtualPoolFilter(virtualPoolId));
}
for (VolumeRestRep volume : volumes) {
volumeIds.add(volume.getId());
}
}
if (CollectionUtils.isNotEmpty(volumeIds)) {
BulkIdParam input = new BulkIdParam();
input.setIds(volumeIds);
List<VirtualPoolChangeRep> vpoolChanges = api(ctx).blockVpools().listVirtualPoolChangeCandidates(virtualPoolId, input);
return createVpoolChangeOptions(vpoolChangeOperation, vpoolChanges);
}
return Collections.emptyList();
}
Aggregations