Search in sources :

Example 1 with ComputeSystemOrchestrationController

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);
}
Also used : ComputeSystemOrchestrationController(com.emc.storageos.computesystemorchestrationcontroller.ComputeSystemOrchestrationController) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with ComputeSystemOrchestrationController

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);
}
Also used : ComputeSystemOrchestrationController(com.emc.storageos.computesystemorchestrationcontroller.ComputeSystemOrchestrationController) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)2 ComputeSystemOrchestrationController (com.emc.storageos.computesystemorchestrationcontroller.ComputeSystemOrchestrationController)2 FileShare (com.emc.storageos.db.client.model.FileShare)2 OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)2 Operation (com.emc.storageos.db.client.model.Operation)2 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)2 Consumes (javax.ws.rs.Consumes)2 POST (javax.ws.rs.POST)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)1 BadRequestException (com.emc.storageos.svcs.errorhandling.resources.BadRequestException)1 ControllerException (com.emc.storageos.volumecontroller.ControllerException)1 URISyntaxException (java.net.URISyntaxException)1