Search in sources :

Example 6 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 7 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 8 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 9 with FilePolicyRestRep

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

the class FileProvider method getFilesystemsWithPolicies.

@Asset("fileFilesystemWithPolicies")
@AssetDependencies("project")
public List<AssetOption> getFilesystemsWithPolicies(AssetOptionsContext ctx, URI project) {
    List<AssetOption> options = Lists.newArrayList();
    List<FilePolicyRestRep> fileSystemPolicies = getAllFileSystemLevelPolicies(ctx);
    List<FileShareRestRep> fileSystems = api(ctx).fileSystems().findByProject(project);
    for (FilePolicyRestRep policyRestRep : fileSystemPolicies) {
        if (policyRestRep.getAssignedResources() != null && !policyRestRep.getAssignedResources().isEmpty()) {
            for (FileShareRestRep fileSystem : fileSystems) {
                for (NamedRelatedResourceRep resource : policyRestRep.getAssignedResources()) {
                    if (resource.getId().equals(fileSystem.getId())) {
                        options.add(new AssetOption(fileSystem.getId(), fileSystem.getName()));
                        break;
                    }
                }
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 10 with FilePolicyRestRep

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

the class FileProvider method getFileSystemPolicies.

@Asset("fileSystemPolicies")
@AssetDependencies("fileFilesystemWithPolicies")
public List<AssetOption> getFileSystemPolicies(AssetOptionsContext ctx, URI fsId) {
    List<AssetOption> options = Lists.newArrayList();
    List<FilePolicyRestRep> fileSystemPolicies = getAllFileSystemLevelPolicies(ctx);
    for (FilePolicyRestRep policyRestRep : fileSystemPolicies) {
        // workaround to display policy name in oder receipt: if fsId is null then list all the policy
        if (fsId == null) {
            options.add(new AssetOption(policyRestRep.getId(), policyRestRep.getName()));
        } else if (policyRestRep.getAssignedResources() != null && !policyRestRep.getAssignedResources().isEmpty()) {
            for (NamedRelatedResourceRep resource : policyRestRep.getAssignedResources()) {
                if (resource.getId().equals(fsId)) {
                    options.add(new AssetOption(policyRestRep.getId(), policyRestRep.getName()));
                }
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : AssetOption(com.emc.vipr.model.catalog.AssetOption) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

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