use of com.emc.vipr.client.core.util.CachedResources in project coprhd-controller by CoprHD.
the class BlockProvider method getBlockVolumes.
@Asset("unassignedVplexBlockVolume")
@AssetDependencies({ "project", "host", "virtualArray" })
public List<AssetOption> getBlockVolumes(AssetOptionsContext ctx, final URI projectId, URI hostOrClusterId, URI virtualArrayId) {
// get a list of all 'source' volumes that :
// - are in this project and not exported to the given host/cluster
// - are a 'source' volume
// - are vplex volumes
ViPRCoreClient client = api(ctx);
Set<URI> exportedBlockResources = BlockProvider.getExportedVolumes(client, projectId, hostOrClusterId, virtualArrayId);
UnexportedBlockResourceFilter<VolumeRestRep> unexportedFilter = new UnexportedBlockResourceFilter<VolumeRestRep>(exportedBlockResources);
SourceTargetVolumesFilter sourceTargetVolumesFilter = new SourceTargetVolumesFilter();
VplexVolumeFilter vplexVolumeFilter = new VplexVolumeFilter();
CachedResources<BlockVirtualPoolRestRep> blockVpools = new CachedResources<>(client.blockVpools());
VplexVolumeVirtualPoolFilter virtualPoolFilter = new VplexVolumeVirtualPoolFilter(blockVpools);
BlockVolumeBootVolumeFilter bootVolumeFilter = new BlockVolumeBootVolumeFilter();
FilterChain<VolumeRestRep> filter = sourceTargetVolumesFilter.and(unexportedFilter).and(bootVolumeFilter.not()).and(vplexVolumeFilter.or(virtualPoolFilter));
// perform the query and apply the filter
List<VolumeRestRep> volumes = client.blockVolumes().findByProject(projectId, filter);
// get a list of all volumes from our list that are in the target VArray, or use the target VArray for protection
List<BlockObjectRestRep> acceptedVolumes = getVPlexVolumesInTargetVArray(client, virtualArrayId, volumes);
return createVolumeOptions(client, acceptedVolumes);
}
use of com.emc.vipr.client.core.util.CachedResources in project coprhd-controller by CoprHD.
the class BlockProvider method getRpFailoverTargets.
protected List<AssetOption> getRpFailoverTargets(ViPRCoreClient client, VolumeRestRep volume) {
Map<String, String> targetVolumes = Maps.newLinkedHashMap();
URI protectionSetId = volume.getProtection().getRpRep().getProtectionSet().getId();
ProtectionSetRestRep localProtectionSet = client.blockVolumes().getProtectionSet(volume.getId(), protectionSetId);
String sourceSiteName = volume.getProtection().getRpRep().getInternalSiteName();
CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
List<RelatedResourceRep> rpTargets = localProtectionSet.getVolumes();
for (VolumeRestRep protectionSetVolume : client.blockVolumes().getByRefs(rpTargets, RecoverPointPersonalityFilter.TARGET)) {
String targetSiteName = protectionSetVolume.getProtection().getRpRep().getInternalSiteName();
boolean isLocal = StringUtils.equals(sourceSiteName, targetSiteName);
String rpType = isLocal ? "local" : "remote";
VirtualArrayRestRep virtualArray = virtualArrays.get(protectionSetVolume.getVirtualArray());
String label = getMessage("recoverpoint.target", name(protectionSetVolume), rpType, name(virtualArray));
targetVolumes.put(stringId(protectionSetVolume), 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;
}
use of com.emc.vipr.client.core.util.CachedResources in project coprhd-controller by CoprHD.
the class BlockProvider method getSrdfFailoverTargets.
protected List<AssetOption> getSrdfFailoverTargets(ViPRCoreClient client, VolumeRestRep volume) {
Map<String, String> targetVolumes = Maps.newLinkedHashMap();
CachedResources<VirtualArrayRestRep> virtualArrays = new CachedResources<VirtualArrayRestRep>(client.varrays());
List<VirtualArrayRelatedResourceRep> srdfTargets = volume.getProtection().getSrdfRep().getSRDFTargetVolumes();
for (VolumeRestRep protectionSetVolume : client.blockVolumes().getByRefs(srdfTargets, new SRDFTargetFilter())) {
VirtualArrayRestRep virtualArray = virtualArrays.get(protectionSetVolume.getVirtualArray());
String label = getMessage("srdf.target", name(protectionSetVolume), name(virtualArray));
targetVolumes.put(stringId(protectionSetVolume), 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;
}
use of com.emc.vipr.client.core.util.CachedResources 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