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);
}
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);
}
Aggregations