use of com.emc.vipr.client.core.filters.SRDFSourceFilter in project coprhd-controller by CoprHD.
the class BlockProvider method getProtectedVolumes.
@Asset("protectedBlockVolume")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getProtectedVolumes(AssetOptionsContext ctx, URI project, String volumeOrConsistencyType) {
ViPRCoreClient client = api(ctx);
if (isVolumeType(volumeOrConsistencyType)) {
debug("getting protected volumes (project=%s)", project);
// Allow recoverpoint or SRDF sources
ResourceFilter<VolumeRestRep> filter = RecoverPointPersonalityFilter.SOURCE.or(new SRDFSourceFilter());
List<VolumeRestRep> volumes = client.blockVolumes().findByProject(project, filter);
// We need to filter out SRDF Metro volumes as they are not eligible for FAILOVER or SWAP
List<VolumeRestRep> filteredVols = new ArrayList<>();
for (VolumeRestRep currentVolume : volumes) {
ProtectionRestRep protection = currentVolume.getProtection();
if (protection != null && protection.getSrdfRep() != null && protection.getSrdfRep().getSRDFTargetVolumes() != null && !protection.getSrdfRep().getSRDFTargetVolumes().isEmpty()) {
for (VolumeRestRep srdfTarget : client.blockVolumes().getByRefs(protection.getSrdfRep().getSRDFTargetVolumes(), new SRDFTargetFilter())) {
SRDFRestRep srdf = (srdfTarget.getProtection() != null) ? srdfTarget.getProtection().getSrdfRep() : null;
if (srdf != null && (srdf.getAssociatedSourceVolume() != null) && (srdf.getSrdfCopyMode() != null) && (!ACTIVE.equalsIgnoreCase(srdf.getSrdfCopyMode()))) {
filteredVols.add(currentVolume);
break;
}
}
} else {
// Add the volume as before
filteredVols.add(currentVolume);
}
}
return createVolumeOptions(client, filteredVols);
} else {
debug("getting protected consistency groups (project=%s)", project);
// Allow recoverpoint or SRDF sources
ResourceFilter<BlockConsistencyGroupRestRep> filter = new ConsistencyGroupFilter(BlockConsistencyGroup.Types.RP.name(), false).or(new ConsistencyGroupFilter(BlockConsistencyGroup.Types.SRDF.name(), false));
List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).filter(filter).run();
// We need to filter out SRDF Metro volumes as they are not eligible for FAILOVER or SWAP
List<BlockConsistencyGroupRestRep> filteredCgs = new ArrayList<>();
for (BlockConsistencyGroupRestRep cg : consistencyGroups) {
// Get SRDF source volumes
if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
List<VolumeRestRep> srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), new SRDFSourceFilter());
if (srcVolumes != null && !srcVolumes.isEmpty()) {
// Get the first source volume and obtain its target references
VolumeRestRep srcVolume = srcVolumes.get(0);
for (VolumeRestRep srdfTarget : client.blockVolumes().getByRefs(srcVolume.getProtection().getSrdfRep().getSRDFTargetVolumes(), new SRDFTargetFilter())) {
SRDFRestRep srdf = (srdfTarget.getProtection() != null) ? srdfTarget.getProtection().getSrdfRep() : null;
if (srdf != null && (srdf.getAssociatedSourceVolume() != null) && (srdf.getSrdfCopyMode() != null) && (!ACTIVE.equalsIgnoreCase(srdf.getSrdfCopyMode()))) {
filteredCgs.add(cg);
break;
}
}
}
} else {
// Add the cg as before
filteredCgs.add(cg);
}
}
return createBaseResourceOptions(filteredCgs);
}
}
use of com.emc.vipr.client.core.filters.SRDFSourceFilter in project coprhd-controller by CoprHD.
the class BlockProvider method getFailoverTarget.
@Asset("failoverTarget")
@AssetDependencies("protectedBlockVolume")
public List<AssetOption> getFailoverTarget(AssetOptionsContext ctx, URI protectedBlockVolume) {
if (protectedBlockVolume != null) {
ViPRCoreClient client = api(ctx);
if (BlockProviderUtils.isType(protectedBlockVolume, VOLUME_TYPE)) {
debug("getting failoverTargets (protectedBlockVolume=%s)", protectedBlockVolume);
VolumeRestRep volume = client.blockVolumes().get(protectedBlockVolume);
ProtectionRestRep protection = volume.getProtection();
if (protection != null) {
// RecoverPoint protection
if (protection.getRpRep() != null && protection.getRpRep().getProtectionSet() != null) {
return getRpFailoverTargets(client, volume);
}
// VMAX SRDF protection
if (protection.getSrdfRep() != null && protection.getSrdfRep().getSRDFTargetVolumes() != null && !protection.getSrdfRep().getSRDFTargetVolumes().isEmpty()) {
return getSrdfFailoverTargets(client, volume);
}
}
} else if (BlockProviderUtils.isType(protectedBlockVolume, BLOCK_CONSISTENCY_GROUP_TYPE)) {
debug("getting failoverTargets for consistency group %s", protectedBlockVolume);
BlockConsistencyGroupRestRep cg = client.blockConsistencyGroups().get(protectedBlockVolume);
List<VolumeRestRep> srcVolumes = null;
// Get RP source volumes
if (cg.getTypes().contains(BlockConsistencyGroup.Types.RP.name())) {
srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), RecoverPointPersonalityFilter.SOURCE);
}
// Get SRDF source volumes
if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
srcVolumes = client.blockVolumes().getByRefs(cg.getVolumes(), new SRDFSourceFilter());
}
if (srcVolumes != null && !srcVolumes.isEmpty()) {
// Get the first source volume and obtain its target references
VolumeRestRep srcVolume = srcVolumes.get(0);
if (cg.getTypes() != null) {
Map<String, String> targetVolumes = Maps.newLinkedHashMap();
CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
List<VirtualArrayRelatedResourceRep> targets = new ArrayList<VirtualArrayRelatedResourceRep>();
// Process the RP targets
if (cg.getTypes().contains(BlockConsistencyGroup.Types.RP.name())) {
targets = srcVolume.getProtection().getRpRep().getRpTargets();
}
// Process the SRDF targets
if (cg.getTypes().contains(BlockConsistencyGroup.Types.SRDF.name())) {
targets = srcVolume.getProtection().getSrdfRep().getSRDFTargetVolumes();
}
for (VolumeRestRep targetVolume : client.blockVolumes().getByRefs(targets)) {
VirtualArrayRestRep virtualArray = virtualArrays.get(targetVolume.getVirtualArray());
String label = getMessage(name(virtualArray));
targetVolumes.put(stringId(virtualArray), label);
}
List<AssetOption> options = Lists.newArrayList();
for (Map.Entry<String, String> entry : targetVolumes.entrySet()) {
options.add(new AssetOption(entry.getKey(), entry.getValue()));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
}
}
}
return Lists.newArrayList();
}
Aggregations