Search in sources :

Example 1 with FilePolicyRestRep

use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.

the class VirtualArrayProvider method getTargetVirtualArrays.

@Asset("fileTargetVirtualArray")
@AssetDependencies({ "fileFilePolicy", "unprotectedFilesystem" })
public List<AssetOption> getTargetVirtualArrays(AssetOptionsContext context, URI filePolicy, URI fsId) {
    ViPRCoreClient client = api(context);
    FilePolicyRestRep policyRest = client.fileProtectionPolicies().getFilePolicy(filePolicy);
    if (policyRest.getType().equals("file_snapshot")) {
        VirtualArrayRestRep vArray = null;
        List<AssetOption> options = Lists.newArrayList();
        FileShareRestRep fsObj = client.fileSystems().get(fsId);
        if (fsObj != null) {
            vArray = client.varrays().get(fsObj.getVirtualArray().getId());
            options.add(createBaseResourceOption(vArray));
        }
        return options;
    } else {
        return getFileVirtualArrays(context);
    }
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) VirtualArrayRestRep(com.emc.storageos.model.varray.VirtualArrayRestRep) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 2 with FilePolicyRestRep

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

Example 3 with FilePolicyRestRep

use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.

the class FileProtectionPolicies method unassign.

@FlashException(value = "list", keep = true)
public static void unassign(String ids) {
    FilePolicyRestRep filePolicyRestRep = getViprClient().fileProtectionPolicies().get(uri(ids));
    if (filePolicyRestRep != null) {
        AssignPolicyForm assignPolicy = new AssignPolicyForm().form(filePolicyRestRep);
        addRenderApplyPolicysAt();
        addAssignedProjectArgs(filePolicyRestRep);
        addAssignedVPoolArgs(filePolicyRestRep);
        render(assignPolicy);
    } else {
        flash.error(MessagesUtils.get(UNKNOWN, ids));
        list();
    }
}
Also used : FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) FlashException(controllers.util.FlashException)

Example 4 with FilePolicyRestRep

use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.

the class FileProtectionPolicies method updateUnAssignPolicyParam.

private static Boolean updateUnAssignPolicyParam(AssignPolicyForm assignPolicy, FilePolicyUnAssignParam param) {
    Boolean policyUnAssignment = false;
    FilePolicyRestRep existingPolicy = getViprClient().fileProtectionPolicies().get(URI.create(assignPolicy.id));
    if (FilePolicyApplyLevel.project.name().equalsIgnoreCase(existingPolicy.getAppliedAt())) {
        List<String> projects = Lists.newArrayList();
        if (assignPolicy.unassignedProjects != null) {
            projects = assignPolicy.unassignedProjects;
        }
        List<String> remove = projects;
        // removed projects
        Set<URI> unAssingRes = new HashSet<URI>();
        if (!remove.isEmpty()) {
            for (String project : remove) {
                unAssingRes.add(uri(project));
            }
            policyUnAssignment = true;
        }
        param.setUnassignfrom(unAssingRes);
    } else if (FilePolicyApplyLevel.vpool.name().equalsIgnoreCase(existingPolicy.getAppliedAt())) {
        List<String> vPools = Lists.newArrayList();
        if (assignPolicy.unassignedVirtualPools != null) {
            vPools = assignPolicy.unassignedVirtualPools;
        }
        List<String> remove = vPools;
        // removed vpools
        Set<URI> unAssingRes = new HashSet<URI>();
        if (!remove.isEmpty()) {
            for (String vpool : remove) {
                unAssingRes.add(uri(vpool));
            }
            policyUnAssignment = true;
        }
        param.setUnassignfrom(unAssingRes);
    }
    return policyUnAssignment;
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) List(java.util.List) ArrayList(java.util.ArrayList) URI(java.net.URI) HashSet(java.util.HashSet)

Example 5 with FilePolicyRestRep

use of com.emc.storageos.model.file.policy.FilePolicyRestRep in project coprhd-controller by CoprHD.

the class FileSystems method getScheculePolicies.

public static void getScheculePolicies() {
    ViPRCoreClient client = BourneUtil.getViprClient();
    List<NamedRelatedResourceRep> filePolicies = client.fileProtectionPolicies().listFilePolicies().getFilePolicies();
    List<StringOption> policyOptions = Lists.newArrayList();
    for (NamedRelatedResourceRep filePolicy : filePolicies) {
        FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(filePolicy.getId());
        if (policyRestRep != null && "file_system".equalsIgnoreCase(policyRestRep.getAppliedAt())) {
            policyOptions.add(new StringOption(policyRestRep.getId().toString(), filePolicy.getName()));
        }
    }
    renderJSON(policyOptions);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) StringOption(util.StringOption) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Aggregations

FilePolicyRestRep (com.emc.storageos.model.file.policy.FilePolicyRestRep)21 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)8 Asset (com.emc.sa.asset.annotation.Asset)6 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)6 AssetOption (com.emc.vipr.model.catalog.AssetOption)6 FlashException (controllers.util.FlashException)6 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)5 URI (java.net.URI)5 ArrayList (java.util.ArrayList)5 FileVirtualPoolRestRep (com.emc.storageos.model.vpool.FileVirtualPoolRestRep)3 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)2 HashSet (java.util.HashSet)2 List (java.util.List)2 Set (java.util.Set)2 DataObject (com.emc.storageos.db.client.model.DataObject)1 FilePolicyApplyLevel (com.emc.storageos.db.client.model.FilePolicy.FilePolicyApplyLevel)1 FileReplicationTopology (com.emc.storageos.db.client.model.FileReplicationTopology)1 StringSet (com.emc.storageos.db.client.model.StringSet)1 VirtualArray (com.emc.storageos.db.client.model.VirtualArray)1