Search in sources :

Example 6 with FileSystemExportParam

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

the class FileProvider method getFileExportsWithRootPermissions.

@Asset("fileExportsWithRootPermissions")
@AssetDependencies("fileUnmountedFilesystem")
public List<AssetOption> getFileExportsWithRootPermissions(AssetOptionsContext ctx, URI fileFilesystem) {
    List<AssetOption> options = Lists.newArrayList();
    for (FileSystemExportParam export : listFileExports(ctx, fileFilesystem)) {
        if (export.getPermissions().equalsIgnoreCase("root")) {
            options.add(new AssetOption(export.getMountPoint(), export.getMountPoint()));
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : FileSystemExportParam(com.emc.storageos.model.file.FileSystemExportParam) AssetOption(com.emc.vipr.model.catalog.AssetOption) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 7 with FileSystemExportParam

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

the class FileProvider method getCIFSFileExports.

@Asset("fileExports")
@AssetDependencies("fileCIFSFilesystem")
public List<AssetOption> getCIFSFileExports(AssetOptionsContext ctx, URI fileFilesystem) {
    List<AssetOption> options = Lists.newArrayList();
    for (FileSystemExportParam export : listFileExports(ctx, fileFilesystem)) {
        options.add(new AssetOption(export.getMountPoint(), export.getMountPoint()));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : FileSystemExportParam(com.emc.storageos.model.file.FileSystemExportParam) AssetOption(com.emc.vipr.model.catalog.AssetOption) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 8 with FileSystemExportParam

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

the class FileProvider method getFileExports.

@Asset("fileExports")
@AssetDependencies("fileFilesystem")
public List<AssetOption> getFileExports(AssetOptionsContext ctx, URI fileFilesystem) {
    List<AssetOption> options = Lists.newArrayList();
    for (FileSystemExportParam export : listFileExports(ctx, fileFilesystem)) {
        options.add(new AssetOption(export.getMountPoint(), export.getMountPoint()));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : FileSystemExportParam(com.emc.storageos.model.file.FileSystemExportParam) AssetOption(com.emc.vipr.model.catalog.AssetOption) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 9 with FileSystemExportParam

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

the class InternalApiTest method testInternalFileService.

@Test
public /**
 * This test exercises only the server side functionaly, not the internal client
 * @throws Exception
 */
void testInternalFileService() throws Exception {
    // create fs
    FileSystemParam fsparam = new FileSystemParam();
    fsparam.setVpool(_cosId);
    fsparam.setLabel("test-internalapi-" + System.currentTimeMillis());
    fsparam.setVarray(_nhId);
    fsparam.setSize("20971520");
    URI path = URI.create(_apiServer).resolve("/internal/file/filesystems");
    WebResource rRoot = _client.resource(path);
    WebResource.Builder rBuilder = _requestHelper.addSignature(rRoot);
    TaskResourceRep resp = _requestHelper.addToken(rBuilder, _rootToken).post(TaskResourceRep.class, fsparam);
    Assert.assertTrue(resp != null);
    Assert.assertNotNull(resp.getOpId());
    Assert.assertNotNull(resp.getResource());
    String fsId = resp.getResource().getId().toString();
    String opId = resp.getOpId();
    // GET filesystem
    path = URI.create(_apiServer).resolve("/internal/file/filesystems/" + fsId);
    rRoot = _client.resource(path);
    rBuilder = _requestHelper.addSignature(rRoot);
    ClientResponse response = _requestHelper.addToken(rBuilder, _rootToken).get(ClientResponse.class);
    Assert.assertTrue(response != null);
    Assert.assertEquals(200, response.getStatus());
    // wait for the create to finish
    path = URI.create(_apiServer).resolve("/internal/file/filesystems/" + fsId + "/tasks/" + opId);
    int checkCount = 1200;
    String status;
    do {
        // wait upto ~2 minute for fs creation
        Thread.sleep(100);
        rRoot = _client.resource(path);
        TaskResourceRep fsResp = _requestHelper.addSignature(rRoot).get(TaskResourceRep.class);
        status = fsResp.getState();
    } while (status.equals("pending") && checkCount-- > 0);
    if (!status.equals("ready")) {
        Assert.assertTrue("Fileshare create timed out", false);
    }
    // export
    path = URI.create(_apiServer).resolve("/internal/file/filesystems/" + fsId + "/exports");
    FileSystemExportParam export = new FileSystemExportParam();
    export.setPermissions("root");
    export.setRootUserMapping("root");
    export.setProtocol("NFS");
    export.setEndpoints(new ArrayList<String>());
    export.getEndpoints().add("www.ford.com");
    rRoot = _client.resource(path);
    rBuilder = _requestHelper.addSignature(rRoot);
    resp = _requestHelper.addToken(rBuilder, _rootToken).post(TaskResourceRep.class, export);
    opId = resp.getOpId();
    // wait for the export to finish
    path = URI.create(_apiServer).resolve("/internal/file/filesystems/" + fsId + "/tasks/" + opId);
    do {
        // wait upto ~2 minute for fs creation
        Thread.sleep(100);
        rRoot = _client.resource(path);
        TaskResourceRep fsResp = _requestHelper.addSignature(rRoot).get(TaskResourceRep.class);
        status = fsResp.getState();
    } while (status.equals("pending") && checkCount-- > 0);
    if (!status.equals("ready")) {
        Assert.assertTrue("Fileshare export timed out", false);
    }
    // unexport
    String unexportPath = String.format("/internal/file/filesystems/%s/exports/%s,%s,%s,%s", fsId, export.getProtocol(), export.getSecurityType(), export.getPermissions(), export.getRootUserMapping());
    path = URI.create(_apiServer).resolve(unexportPath);
    rRoot = _client.resource(path);
    rBuilder = _requestHelper.addSignature(rRoot);
    resp = _requestHelper.addToken(rBuilder, _rootToken).delete(TaskResourceRep.class, export);
    opId = resp.getOpId();
    // wait for the unexport to finish
    path = URI.create(_apiServer).resolve("/internal/file/filesystems/" + fsId + "/tasks/" + opId);
    do {
        // wait upto ~2 minute for fs creation
        Thread.sleep(100);
        rRoot = _client.resource(path);
        TaskResourceRep fsResp = _requestHelper.addSignature(rRoot).get(TaskResourceRep.class);
        status = fsResp.getState();
    } while (status.equals("pending") && checkCount-- > 0);
    if (!status.equals("ready")) {
        Assert.assertTrue("Fileshare unexport timed out", false);
    }
    // delete
    path = URI.create(_apiServer).resolve("/internal/file/filesystems/" + fsId + "/deactivate");
    FileSystemDeleteParam deleteParam = new FileSystemDeleteParam();
    deleteParam.setForceDelete(false);
    rRoot = _client.resource(path);
    rBuilder = _requestHelper.addSignature(rRoot);
    resp = _requestHelper.addToken(rBuilder, _rootToken).post(TaskResourceRep.class, deleteParam);
    Assert.assertTrue(resp != null);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) FileSystemExportParam(com.emc.storageos.model.file.FileSystemExportParam) FileSystemParam(com.emc.storageos.model.file.FileSystemParam) WebResource(com.sun.jersey.api.client.WebResource) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) FileSystemDeleteParam(com.emc.storageos.model.file.FileSystemDeleteParam) URI(java.net.URI) Test(org.junit.Test)

Example 10 with FileSystemExportParam

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

the class InternalApiTest method testFileServiceUsingInternalClient.

@Test
public /**
 * This test exercises both server side and internal client
 * @throws Exception
 */
void testFileServiceUsingInternalClient() throws Exception {
    // create fs
    FileSystemParam fsparam = new FileSystemParam();
    fsparam.setVpool(_cosId);
    fsparam.setLabel("test-internalapi-" + System.currentTimeMillis());
    fsparam.setVarray(_nhId);
    fsparam.setSize("20971520");
    TaskResourceRep resp = _internalFileClient.createFileSystem(fsparam, _rootToken);
    Assert.assertTrue(resp != null);
    Assert.assertNotNull(resp.getOpId());
    Assert.assertNotNull(resp.getResource());
    URI fsId = resp.getResource().getId();
    String opId = resp.getOpId();
    // GET filesystem - no method on the client for this?
    WebResource rRoot = _requestHelper.createRequest(_client, _apiServer, "/internal/file/filesystems/" + fsId);
    WebResource.Builder rBuilder = _requestHelper.addSignature(rRoot);
    ClientResponse response = _requestHelper.addToken(rBuilder, _rootToken).get(ClientResponse.class);
    Assert.assertTrue(response != null);
    Assert.assertEquals(200, response.getStatus());
    // wait for the create to finish
    int checkCount = 1200;
    String status;
    do {
        // wait upto ~2 minute for fs creation
        Thread.sleep(100);
        TaskResourceRep fsResp = _internalFileClient.getTaskStatus(fsId, opId);
        status = fsResp.getState();
    } while (status.equals("pending") && checkCount-- > 0);
    if (!status.equals("ready")) {
        Assert.assertTrue("Fileshare create timed out", false);
    }
    // export
    FileSystemExportParam export = new FileSystemExportParam();
    export.setPermissions("root");
    export.setRootUserMapping("root");
    export.setProtocol("NFS");
    export.setEndpoints(new ArrayList<String>());
    export.getEndpoints().add("www.ford.com");
    resp = _internalFileClient.exportFileSystem(fsId, export);
    opId = resp.getOpId();
    // wait for the export to finish
    do {
        // wait upto ~2 minute for fs creation
        Thread.sleep(100);
        TaskResourceRep fsResp = _internalFileClient.getTaskStatus(fsId, opId);
        status = fsResp.getState();
    } while (status.equals("pending") && checkCount-- > 0);
    if (!status.equals("ready")) {
        Assert.assertTrue("Fileshare export timed out", false);
    }
    // unexport
    resp = _internalFileClient.unexportFileSystem(fsId, export.getProtocol(), export.getSecurityType(), export.getPermissions(), export.getRootUserMapping(), null);
    opId = resp.getOpId();
    // wait for the unexport to finish
    do {
        // wait upto ~2 minute for fs creation
        Thread.sleep(100);
        TaskResourceRep fsResp = _internalFileClient.getTaskStatus(fsId, opId);
        status = fsResp.getState();
    } while (status.equals("pending") && checkCount-- > 0);
    if (!status.equals("ready")) {
        Assert.assertTrue("Fileshare unexport timed out", false);
    }
    // delete
    FileSystemDeleteParam deleteParam = new FileSystemDeleteParam();
    deleteParam.setForceDelete(false);
    resp = _internalFileClient.deactivateFileSystem(fsId, _rootToken, deleteParam);
    Assert.assertTrue(resp != null);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) FileSystemExportParam(com.emc.storageos.model.file.FileSystemExportParam) FileSystemParam(com.emc.storageos.model.file.FileSystemParam) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) WebResource(com.sun.jersey.api.client.WebResource) FileSystemDeleteParam(com.emc.storageos.model.file.FileSystemDeleteParam) URI(java.net.URI) Test(org.junit.Test)

Aggregations

FileSystemExportParam (com.emc.storageos.model.file.FileSystemExportParam)13 Asset (com.emc.sa.asset.annotation.Asset)4 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)4 AssetOption (com.emc.vipr.model.catalog.AssetOption)4 URI (java.net.URI)4 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)2 FileExport (com.emc.storageos.db.client.model.FileExport)2 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)2 FileSystemDeleteParam (com.emc.storageos.model.file.FileSystemDeleteParam)2 FileSystemExportList (com.emc.storageos.model.file.FileSystemExportList)2 FileSystemParam (com.emc.storageos.model.file.FileSystemParam)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 ClientResponse (com.sun.jersey.api.client.ClientResponse)2 WebResource (com.sun.jersey.api.client.WebResource)2 ArrayList (java.util.ArrayList)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 Test (org.junit.Test)2 GetNfsExportsForFileSystem (com.emc.sa.service.vipr.file.tasks.GetNfsExportsForFileSystem)1