Search in sources :

Example 6 with FileSystemParam

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

Example 7 with FileSystemParam

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

the class CreateFileSystem method doExecute.

@Override
protected Task<FileShareRestRep> doExecute() throws Exception {
    FileSystemParam input = new FileSystemParam();
    input.setLabel(label);
    input.setSize(String.valueOf(DiskSizeConversionUtils.gbToBytes(sizeInGB)));
    input.setVpool(vpoolId);
    input.setVarray(varrayId);
    input.setNotificationLimit(advisoryLimit);
    input.setSoftLimit(softLimit);
    input.setSoftGrace(gracePeriod);
    return getClient().fileSystems().create(projectId, input);
}
Also used : FileSystemParam(com.emc.storageos.model.file.FileSystemParam)

Aggregations

FileSystemParam (com.emc.storageos.model.file.FileSystemParam)7 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)4 FileSystemDeleteParam (com.emc.storageos.model.file.FileSystemDeleteParam)3 URI (java.net.URI)3 Test (org.junit.Test)3 FileShare (com.emc.storageos.db.client.model.FileShare)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2 FileDescriptor (com.emc.storageos.fileorchestrationcontroller.FileDescriptor)2 FileOrchestrationController (com.emc.storageos.fileorchestrationcontroller.FileOrchestrationController)2 FileSystemExportParam (com.emc.storageos.model.file.FileSystemExportParam)2 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 WebResource (com.sun.jersey.api.client.WebResource)2 ArrayList (java.util.ArrayList)2 BulkIdParam (com.emc.storageos.model.BulkIdParam)1 FileShareBulkRep (com.emc.storageos.model.file.FileShareBulkRep)1 FileShareRestRep (com.emc.storageos.model.file.FileShareRestRep)1 ProjectElement (com.emc.storageos.model.project.ProjectElement)1 ProjectParam (com.emc.storageos.model.project.ProjectParam)1