Search in sources :

Example 66 with FileShareRestRep

use of com.emc.storageos.model.file.FileShareRestRep 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)

Aggregations

FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)66 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)27 URI (java.net.URI)15 Asset (com.emc.sa.asset.annotation.Asset)13 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)13 AssetOption (com.emc.vipr.model.catalog.AssetOption)10 ArrayList (java.util.ArrayList)7 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)6 FileProtectionRestRep (com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep)5 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)5 Task (com.emc.vipr.client.Task)4 FlashException (controllers.util.FlashException)4 CreateFileSystem (com.emc.sa.service.vipr.file.tasks.CreateFileSystem)3 DeactivateFileSystem (com.emc.sa.service.vipr.file.tasks.DeactivateFileSystem)3 DeactivateFileSystemExportRule (com.emc.sa.service.vipr.file.tasks.DeactivateFileSystemExportRule)3 FileSystemDeleteParam (com.emc.storageos.model.file.FileSystemDeleteParam)3 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)3 FileVirtualPoolRestRep (com.emc.storageos.model.vpool.FileVirtualPoolRestRep)3 MachineTagsCollection (com.emc.sa.machinetags.MachineTagsCollection)2 DeactivateFileSystemShare (com.emc.sa.service.vipr.file.tasks.DeactivateFileSystemShare)2