use of com.emc.storageos.computesystemorchestrationcontroller.ComputeSystemOrchestrationController in project coprhd-controller by CoprHD.
the class FileService method mountExport.
/**
* Perform a mount operation for a file system
* <p>
* NOTE: This is an asynchronous operation.
*
* @param id
* the URN of a ViPR File system
* @param param
* File system mount parameters
* @brief Mount a file system
* @return Task resource representation
* @throws InternalException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/mount")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep mountExport(@PathParam("id") URI id, FileSystemMountParam param) throws InternalException {
_log.info("FileService::mount Request recieved {}", id);
String task = UUID.randomUUID().toString();
ArgValidator.checkFieldUriType(id, FileShare.class, "id");
// Get the FileSystem object from the URN
FileShare fs = queryResource(id);
ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
// validations
if (!isSubDirValid(fs, param.getSubDir())) {
throw APIException.badRequests.invalidParameter("sub_directory", param.getSubDir());
}
if (!isFSTypeValid(param)) {
throw APIException.badRequests.invalidParameter("fs_type", param.getFsType());
}
if (!isSecurityValid(fs, param)) {
throw APIException.badRequests.invalidParameter("security", param.getSecurity());
}
fs.setOpStatus(new OpStatusMap());
Operation op = new Operation();
op.setResourceType(ResourceOperationTypeEnum.MOUNT_NFS_EXPORT);
fs.getOpStatus().createTaskStatus(task, op);
_dbClient.updateObject(fs);
// Now get ready to make calls into the controller
ComputeSystemOrchestrationController controller = getController(ComputeSystemOrchestrationController.class, null);
try {
controller.mountDevice(param.getHost(), id, param.getSubDir(), param.getSecurity(), param.getPath(), param.getFsType(), task);
} catch (Exception e) {
// should discriminate between validation problems vs. internal errors
throw e;
}
auditOp(OperationTypeEnum.MOUNT_NFS_EXPORT, true, AuditLogManager.AUDITOP_BEGIN, fs.getName(), fs.getId().toString(), param.getHost().toString(), param.getSubDir(), param.getPath());
fs = _dbClient.queryObject(FileShare.class, id);
_log.debug("FileService::Mount Before sending response, FS ID : {}, Taks : {} ; Status {}", fs.getOpStatus().get(task), fs.getOpStatus().get(task).getStatus());
return toTask(fs, task, op);
}
use of com.emc.storageos.computesystemorchestrationcontroller.ComputeSystemOrchestrationController in project coprhd-controller by CoprHD.
the class FileService method unmountExport.
/**
* unmount an exported filesystem
* <p>
* NOTE: This is an asynchronous operation.
*
* @param id
* the URN of the fs
* @param param
* FileSystemUnmountParam
* @brief Unmount a file system
* @return Task resource representation
* @throws com.emc.storageos.svcs.errorhandling.resources.InternalException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/unmount")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep unmountExport(@PathParam("id") URI id, FileSystemUnmountParam param) throws InternalException {
FileShare fs = queryResource(id);
ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
// validations
if (!isMountPathValid(param.getHostId(), param.getMountPath())) {
throw APIException.badRequests.invalidParameter("mount_path", param.getMountPath());
}
_log.info("FileService::unmount export Request recieved {}", id);
String task = UUID.randomUUID().toString();
Operation op = new Operation();
op.setResourceType(ResourceOperationTypeEnum.UNMOUNT_NFS_EXPORT);
fs.setOpStatus(new OpStatusMap());
fs.getOpStatus().createTaskStatus(task, op);
_dbClient.updateObject(fs);
// Now get ready to make calls into the controller
ComputeSystemOrchestrationController controller = getController(ComputeSystemOrchestrationController.class, null);
try {
controller.unmountDevice(param.getHostId(), id, param.getMountPath(), task);
} catch (InternalException e) {
throw e;
}
auditOp(OperationTypeEnum.UNMOUNT_NFS_EXPORT, true, AuditLogManager.AUDITOP_BEGIN, param.getHostId(), param.getMountPath());
fs = _dbClient.queryObject(FileShare.class, fs.getId());
_log.debug("FileService::unmount Before sending response, FS ID : {}, Task : {} ; Status {}", fs.getOpStatus().get(task), fs.getOpStatus().get(task).getStatus());
return toTask(fs, task, op);
}
Aggregations