Search in sources :

Example 11 with FilePolicyRestRep

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

the class FileProvider method getFilePolicies.

@Asset("fileFilePolicy")
@AssetDependencies({ "project", "fileFilesystemAssociation" })
public List<AssetOption> getFilePolicies(AssetOptionsContext ctx, URI project, URI fsId) {
    ViPRCoreClient client = api(ctx);
    List<AssetOption> options = Lists.newArrayList();
    for (FilePolicyRestRep policyRestRep : getAllFileSystemLevelPolicies(ctx)) {
        options.add(new AssetOption(policyRestRep.getId(), policyRestRep.getName()));
    }
    if (options != null && !options.isEmpty()) {
        AssetOptionsUtils.sortOptionsByLabel(options);
    }
    return options;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) AssetOption(com.emc.vipr.model.catalog.AssetOption) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 12 with FilePolicyRestRep

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

the class FileProvider method getAllFileSystemLevelPolicies.

private List<FilePolicyRestRep> getAllFileSystemLevelPolicies(AssetOptionsContext ctx) {
    ViPRCoreClient client = api(ctx);
    List<FilePolicyRestRep> fileSystemPolicies = new ArrayList<FilePolicyRestRep>();
    FilePolicyListRestRep policies = client.fileProtectionPolicies().listFilePolicies();
    if (policies != null && !policies.getFilePolicies().isEmpty()) {
        for (NamedRelatedResourceRep policy : policies.getFilePolicies()) {
            FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(policy.getId());
            if (policyRestRep != null && policyRestRep.getAppliedAt() != null && policyRestRep.getAppliedAt().equalsIgnoreCase("file_system")) {
                fileSystemPolicies.add(policyRestRep);
            }
        }
    }
    return fileSystemPolicies;
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) ArrayList(java.util.ArrayList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) FilePolicyListRestRep(com.emc.storageos.model.file.policy.FilePolicyListRestRep)

Example 13 with FilePolicyRestRep

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

the class VirtualArrayProvider method getFileTargetVirtualArrays.

@Asset("fileTargetVirtualArray")
@AssetDependencies({ "fileFilePolicy", "fileFilesystemAssociation" })
public List<AssetOption> getFileTargetVirtualArrays(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 14 with FilePolicyRestRep

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

the class FileProtectionPolicies method saveAssignPolicy.

@FlashException(keep = true, referrer = { "assign" })
public static void saveAssignPolicy(AssignPolicyForm assignPolicy) {
    if (assignPolicy == null) {
        Logger.error("No assign policy parameters passed");
        badRequest("No assign policy parameters passed");
        return;
    }
    assignPolicy.validate("assignPolicy");
    if (Validation.hasErrors()) {
        Common.handleError();
    }
    assignPolicy.id = params.get("id");
    FilePolicyRestRep policy = getViprClient().fileProtectionPolicies().getFilePolicy(uri(assignPolicy.id));
    if (policy.getAppliedAt().equalsIgnoreCase(FilePolicyApplyLevel.file_system.name())) {
        list();
    }
    FilePolicyAssignParam assignPolicyParam = new FilePolicyAssignParam();
    if (assignPolicy.topologiesString == null || assignPolicy.topologiesString.equalsIgnoreCase("[]")) {
        if (policy.getReplicationSettings() != null && policy.getReplicationSettings().getType().equalsIgnoreCase(FileReplicationType.REMOTE.name())) {
            flash.error("No source and target varry parameters passed", policy.getName());
            if (StringUtils.isNotBlank(assignPolicy.referrerUrl)) {
                redirect(assignPolicy.referrerUrl);
            } else {
                list();
            }
        }
    }
    try {
        updateAssignPolicyParam(assignPolicy, assignPolicyParam);
        TaskResourceRep taskRes = getViprClient().fileProtectionPolicies().assignPolicy(uri(assignPolicy.id), assignPolicyParam);
        if (isTaskSuccessful(assignPolicy.id, taskRes)) {
            flash.success(MessagesUtils.get("assignPolicy.request.saved", assignPolicy.policyName));
        }
    } catch (Exception ex) {
        flash.error(ex.getMessage(), assignPolicy.policyName);
    }
    if (StringUtils.isNotBlank(assignPolicy.referrerUrl)) {
        redirect(assignPolicy.referrerUrl);
    } else {
        list();
    }
}
Also used : FilePolicyAssignParam(com.emc.storageos.model.file.policy.FilePolicyAssignParam) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) FlashException(controllers.util.FlashException) FlashException(controllers.util.FlashException)

Example 15 with FilePolicyRestRep

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

the class FileProtectionPolicies method details.

public static void details(String id) {
    FilePolicyRestRep filePolicyRestRep = getViprClient().fileProtectionPolicies().get(uri(id));
    if (filePolicyRestRep == null) {
        renderJSON("");
    }
    renderJSON(filePolicyRestRep);
}
Also used : FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep)

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