Search in sources :

Example 11 with VirtualArrayRelatedResourceRep

use of com.emc.storageos.model.VirtualArrayRelatedResourceRep in project coprhd-controller by CoprHD.

the class FileMapper method map.

public static FileShareRestRep map(FileShare from) {
    if (from == null) {
        return null;
    }
    FileShareRestRep to = new FileShareRestRep();
    mapFileObjectFields(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.setCapacity(CapacityUtils.convertBytesToGBInStr(from.getCapacity()));
    to.setUsedCapacity(CapacityUtils.convertBytesToGBInStr(from.getUsedCapacity()));
    to.setSoftLimit(from.getSoftLimit());
    to.setSoftGrace(from.getSoftGracePeriod());
    to.setNotificationLimit(from.getNotificationLimit());
    to.setSoftLimitExceeded(from.getSoftLimitExceeded());
    to.setVirtualPool(toRelatedResource(ResourceTypeEnum.FILE_VPOOL, from.getVirtualPool()));
    to.setVirtualArray(toRelatedResource(ResourceTypeEnum.VARRAY, from.getVirtualArray()));
    to.setProtocols(from.getProtocol());
    to.setNativeId(from.getNativeId());
    to.setDataProtection(from.getDataProtection());
    to.setStorageSystem(toRelatedResource(ResourceTypeEnum.STORAGE_SYSTEM, from.getStorageDevice()));
    to.setPool(toRelatedResource(ResourceTypeEnum.STORAGE_POOL, from.getPool(), from.getStorageDevice()));
    to.setStoragePort(toRelatedResource(ResourceTypeEnum.STORAGE_PORT, from.getStoragePort(), from.getStorageDevice()));
    to.setVirtualNAS(toRelatedResource(ResourceTypeEnum.VIRTUAL_NAS, from.getVirtualNAS()));
    to.setThinlyProvisioned(from.getThinlyProvisioned());
    // Set file replication attributes!!
    FileProtectionRestRep replication = new FileProtectionRestRep();
    if (from.getPersonality() != null) {
        replication.setPersonality(from.getPersonality());
        if (PersonalityTypes.SOURCE.name().equalsIgnoreCase(from.getPersonality())) {
            if ((from.getMirrorfsTargets() != null) && (!from.getMirrorfsTargets().isEmpty())) {
                List<VirtualArrayRelatedResourceRep> mirrorTargets = new ArrayList<VirtualArrayRelatedResourceRep>();
                for (String target : from.getMirrorfsTargets()) {
                    mirrorTargets.add(toTargetFileSystemRelatedResource(ResourceTypeEnum.FILE, URI.create(target), null));
                }
                replication.setTargetFileSystems(mirrorTargets);
            }
        } else if (PersonalityTypes.TARGET.name().equalsIgnoreCase(from.getPersonality())) {
            replication.setParentFileSystem(toRelatedResource(ResourceTypeEnum.FILE, from.getParentFileShare().getURI()));
        }
    }
    if (from.getMirrorStatus() != null) {
        replication.setMirrorStatus(from.getMirrorStatus());
    }
    if (from.getAccessState() != null) {
        replication.setAccessState(from.getAccessState());
    }
    to.setProtection(replication);
    to.setFilePolicies(from.getFilePolicies());
    return to;
}
Also used : FileProtectionRestRep(com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep) ArrayList(java.util.ArrayList) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep)

Example 12 with VirtualArrayRelatedResourceRep

use of com.emc.storageos.model.VirtualArrayRelatedResourceRep 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;
}
Also used : RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) SRDFRestRep(com.emc.storageos.model.block.VolumeRestRep.SRDFRestRep) ArrayList(java.util.ArrayList) MirrorRestRep(com.emc.storageos.model.block.VolumeRestRep.MirrorRestRep) BlockMirrorRestRep(com.emc.storageos.model.block.BlockMirrorRestRep) VplexMirrorRestRep(com.emc.storageos.model.block.VplexMirrorRestRep) FullCopyRestRep(com.emc.storageos.model.block.VolumeRestRep.FullCopyRestRep) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) RecoverPointRestRep(com.emc.storageos.model.block.VolumeRestRep.RecoverPointRestRep) ProtectionRestRep(com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep) UnManagedVolume(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume) Volume(com.emc.storageos.db.client.model.Volume) StringSet(com.emc.storageos.db.client.model.StringSet) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) UnManagedVolumeRestRep(com.emc.storageos.model.block.UnManagedVolumeRestRep)

Aggregations

VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)12 ArrayList (java.util.ArrayList)7 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)6 FileProtectionRestRep (com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep)5 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)5 AssetOption (com.emc.vipr.model.catalog.AssetOption)5 Asset (com.emc.sa.asset.annotation.Asset)4 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)4 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)4 URI (java.net.URI)4 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)2 ProtectionRestRep (com.emc.storageos.model.block.VolumeRestRep.ProtectionRestRep)2 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)2 CachedResources (com.emc.vipr.client.core.util.CachedResources)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 UnManagedVolume (com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedVolume)1 Volume (com.emc.storageos.db.client.model.Volume)1