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