Search in sources :

Example 51 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class FileSystems method fileSystemSnapshotPolicies.

@FlashException(referrer = { "fileSystem" })
public static void fileSystemSnapshotPolicies(String fileSystemId) {
    ViPRCoreClient client = BourneUtil.getViprClient();
    List<FilePolicyRestRep> filePolicies = Lists.newArrayList();
    FileShareRestRep fs = client.fileSystems().get(uri(fileSystemId));
    if (fs != null) {
        // Get file system snapshot policies!!
        if (fs.getFilePolicies() != null && !fs.getFilePolicies().isEmpty()) {
            for (String uriPolicy : fs.getFilePolicies()) {
                FilePolicyRestRep policyRestRep = client.fileProtectionPolicies().get(uri(uriPolicy));
                if (policyRestRep != null) {
                    filePolicies.add(policyRestRep);
                }
            }
        }
    }
    render(filePolicies);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) FilePolicyRestRep(com.emc.storageos.model.file.policy.FilePolicyRestRep) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep) FlashException(controllers.util.FlashException)

Example 52 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class FileSystems method listAclJson.

/**
 * This method called during population of Datatable for ACL data.
 *
 * @param aclURL
 *            URL of the file system share.
 */
public static void listAclJson(String aclURL) {
    String fileSystem = null;
    String shareName = null;
    if (StringUtils.isNotBlank(aclURL)) {
        String[] parts = aclURL.split("/");
        if (parts.length == 7) {
            fileSystem = parts[3];
            shareName = parts[5];
        }
    }
    ViPRCoreClient client = BourneUtil.getViprClient();
    List<ShareACL> shareAcls = client.fileSystems().getShareACLs(uri(fileSystem), shareName);
    List<ShareACLDataTable.AclInfo> acl = Lists.newArrayList();
    for (ShareACL shareAcl : shareAcls) {
        String userOrGroup = shareAcl.getUser();
        String type = "User";
        if (shareAcl.getGroup() != null && shareAcl.getGroup() != "") {
            type = "Group";
            userOrGroup = shareAcl.getGroup();
        }
        acl.add(new ShareACLDataTable.AclInfo(userOrGroup, type, shareAcl.getPermission(), fileSystem, shareName, shareAcl.getDomain()));
    }
    renderJSON(DataTablesSupport.createJSON(acl, params));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ShareACL(com.emc.storageos.model.file.ShareACL) ShareACLDataTable(models.datatable.ShareACLDataTable)

Example 53 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class FileSystems method save.

@FlashException(referrer = { "fileSystem" })
public static void save(Boolean edit, String id, String fsPath, String exportPath, String security, String anon, String subDir, @As(",") List<String> ro, @As(",") List<String> rw, @As(",") List<String> root, Boolean bypassDnsCheck) {
    ExportRule rule = new ExportRule();
    rule.setFsID(uri(id));
    rule.setMountPoint(fsPath);
    rule.setExportPath(exportPath);
    rule.setAnon(anon);
    rule.setSecFlavor(security);
    // Clean up endpoints list by removing all empty items
    List<String> empty = Arrays.asList("");
    rw.removeAll(empty);
    ro.removeAll(empty);
    root.removeAll(empty);
    if (!ro.isEmpty()) {
        rule.setReadOnlyHosts(FileUtils.buildEndpointList(ro));
    }
    if (!rw.isEmpty()) {
        rule.setReadWriteHosts(FileUtils.buildEndpointList(rw));
    }
    if (!root.isEmpty()) {
        rule.setRootHosts(FileUtils.buildEndpointList(root));
    }
    List<ExportRule> addRules = Lists.newArrayList();
    addRules.add(rule);
    ExportRules exportRules = new ExportRules();
    exportRules.setExportRules(addRules);
    FileShareExportUpdateParams params = new FileShareExportUpdateParams();
    params.setBypassDnsCheck(bypassDnsCheck);
    if (!edit) {
        params.setExportRulesToAdd(exportRules);
    } else {
        params.setExportRulesToModify(exportRules);
        subDir = FileUtils.findSubDirectory(fsPath, exportPath);
    }
    ViPRCoreClient client = BourneUtil.getViprClient();
    client.fileSystems().updateExport(uri(id), subDir, params);
    flash.put("info", MessagesUtils.get("resources.filesystem.export.update"));
    fileSystem(id);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ExportRules(com.emc.storageos.model.file.ExportRules) FileShareExportUpdateParams(com.emc.storageos.model.file.FileShareExportUpdateParams) ExportRule(com.emc.storageos.model.file.ExportRule) FlashException(controllers.util.FlashException)

Example 54 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class FileSystems method listNfsAcl.

public static void listNfsAcl(String fileSystemId, String fsMountPath, String subDir) {
    renderArgs.put("dataTable", new NfsACLDataTable());
    renderArgs.put("subDir", subDir);
    renderArgs.put("fileSystemId", uri(fileSystemId));
    renderArgs.put("fsMountPath", fsMountPath);
    renderArgs.put("fileSystemSubDirAndPath", fileSystemId + "~~~" + subDir + "~~~" + fsMountPath);
    renderArgs.put("permissionOptions", StringOption.options(new String[] { "read", "write", "execute", "fullControl" }));
    ViPRCoreClient client = BourneUtil.getViprClient();
    NfsACLForm nfsACL = new NfsACLForm();
    FileShareRestRep restRep = client.fileSystems().get(uri(fileSystemId));
    renderArgs.put("fileSystemName", restRep.getName());
    render(nfsACL);
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NfsACLDataTable(models.datatable.NfsACLDataTable) FileShareRestRep(com.emc.storageos.model.file.FileShareRestRep)

Example 55 with ViPRCoreClient

use of com.emc.vipr.client.ViPRCoreClient in project coprhd-controller by CoprHD.

the class FileSystems method listNfsAclJson.

public static void listNfsAclJson(String fileSystemSubDirAndPath) {
    renderArgs.put("dataTable", new NfsACLDataTable());
    String fileSystemId = null;
    String subDir = null;
    String fsMountPath = null;
    if (StringUtils.isNotBlank(fileSystemSubDirAndPath)) {
        String[] parts = fileSystemSubDirAndPath.split("~~~");
        if (parts.length == 3) {
            fileSystemId = parts[0];
            subDir = parts[1];
            fsMountPath = parts[2];
        }
    }
    renderArgs.put("subDir", subDir);
    renderArgs.put("fsMountPath", fsMountPath);
    renderArgs.put("fileSystemId", uri(fileSystemId));
    renderArgs.put("fileSystemName", uri(fileSystemId));
    ViPRCoreClient client = BourneUtil.getViprClient();
    List<NfsACL> nfsAcls = client.fileSystems().getNfsACLs(uri(fileSystemId), subDir);
    NfsACL nfsAcl = new NfsACL();
    List<NfsACLDataTable.NfsAclInfo> nfsAccessControlList = Lists.newArrayList();
    if (nfsAcls.size() > 0) {
        nfsAcl = nfsAcls.get(0);
        List<NfsACE> acl = nfsAcl.getNfsAces();
        for (NfsACE ace : acl) {
            String name = ace.getUser();
            String type = ace.getType();
            String permissions = ace.getPermissions();
            String domain = ace.getDomain();
            String permissionType = ace.getPermissionType();
            nfsAccessControlList.add(new NfsACLDataTable.NfsAclInfo(name, type, permissions, fileSystemId, subDir, domain, fsMountPath, permissionType));
        }
    }
    renderJSON(DataTablesSupport.createJSON(nfsAccessControlList, params));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NfsACL(com.emc.storageos.model.file.NfsACL) NfsACE(com.emc.storageos.model.file.NfsACE) NfsACLDataTable(models.datatable.NfsACLDataTable)

Aggregations

ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)225 Asset (com.emc.sa.asset.annotation.Asset)72 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)66 URI (java.net.URI)66 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)49 FlashException (controllers.util.FlashException)48 AssetOption (com.emc.vipr.model.catalog.AssetOption)41 ArrayList (java.util.ArrayList)34 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)29 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)27 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)24 BlockSnapshotRestRep (com.emc.storageos.model.block.BlockSnapshotRestRep)20 BlockConsistencyGroupRestRep (com.emc.storageos.model.block.BlockConsistencyGroupRestRep)15 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)15 StoragePortGroupRestRepList (com.emc.storageos.model.portgroup.StoragePortGroupRestRepList)13 HashSet (java.util.HashSet)13 Task (com.emc.vipr.client.Task)11 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)10 ViPRHttpException (com.emc.vipr.client.exceptions.ViPRHttpException)10 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)8