use of com.emc.storageos.model.block.VolumeRestRep.FullCopyRestRep in project coprhd-controller by CoprHD.
the class BlockMapper method map.
public static VolumeRestRep map(DbClient dbClient, Volume from, Map<URI, Boolean> projectSrdfCapableCache) {
if (from == null) {
return null;
}
VolumeRestRep to = new VolumeRestRep();
mapBlockObjectFields(from, to);
if (from.getProject() != null) {
to.setProject(toRelatedResource(ResourceTypeEnum.PROJECT, from.getProject().getURI()));
}
if (from.getTenant() != null) {
to.setTenant(toRelatedResource(ResourceTypeEnum.TENANT, from.getTenant().getURI()));
}
to.setProvisionedCapacity(CapacityUtils.convertBytesToGBInStr(from.getProvisionedCapacity()));
// For VPLEX virtual volumes return allocated capacity as provisioned capacity (cop-18608)
to.setAllocatedCapacity(CapacityUtils.convertBytesToGBInStr(from.getAllocatedCapacity()));
boolean isVplexVolume = DiscoveredDataObject.Type.vplex.name().equalsIgnoreCase(from.getSystemType());
if (isVplexVolume) {
to.setAllocatedCapacity(CapacityUtils.convertBytesToGBInStr(from.getProvisionedCapacity()));
}
to.setCapacity(CapacityUtils.convertBytesToGBInStr(from.getCapacity()));
if (from.getThinlyProvisioned()) {
to.setPreAllocationSize(CapacityUtils.convertBytesToGBInStr(from.getThinVolumePreAllocationSize()));
}
to.setVirtualPool(toRelatedResource(ResourceTypeEnum.BLOCK_VPOOL, from.getVirtualPool()));
to.setIsComposite(from.getIsComposite());
to.setAutoTierPolicyUri(toRelatedResource(ResourceTypeEnum.AUTO_TIERING_POLICY, from.getAutoTieringPolicyUri(), from.getId()));
to.setThinlyProvisioned(from.getThinlyProvisioned());
to.setAccessState(from.getAccessState());
to.setLinkStatus(from.getLinkStatus());
// Default snapshot session support to false
to.setSupportsSnapshotSessions(Boolean.FALSE);
// set compression ratio
to.setCompressionRatio(from.getCompressionRatio());
if (DiscoveredDataObject.Type.vmax3.name().equalsIgnoreCase(from.getSystemType())) {
to.setSupportsSnapshotSessions(Boolean.TRUE);
}
to.setSystemType(from.getSystemType());
// Extra checks for VPLEX volumes
Volume srdfVolume = from;
Volume sourceSideBackingVolume = null;
if (null != dbClient && null != from.getAssociatedVolumes() && !from.getAssociatedVolumes().isEmpty()) {
// For snapshot session support of a VPLEX volume, we only need to check the SOURCE side of the
// volume.
sourceSideBackingVolume = VPlexUtil.getVPLEXBackendVolume(from, true, dbClient);
// Check for null in case the VPlex vol was ingested w/o the backend volumes
if ((sourceSideBackingVolume != null) && DiscoveredDataObject.Type.vmax3.name().equalsIgnoreCase(sourceSideBackingVolume.getSystemType())) {
to.setSupportsSnapshotSessions(Boolean.TRUE);
}
// SrdfRestRep below.
if (projectSrdfCapable(dbClient, from.getProject().getURI(), projectSrdfCapableCache)) {
srdfVolume = VPlexSrdfUtil.getSrdfVolumeFromVplexVolume(dbClient, from);
srdfVolume = (srdfVolume != null ? srdfVolume : from);
}
to.setAccessState(srdfVolume.getAccessState());
to.setLinkStatus(srdfVolume.getLinkStatus());
}
if (from.getPool() != null) {
to.setPool(toRelatedResource(ResourceTypeEnum.STORAGE_POOL, from.getPool()));
}
// RecoverPoint specific section
RecoverPointRestRep toRp = null;
if (from.checkForRp()) {
toRp = new RecoverPointRestRep();
toRp.setProtectionSystem(toRelatedResource(ResourceTypeEnum.PROTECTION_SYSTEM, from.getProtectionController()));
toRp.setPersonality(from.getPersonality());
toRp.setInternalSiteName(from.getInternalSiteName());
toRp.setCopyName(from.getRpCopyName());
toRp.setRsetName(from.getRSetName());
if ((from.getRpTargets() != null) && (!from.getRpTargets().isEmpty())) {
List<VirtualArrayRelatedResourceRep> rpTargets = new ArrayList<VirtualArrayRelatedResourceRep>();
for (String target : from.getRpTargets()) {
rpTargets.add(toTargetVolumeRelatedResource(ResourceTypeEnum.VOLUME, URI.create(target), getVarray(dbClient, target)));
}
toRp.setRpTargets(rpTargets);
}
if (from.getProtectionSet() != null) {
toRp.setProtectionSet(toRelatedResource(ResourceTypeEnum.PROTECTION_SET, from.getProtectionSet().getURI(), from.getId()));
}
}
// Mirror specific section
MirrorRestRep toMirror = null;
if ((from.getMirrors() != null) && (!from.getMirrors().isEmpty())) {
toMirror = new MirrorRestRep();
List<VirtualArrayRelatedResourceRep> mirrors = new ArrayList<VirtualArrayRelatedResourceRep>();
for (String mirror : from.getMirrors()) {
mirrors.add(toTargetVolumeRelatedResource(ResourceTypeEnum.BLOCK_MIRROR, URI.create(mirror), from.getId(), getVarray(dbClient, mirror)));
}
toMirror.setMirrors(mirrors);
}
// Full copy specific section
FullCopyRestRep toFullCopy = null;
URI fullCopySourceVolumeURI = from.getAssociatedSourceVolume();
StringSet fromFullCopies = from.getFullCopies();
if (!NullColumnValueGetter.isNullURI(fullCopySourceVolumeURI) || (fromFullCopies != null && !fromFullCopies.isEmpty())) {
toFullCopy = new FullCopyRestRep();
if (fullCopySourceVolumeURI != null) {
toFullCopy.setAssociatedSourceVolume(toRelatedResource(ResourceTypeEnum.VOLUME, fullCopySourceVolumeURI));
}
if (fromFullCopies != null) {
List<VirtualArrayRelatedResourceRep> fullCopies = new ArrayList<VirtualArrayRelatedResourceRep>();
for (String fullCopy : fromFullCopies) {
fullCopies.add(toTargetVolumeRelatedResource(ResourceTypeEnum.VOLUME, URI.create(fullCopy), getVarray(dbClient, fullCopy)));
}
toFullCopy.setFullCopyVolumes(fullCopies);
}
if (from.getSyncActive() != null) {
toFullCopy.setSyncActive(from.getSyncActive());
}
if (from.getReplicaState() != null) {
toFullCopy.setReplicaState(from.getReplicaState());
}
if (from.getFullCopySetName() != null) {
toFullCopy.setFullCopySetName(from.getFullCopySetName());
}
}
// SRDF specific section; uses srdfVolume which is a copy of from unless
// it's a vplex underlying srdf volume
SRDFRestRep toSRDF = null;
if ((srdfVolume.getSrdfTargets() != null) && (!srdfVolume.getSrdfTargets().isEmpty())) {
toSRDF = new SRDFRestRep();
List<VirtualArrayRelatedResourceRep> targets = new ArrayList<VirtualArrayRelatedResourceRep>();
if (srdfVolume != from) {
// VPLEX; translate targets to corresponding VPLEX volume. if any
for (String target : VPlexSrdfUtil.getSrdfOrVplexTargets(dbClient, srdfVolume)) {
targets.add(toTargetVolumeRelatedResource(ResourceTypeEnum.VOLUME, URI.create(target), getVarray(dbClient, target)));
}
} else {
// Non-VPLEX
for (String target : from.getSrdfTargets()) {
targets.add(toTargetVolumeRelatedResource(ResourceTypeEnum.VOLUME, URI.create(target), getVarray(dbClient, target)));
}
}
toSRDF.setPersonality(srdfVolume.getPersonality());
toSRDF.setSRDFTargetVolumes(targets);
} else if (!NullColumnValueGetter.isNullNamedURI(srdfVolume.getSrdfParent())) {
toSRDF = new SRDFRestRep();
toSRDF.setPersonality(srdfVolume.getPersonality());
toSRDF.setAssociatedSourceVolume(toRelatedResource(ResourceTypeEnum.VOLUME, srdfVolume.getSrdfParent().getURI()));
toSRDF.setSrdfCopyMode(srdfVolume.getSrdfCopyMode());
toSRDF.setSrdfGroup(srdfVolume.getSrdfGroup());
}
// Protection object encapsulates mirrors and RP
if (toMirror != null || toRp != null || toFullCopy != null || toSRDF != null) {
ProtectionRestRep toProtection = new ProtectionRestRep();
toProtection.setMirrorRep(toMirror);
toProtection.setRpRep(toRp);
toProtection.setFullCopyRep(toFullCopy);
toProtection.setSrdfRep(toSRDF);
to.setProtection(toProtection);
}
String replicationGroupInstance = isVplexVolume ? from.getBackingReplicationGroupInstance() : from.getReplicationGroupInstance();
if (NullColumnValueGetter.isNotNullValue(replicationGroupInstance)) {
to.setReplicationGroupInstance(replicationGroupInstance);
}
if ((from.getAssociatedVolumes() != null) && (!from.getAssociatedVolumes().isEmpty())) {
List<RelatedResourceRep> backingVolumes = new ArrayList<RelatedResourceRep>();
for (String backingVolume : from.getAssociatedVolumes()) {
backingVolumes.add(toRelatedResource(ResourceTypeEnum.VOLUME, URI.create(backingVolume)));
}
to.setHaVolumes(backingVolumes);
}
if ((from.getVolumeGroupIds() != null) && (!from.getVolumeGroupIds().isEmpty())) {
List<RelatedResourceRep> volumeGroups = new ArrayList<RelatedResourceRep>();
for (String volumeGroup : from.getVolumeGroupIds()) {
volumeGroups.add(toRelatedResource(ResourceTypeEnum.VOLUME_GROUP, URI.create(volumeGroup)));
}
to.setVolumeGroups(volumeGroups);
}
return to;
}
Aggregations