use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getExportsForExportedVolume.
@Asset("volumeExport")
@AssetDependencies("exportedBlockVolume")
public List<AssetOption> getExportsForExportedVolume(AssetOptionsContext ctx, URI volumeId) {
final ViPRCoreClient client = api(ctx);
Set<NamedRelatedResourceRep> exports = getUniqueExportsForVolume(ctx, volumeId);
return createExportWithVarrayOptions(client, client.blockExports().getByRefs(exports));
}
use of com.emc.sa.asset.annotation.AssetDependencies 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.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getVirtualArrayChangeCandidateVolumes.
@Asset("virtualArrayChangeVolume")
@AssetDependencies({ "project", "targetVirtualArray" })
public List<AssetOption> getVirtualArrayChangeCandidateVolumes(AssetOptionsContext ctx, URI projectId, URI varrayId) {
ViPRCoreClient client = api(ctx);
NamedVolumesList volumeList = client.blockVolumes().listVirtualArrayChangeCandidates(projectId, varrayId);
List<VolumeRestRep> volumes = client.blockVolumes().getByRefs(volumeList.getVolumes());
return createVolumeOptions(client, volumes);
}
use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationVirtualArrays.
@Asset("applicationVirtualArray")
@AssetDependencies("application")
public List<AssetOption> getApplicationVirtualArrays(AssetOptionsContext ctx, URI applicationId) {
final ViPRCoreClient client = api(ctx);
List<NamedRelatedResourceRep> volList = client.application().listVolumes(applicationId);
List<AssetOption> options = new ArrayList<AssetOption>();
boolean isRP = false;
URI sourceVarrayId = null;
List<VolumeRestRep> allRPSourceVols = null;
if (volList != null && !volList.isEmpty()) {
VolumeRestRep vol = client.blockVolumes().get(volList.get(0));
if (BlockProviderUtils.isVolumeRP(vol)) {
isRP = true;
allRPSourceVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.SOURCE);
if (allRPSourceVols != null && !allRPSourceVols.isEmpty()) {
VolumeRestRep rpvol = allRPSourceVols.get(0);
sourceVarrayId = rpvol.getVirtualArray().getId();
}
}
} else {
options.add(newAssetOption(URI.create("none"), "None"));
return options;
}
// if the volumes are RP (vplex or not) add the RP targets as options
if (isRP) {
options.add(newAssetOption(sourceVarrayId, "protection.site.type.source"));
Set<URI> targetVarrayIds = new HashSet<URI>();
List<AssetOption> targetOptions = new ArrayList<AssetOption>();
List<VolumeRestRep> allRPTargetVols = client.blockVolumes().getByRefs(volList, RecoverPointPersonalityFilter.TARGET);
for (VolumeRestRep targetVol : allRPTargetVols) {
targetVarrayIds.add(targetVol.getVirtualArray().getId());
}
List<VirtualArrayRestRep> targetVarrays = client.varrays().getByIds(targetVarrayIds);
for (VirtualArrayRestRep targetVarray : targetVarrays) {
targetOptions.add(newAssetOption(String.format("tgt:%s", targetVarray.getId().toString()), "protection.site.type.target", targetVarray.getName()));
}
// sort the targets
AssetOptionsUtils.sortOptionsByLabel(targetOptions);
options.addAll(targetOptions);
}
if (options.isEmpty()) {
options.add(newAssetOption(URI.create("none"), "None"));
}
return options;
}
use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getVolumesWithoutConsistencyGroup.
@Asset("volumeWithoutConsistencyGroup")
@AssetDependencies("project")
public List<AssetOption> getVolumesWithoutConsistencyGroup(AssetOptionsContext ctx, URI project) {
debug("getting volumes that don't belong to a consistency group (project=%s)", project);
ViPRCoreClient client = api(ctx);
List<VolumeRestRep> volumes = client.blockVolumes().findByProject(project);
Map<URI, VolumeRestRep> volumeNames = getProjectVolumeNames(client, project);
List<AssetOption> options = Lists.newArrayList();
for (VolumeRestRep volume : volumes) {
if (volume.getConsistencyGroup() == null) {
options.add(createVolumeOption(client, null, volume, volumeNames));
}
}
return options;
}
Aggregations