Search in sources :

Example 1 with FileProtectionRestRep

use of com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep in project coprhd-controller by CoprHD.

the class FileSystems method fileSystemMirrors.

public static void fileSystemMirrors(String fileSystemId) {
    URI id = uri(fileSystemId);
    ViPRCoreClient client = BourneUtil.getViprClient();
    FileProtectionRestRep targetFileSystems = client.fileSystems().get(id).getProtection();
    List<FileShareRestRep> fileMirrors = new ArrayList<FileShareRestRep>();
    for (VirtualArrayRelatedResourceRep virtualResource : targetFileSystems.getTargetFileSystems()) {
        fileMirrors.add(client.fileSystems().get(virtualResource.getId()));
    }
    String personality = targetFileSystems.getPersonality();
    // The code will be refactored once 1:n or cascaded FS replication is supported
    if (!fileMirrors.isEmpty()) {
        FileShareRestRep fsRestRep = fileMirrors.get(0);
        fsRestRep.getProtection().setMirrorStatus(targetFileSystems.getMirrorStatus());
    }
    // Verify the replication is at fs level or not
    boolean replicationAtFs = false;
    FileShareRestRep fs = client.fileSystems().get(id);
    if (fs != null) {
        FilePolicyRestRep replicationPolicy = getReplicationPolicy(client, fs);
        if (replicationPolicy != null) {
            if (FilePolicyApplyLevel.file_system.name().equalsIgnoreCase(replicationPolicy.getAppliedAt())) {
                replicationAtFs = true;
            }
            renderArgs.put("replicationPolicy", replicationPolicy);
        }
        renderArgs.put("replicationAtFsLevel", replicationAtFs);
    }
    renderArgs.put("personality", personality);
    renderArgs.put("fileMirrors", fileMirrors);
    renderArgs.put("fileSystemId", fileSystemId);
    render();
}
Also used : FileProtectionRestRep(com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ArrayList(java.util.ArrayList) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) URI(java.net.URI) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep)

Example 2 with FileProtectionRestRep

use of com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep in project coprhd-controller by CoprHD.

the class FileProvider method getFailoverFileTarget.

@Asset("failoverFileTarget")
@AssetDependencies("protectedRemoteFileSystem")
public List<AssetOption> getFailoverFileTarget(AssetOptionsContext ctx, URI protectedFileSystem) {
    if (protectedFileSystem != null) {
        ViPRCoreClient client = api(ctx);
        List<AssetOption> options = Lists.newArrayList();
        debug("getting failoverFileTargets (protectedFileSystem=%s)", protectedFileSystem);
        FileShareRestRep file = client.fileSystems().get(protectedFileSystem);
        FileProtectionRestRep protection = file.getProtection();
        if (protection != null) {
            List<VirtualArrayRelatedResourceRep> targets = protection.getTargetFileSystems();
            for (VirtualArrayRelatedResourceRep target : targets) {
                FileShareRestRep fileshare = client.fileSystems().get(target.getId());
                options.add(new AssetOption(fileshare.getId(), fileshare.getName()));
            }
        }
        AssetOptionsUtils.sortOptionsByLabel(options);
        return options;
    }
    return Lists.newArrayList();
}
Also used : FileProtectionRestRep(com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 3 with FileProtectionRestRep

use of com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep in project coprhd-controller by CoprHD.

the class FileProvider method getFailbackFileTarget.

@Asset("failbackFileTarget")
@AssetDependencies("protectedRemoteFileSystem")
public List<AssetOption> getFailbackFileTarget(AssetOptionsContext ctx, URI protectedFileSystem) {
    if (protectedFileSystem != null) {
        ViPRCoreClient client = api(ctx);
        List<AssetOption> options = Lists.newArrayList();
        debug("getting failbackFileTargets (protectedFileSystem=%s)", protectedFileSystem);
        FileShareRestRep file = client.fileSystems().get(protectedFileSystem);
        FileProtectionRestRep protection = file.getProtection();
        if (protection != null) {
            List<VirtualArrayRelatedResourceRep> targets = protection.getTargetFileSystems();
            for (VirtualArrayRelatedResourceRep target : targets) {
                FileShareRestRep fileshare = client.fileSystems().get(target.getId());
                options.add(new AssetOption(fileshare.getId(), fileshare.getName()));
            }
        }
        AssetOptionsUtils.sortOptionsByLabel(options);
        return options;
    }
    return Lists.newArrayList();
}
Also used : FileProtectionRestRep(com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) VirtualArrayRelatedResourceRep(com.emc.storageos.model.VirtualArrayRelatedResourceRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 4 with FileProtectionRestRep

use of com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep in project coprhd-controller by CoprHD.

the class AffectedResources method getFileMirror.

private static List<FileShareRestRep> getFileMirror(ViPRCoreClient client, URI id) {
    try {
        if (id != null) {
            List<FileShareRestRep> fileMirrors = new ArrayList<FileShareRestRep>();
            FileProtectionRestRep targetFileSystems = client.fileSystems().get(id).getProtection();
            for (VirtualArrayRelatedResourceRep virtualResource : targetFileSystems.getTargetFileSystems()) {
                fileMirrors.add(client.fileSystems().get(virtualResource.getId()));
            }
            return fileMirrors;
        }
    } catch (Exception e) {
        Logger.debug(e, "Failed to retrieve file system: %s", id);
    }
    return null;
}
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 5 with FileProtectionRestRep

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

VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)5 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)5 FileProtectionRestRep (com.emc.storageos.model.file.FileShareRestRep.FileProtectionRestRep)5 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)3 ArrayList (java.util.ArrayList)3 Asset (com.emc.sa.asset.annotation.Asset)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)2 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)1 URI (java.net.URI)1