use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getBlockSnapshotType.
@Asset("blockSnapshotType")
@AssetDependencies({ "blockVolumeOrConsistencyType", "snapshotBlockVolume" })
public List<AssetOption> getBlockSnapshotType(AssetOptionsContext ctx, String storageType, URI blockVolumeOrCG) {
// These are hard coded values for now. In the future, this may be available through an API
List<AssetOption> options = Lists.newArrayList();
if (isConsistencyGroupType(blockVolumeOrCG)) {
options.add(CG_SNAPSHOT_TYPE_OPTION);
// Only add cg session option if the CG selected supports it
ViPRCoreClient client = api(ctx);
BlockConsistencyGroupRestRep cg = client.blockConsistencyGroups().get(blockVolumeOrCG);
if (isSnapshotSessionSupportedForCG(cg)) {
options.add(CG_SNAPSHOT_SESSION_TYPE_OPTION);
}
} else {
debug("getting blockSnapshotTypes (blockVolume=%s)", blockVolumeOrCG);
ViPRCoreClient client = api(ctx);
VolumeRestRep volume = client.blockVolumes().get(blockVolumeOrCG);
BlockVirtualPoolRestRep virtualPool = client.blockVpools().get(volume.getVirtualPool());
if (isLocalSnapshotSupported(virtualPool)) {
options.add(LOCAL_ARRAY_SNAPSHOT_TYPE_OPTION);
}
if (isRPSourceVolume(volume)) {
options.add(RECOVERPOINT_BOOKMARK_SNAPSHOT_TYPE_OPTION);
}
if (isSnapshotSessionSupportedForVolume(volume)) {
options.add(SNAPSHOT_SESSION_TYPE_OPTION);
}
}
return options;
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getAddMobilityGroupResources.
@Asset("addMobilityGroupResource")
@AssetDependencies("mobilityGroup")
public List<AssetOption> getAddMobilityGroupResources(AssetOptionsContext ctx, final URI mobilityGroupId) {
final ViPRCoreClient client = api(ctx);
VolumeGroupRestRep mobilityGroup = client.application().get(mobilityGroupId);
if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.VOLUMES.name())) {
// VPLEX volumes that don't have reference to this mobility group
List<URI> volumeIds = client.blockVolumes().listBulkIds();
final ResourceFilter<VolumeRestRep> vplexFilter = new VplexVolumeFilter();
List<VolumeRestRep> volumes = client.blockVolumes().getByIds(volumeIds, new ResourceFilter<VolumeRestRep>() {
@Override
public boolean acceptId(URI id) {
return true;
}
@Override
public boolean accept(VolumeRestRep item) {
boolean accept = (item.getVolumeGroups() == null || !contains(item, mobilityGroupId)) && vplexFilter.accept(item);
if (accept) {
boolean rpProtection = (item.getProtection() != null && item.getProtection().getRpRep() != null && item.getProtection().getRpRep().getPersonality() != null);
if (rpProtection) {
// If RP+VPLEX protection specified, only allow RP SOURCE volumes to be listed
// as candidates for mobility groups. Exclude TARGETs and JOURNALs.
String personality = item.getProtection().getRpRep().getPersonality();
if (Volume.PersonalityTypes.TARGET.name().equals(personality) || Volume.PersonalityTypes.METADATA.name().equals(personality)) {
accept = false;
}
}
}
return accept;
}
private boolean contains(VolumeRestRep item, URI mobilityGroup) {
for (RelatedResourceRep vg : item.getVolumeGroups()) {
if (vg.getId().equals(mobilityGroup)) {
return true;
}
}
return false;
}
});
return createBaseResourceOptions(volumes);
} else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.HOSTS.name())) {
List<URI> hostIds = client.hosts().listBulkIds();
List<HostRestRep> hosts = client.hosts().getByIds(hostIds, new ResourceFilter<HostRestRep>() {
@Override
public boolean acceptId(URI id) {
return true;
}
@Override
public boolean accept(HostRestRep item) {
return item.getVolumeGroups() == null || !contains(item, mobilityGroupId);
}
private boolean contains(HostRestRep item, URI mobilityGroup) {
for (RelatedResourceRep vg : item.getVolumeGroups()) {
if (vg.getId().equals(mobilityGroup)) {
return true;
}
}
return false;
}
});
return createBaseResourceOptions(hosts);
} else if (mobilityGroup.getMigrationGroupBy().equals(VolumeGroup.MigrationGroupBy.CLUSTERS.name())) {
List<URI> clusterIds = client.clusters().listBulkIds();
List<ClusterRestRep> clusters = client.clusters().getByIds(clusterIds, new ResourceFilter<ClusterRestRep>() {
@Override
public boolean acceptId(URI id) {
return true;
}
@Override
public boolean accept(ClusterRestRep item) {
return item.getVolumeGroups() == null || !contains(item, mobilityGroupId);
}
private boolean contains(ClusterRestRep item, URI mobilityGroup) {
for (RelatedResourceRep vg : item.getVolumeGroups()) {
if (vg.getId().equals(mobilityGroup)) {
return true;
}
}
return false;
}
});
return createBaseResourceOptions(clusters);
} else {
return Lists.newArrayList();
}
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationReplicationGroupsForCopy.
@Asset("copyReplicationGroup")
@AssetDependencies({ "application", "restoreFullCopyName" })
public List<AssetOption> getApplicationReplicationGroupsForCopy(AssetOptionsContext ctx, URI applicationId, String copyName) {
final ViPRCoreClient client = api(ctx);
List<VolumeRestRep> allCopyVols = client.blockVolumes().getByRefs(client.application().getFullCopiesByApplication(applicationId).getVolumes());
return createStringOptions(BlockStorageUtils.stripRPTargetFromReplicationGroup(groupFullCopyByApplicationSubGroup(ctx, filterByCopyName(allCopyVols, copyName)).keySet()));
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getSnapshotSessionBlockVolumes.
@Asset("snapshotSessionBlockVolume")
@AssetDependencies({ "project", "blockVolumeOrConsistencyType" })
public List<AssetOption> getSnapshotSessionBlockVolumes(AssetOptionsContext context, URI project, String storageType) {
final ViPRCoreClient client = api(context);
if (isVolumeType(storageType)) {
List<VolumeRestRep> volumes = listVolumes(client, project);
List<VolumeDetail> volumeDetails = getVolumeDetails(client, volumes);
Map<URI, VolumeRestRep> volumeNames = ResourceUtils.mapById(volumes);
List<AssetOption> options = Lists.newArrayList();
for (VolumeDetail detail : volumeDetails) {
boolean localSnapSupported = isLocalSnapshotSupported(detail.vpool);
boolean isRPTargetVolume = isRPTargetVolume(detail.volume);
boolean isRPSourceVolume = isRPSourceVolume(detail.volume);
boolean isInConsistencyGroup = !StringUtils.isEmpty(detail.volume.getReplicationGroupInstance());
boolean isSnapshotSessionSupported = isSnapshotSessionSupportedForVolume(detail.volume);
debug("filter[ localSnapSupported=%s, isRPTargetVolume=%s, isRPSourceVolume=%s, isInConsistencyGroup=%s, isXio3XVolume=%s ]", localSnapSupported, isRPTargetVolume, isRPSourceVolume, isInConsistencyGroup, isSnapshotSessionSupported);
if (isSnapshotSessionSupported && localSnapSupported && !isInConsistencyGroup) {
options.add(createVolumeOption(client, null, detail.volume, volumeNames));
}
}
return options;
} else {
List<BlockConsistencyGroupRestRep> consistencyGroups = client.blockConsistencyGroups().search().byProject(project).run();
return createBaseResourceOptions(consistencyGroups);
}
}
use of com.emc.storageos.model.block.VolumeRestRep in project coprhd-controller by CoprHD.
the class BlockProvider method getApplicationSnapshotSessionCopySetsForRestore.
private Set<String> getApplicationSnapshotSessionCopySetsForRestore(AssetOptionsContext ctx, URI application) {
Set<String> restoreCopySets = new HashSet<String>();
Set<String> copySetNames = api(ctx).application().getVolumeGroupSnapsetSessionSets(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) {
List<VolumeRestRep> applicationVolumes = api(ctx).blockVolumes().getByRefs(api(ctx).application().getVolumeByApplication(application).getVolumes());
Set<String> sourceRepGrpNames = new HashSet<String>();
for (VolumeRestRep volume : applicationVolumes) {
if (volume.getReplicationGroupInstance() != null && BlockStorageUtils.isRPSourceVolume(volume)) {
sourceRepGrpNames.add(volume.getReplicationGroupInstance());
}
}
for (String copySetName : copySetNames) {
VolumeGroupCopySetParam input = new VolumeGroupCopySetParam();
input.setCopySetName(copySetName);
BlockSnapshotSessionList sessions = api(ctx).application().getVolumeGroupSnapshotSessionsByCopySet(application, input);
if (sessions != null && sessions.getSnapSessionRelatedResourceList() != null && !sessions.getSnapSessionRelatedResourceList().isEmpty()) {
BlockSnapshotSessionRestRep sessionRep = api(ctx).blockSnapshotSessions().get(sessions.getSnapSessionRelatedResourceList().get(0));
if (sessionRep != null && sessionRep.getReplicationGroupInstance() != null && sourceRepGrpNames.contains(sessionRep.getReplicationGroupInstance())) {
restoreCopySets.add(copySetName);
}
}
}
} else {
restoreCopySets.addAll(copySetNames);
}
return restoreCopySets;
}
Aggregations