Search in sources :

Example 6 with FileVirtualPoolRestRep

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

the class FileVirtualPoolForm method save.

@Override
public FileVirtualPoolRestRep save() {
    FileVirtualPoolRestRep virtualPool = doSave();
    FileVirtualPools vpools = getViprClient().fileVpools();
    saveQuota(vpools);
    saveTenantACLs(vpools);
    return virtualPool;
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) FileVirtualPools(com.emc.vipr.client.core.FileVirtualPools)

Example 7 with FileVirtualPoolRestRep

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

the class FileSystems method getReplicationPolicy.

private static FilePolicyRestRep getReplicationPolicy(ViPRCoreClient client, FileShareRestRep fs) {
    if (fs != null) {
        // Check file system vpool has replication policy!!!
        FileVirtualPoolRestRep vpool = client.fileVpools().get(fs.getVirtualPool().getId());
        if (vpool != null && vpool.getFileProtectionPolicies() != null && !vpool.getFileProtectionPolicies().isEmpty()) {
            for (String uriPolicy : vpool.getFileProtectionPolicies()) {
                FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(uri(uriPolicy));
                if (policyRestRep != null && "file_replication".equalsIgnoreCase(policyRestRep.getType())) {
                    return policyRestRep;
                }
            }
        }
        // Check file system project has replication policy!!!
        ProjectRestRep project = client.projects().get(fs.getProject().getId());
        if (project != null && project.getFileProtectionPolicies() != null && !project.getFileProtectionPolicies().isEmpty()) {
            for (String uriPolicy : project.getFileProtectionPolicies()) {
                FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(uri(uriPolicy));
                if (policyRestRep != null && "file_replication".equalsIgnoreCase(policyRestRep.getType()) && policyRestRep.getVpool() != null && policyRestRep.getVpool().getId() != null && policyRestRep.getVpool().getId().equals(vpool.getId())) {
                    return policyRestRep;
                }
            }
        }
        // Check file system has replication policy!!!
        if (fs.getFilePolicies() != null && !fs.getFilePolicies().isEmpty()) {
            for (String uriPolicy : fs.getFilePolicies()) {
                FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(uri(uriPolicy));
                if (policyRestRep != null && "file_replication".equalsIgnoreCase(policyRestRep.getType())) {
                    return policyRestRep;
                }
            }
        }
    }
    return null;
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) ProjectRestRep(com.emc.storageos.model.project.ProjectRestRep)

Example 8 with FileVirtualPoolRestRep

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

the class FileProtectionPolicies method getVarraysAssociatedWithPools.

public static void getVarraysAssociatedWithPools(String id) {
    List<VirtualArrayRestRep> varrayList = Lists.newArrayList();
    Set<String> varraySet = Sets.newHashSet();
    FileVirtualPoolRestRep vpool = getViprClient().fileVpools().get(uri(id));
    List<RelatedResourceRep> varrays = vpool.getVirtualArrays();
    for (RelatedResourceRep varray : varrays) {
        varraySet.add(varray.getId().toString());
    }
    for (String varrayId : varraySet) {
        VirtualArrayRestRep varray = getViprClient().varrays().get(uri(varrayId));
        varrayList.add(varray);
    }
    renderJSON(varrayList);
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep)

Example 9 with FileVirtualPoolRestRep

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

the class FileProtectionPolicies method getFileVirtualPoolsOptions.

private static List<StringOption> getFileVirtualPoolsOptions(FilePolicyRestRep policy) {
    Collection<FileVirtualPoolRestRep> virtualPools;
    virtualPools = getViprClient().fileVpools().getAll();
    Collection<FileVirtualPoolRestRep> vPools = Lists.newArrayList();
    for (FileVirtualPoolRestRep vpool : virtualPools) {
        // first level filter based on the protection is enabled or not
        FileVirtualPoolProtectionParam protectParam = vpool.getProtection();
        if (protectParam == null) {
            continue;
        }
        // 2nde level filter based on the applied level of policy and the pool
        if (FilePolicyApplyLevel.project.name().equalsIgnoreCase(policy.getAppliedAt()) && !protectParam.getAllowFilePolicyAtProjectLevel()) {
            continue;
        }
        if (FilePolicyApplyLevel.file_system.name().equalsIgnoreCase(policy.getAppliedAt()) && !protectParam.getAllowFilePolicyAtFSLevel()) {
            continue;
        }
        // now add pool into list if matches protection type with policy
        if (FilePolicyType.file_snapshot.name().equalsIgnoreCase(policy.getType()) && protectParam.getScheduleSnapshots()) {
            vPools.add(vpool);
        } else if (FilePolicyType.file_replication.name().equalsIgnoreCase(policy.getType()) && protectParam.getReplicationSupported()) {
            vPools.add(vpool);
        }
    }
    return createResourceOptions(vPools);
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) FileVirtualPoolProtectionParam(com.emc.storageos.model.vpool.FileVirtualPoolProtectionParam)

Example 10 with FileVirtualPoolRestRep

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

the class FileProvider method getFileTargetVirtualPools.

@Asset("fileTargetVirtualPool")
@AssetDependencies({ "fileFilePolicy" })
public List<AssetOption> getFileTargetVirtualPools(AssetOptionsContext ctx, URI filePolicy) {
    List<AssetOption> options = Lists.newArrayList();
    ViPRCoreClient client = api(ctx);
    FilePolicyRestRep policyRest = client.fileProtectionPolicies().getFilePolicy(filePolicy);
    List<FileVirtualPoolRestRep> vpoolChanges = client.fileVpools().getByTenant(ctx.getTenant());
    for (FileVirtualPoolRestRep vpool : vpoolChanges) {
        if (vpool.getProtection() != null) {
            if ((policyRest.getType().equals("file_snapshot") && vpool.getProtection().getScheduleSnapshots()) || (policyRest.getType().equals("file_replication") && vpool.getProtection().getReplicationSupported())) {
                options.add(new AssetOption(vpool.getId(), vpool.getName()));
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : FileVirtualPoolRestRep(com.emc.storageos.model.vpool.FileVirtualPoolRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

FileVirtualPoolRestRep (com.emc.storageos.model.vpool.FileVirtualPoolRestRep)21 Asset (com.emc.sa.asset.annotation.Asset)8 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)7 URI (java.net.URI)7 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)6 AssetOption (com.emc.vipr.model.catalog.AssetOption)5 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)3 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)3 FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)3 FileVirtualPoolProtectionParam (com.emc.storageos.model.vpool.FileVirtualPoolProtectionParam)3 Map (java.util.Map)3 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)2 FileVirtualPoolForm (models.virtualpool.FileVirtualPoolForm)2 VirtualPoolMapper.toFileVirtualPool (com.emc.storageos.api.mapper.VirtualPoolMapper.toFileVirtualPool)1 MapFileVirtualPool (com.emc.storageos.api.mapper.functions.MapFileVirtualPool)1 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)1 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)1 StoragePoolRestRep (com.emc.storageos.model.pools.StoragePoolRestRep)1 StoragePortRestRep (com.emc.storageos.model.ports.StoragePortRestRep)1 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)1