use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getExportPortGroups.
@Asset("exportChangePortGroup")
@AssetDependencies({ "host", "exportPathStorageSystem", "exportPathVirtualArray", "exportCurrentPortGroup" })
public List<AssetOption> getExportPortGroups(AssetOptionsContext ctx, URI hostOrClusterId, URI storageSystemId, URI varrayId, URI exportCurrentPortGroupId) {
final ViPRCoreClient client = api(ctx);
List<AssetOption> options = Lists.newArrayList();
SimpleValueRep value = client.customConfigs().getCustomConfigTypeValue(VMAX_PORT_GROUP_ENABLED, VMAX);
if (value.getValue().equalsIgnoreCase("true")) {
StoragePortGroupRestRepList portGroupsRestRep = client.varrays().getStoragePortGroups(varrayId, null, storageSystemId, null, null, true);
// Get a handle of the actual port group list
List<StoragePortGroupRestRep> portGroups = portGroupsRestRep.getStoragePortGroups();
// Filter out the current port group as we do not want the user to see this an a valid option
ResourceFilter<StoragePortGroupRestRep> filterExistingPG = new DefaultResourceFilter<StoragePortGroupRestRep>() {
@Override
public boolean accept(StoragePortGroupRestRep pg) {
return !pg.getId().equals(exportCurrentPortGroupId);
}
};
ResourceUtils.applyFilter(portGroups, filterExistingPG);
return createPortGroupOptions(portGroups);
}
return options;
}
use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationFullCopyNamesForRestore.
/**
* returns the list of application full copies that can be restored from. For RP, we exclude target copies because the target is read
* only
*
* @param ctx
* @param applicationId
* @return
*/
@Asset("restoreFullCopyName")
@AssetDependencies("application")
public List<AssetOption> getApplicationFullCopyNamesForRestore(AssetOptionsContext ctx, URI applicationId) {
List<VolumeRestRep> fullCopies = getFullCopiesForApplication(ctx, applicationId);
Set<String> fullCopyNames = new HashSet<String>();
for (VolumeRestRep vol : fullCopies) {
if (vol != null && vol.getProtection() != null && vol.getProtection().getFullCopyRep() != null && vol.getProtection().getFullCopyRep().getFullCopySetName() != null && !fullCopyNames.contains(vol.getProtection().getFullCopyRep().getFullCopySetName())) {
if (!isFullCopyOfRPTarget(ctx, vol)) {
fullCopyNames.add(vol.getProtection().getFullCopyRep().getFullCopySetName());
}
}
}
return createStringOptions(fullCopyNames);
}
use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getVolumesWithContinuousCopies.
@Asset("volumeWithContinuousCopies")
@AssetDependencies("project")
public List<AssetOption> getVolumesWithContinuousCopies(AssetOptionsContext ctx, URI project) {
final ViPRCoreClient client = api(ctx);
List<VolumeRestRep> volumes = client.blockVolumes().findByProject(project, new SourceTargetVolumesFilter() {
@Override
public boolean accept(VolumeRestRep volume) {
if (volume.getProtection() == null) {
return false;
}
MirrorRestRep mirrors = volume.getProtection().getMirrorRep();
if (mirrors == null || mirrors.getMirrors() == null || mirrors.getMirrors().isEmpty()) {
return false;
}
return true;
}
});
return createVolumeOptions(client, volumes);
}
use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationReplicationGroups.
@Asset("replicationGroup")
@AssetDependencies({ "application", "applicationSnapshotVirtualArray" })
public List<AssetOption> getApplicationReplicationGroups(AssetOptionsContext ctx, URI applicationId, String virtualArrayParameter) {
ViPRCoreClient client = api(ctx);
boolean isTarget = false;
URI virtualArray = null;
if (virtualArrayParameter != null && StringUtils.split(virtualArrayParameter, ':')[0].equals("tgt")) {
virtualArray = URI.create(StringUtils.substringAfter(virtualArrayParameter, ":"));
isTarget = true;
} else {
isTarget = false;
}
Set<String> subGroups = Sets.newHashSet();
NamedVolumesList applicationVolumes = client.application().getVolumeByApplication(applicationId);
for (NamedRelatedResourceRep volumeId : applicationVolumes.getVolumes()) {
VolumeRestRep volume = client.blockVolumes().get(volumeId);
VolumeRestRep parentVolume = volume;
if (volume.getHaVolumes() != null && !volume.getHaVolumes().isEmpty()) {
volume = BlockStorageUtils.getVPlexSourceVolume(client, volume);
}
if (volume != null && volume.getReplicationGroupInstance() != null) {
if (isTarget) {
if (volume.getVirtualArray().getId().equals(virtualArray)) {
subGroups.add(volume.getReplicationGroupInstance());
}
} else {
if (!BlockStorageUtils.isRPVolume(parentVolume) || BlockStorageUtils.isRPSourceVolume(parentVolume)) {
subGroups.add(volume.getReplicationGroupInstance());
}
}
}
}
return createStringOptions(BlockStorageUtils.stripRPTargetFromReplicationGroup(subGroups));
}
use of com.emc.sa.asset.annotation.AssetDependencies in project coprhd-controller by CoprHD.
the class BlockProvider method getVplexSnapshotVolumes.
@Asset("vplexVolumeWithSnapshots")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getVplexSnapshotVolumes(AssetOptionsContext ctx, URI project, String volumeOrConsistencyType) {
final ViPRCoreClient client = api(ctx);
if (isVolumeType(volumeOrConsistencyType)) {
Set<URI> volIdSet = new HashSet<>();
List<BlockSnapshotRestRep> snapshots = findSnapshotsByProject(client, project);
for (BlockSnapshotRestRep s : snapshots) {
volIdSet.add(s.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 (vol.getHaVolumes() != null && !vol.getHaVolumes().isEmpty() && !isInConsistencyGroup(vol)) {
filteredVols.add(vol);
}
}
return createVolumeOptions(client, filteredVols);
} else {
List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().findByProject(project, new DefaultResourceFilter<BlockConsistencyGroupRestRep>() {
@Override
public boolean accept(BlockConsistencyGroupRestRep cg) {
if (cg.getTypes() != null && cg.getTypes().contains(Types.VPLEX.name())) {
return true;
} else {
return false;
}
}
});
return createBaseResourceOptions(consistencyGroups);
}
}
Aggregations