use of com.emc.storageos.api.service.impl.resource.utils.NfsACLUtility in project coprhd-controller by CoprHD.
the class FileService method updateFileSystemAcls.
/**
* Update existing file system ACL
*
* @param id
* the URN of a ViPR fileSystem
* @param param
* FileNfsACLUpdateParams
* @brief Update file system ACL
* @return Task resource representation
* @throws InternalException
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/acl")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep updateFileSystemAcls(@PathParam("id") URI id, FileNfsACLUpdateParams param) throws InternalException {
// log input received.
_log.info("Update FS ACL : request received for {} with {}", id, param);
// Validate the FS id.
ArgValidator.checkFieldUriType(id, FileShare.class, "id");
FileShare fs = queryResource(id);
ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
// Check for VirtualPool whether it has NFS v4 enabled
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, fs.getVirtualPool());
if (!vpool.getProtocols().contains(StorageProtocol.File.NFSv4.name())) {
// Throw an error
throw APIException.methodNotAllowed.vPoolDoesntSupportProtocol("Vpool does not support " + StorageProtocol.File.NFSv4.name() + " protocol");
}
StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
FileController controller = getController(FileController.class, device.getSystemType());
String task = UUID.randomUUID().toString();
String path = fs.getPath();
_log.info("fileSystem path {} ", path);
Operation op = new Operation();
try {
_log.info("Sub Dir Provided {}", param.getSubDir());
// Validate the input
NfsACLUtility util = new NfsACLUtility(_dbClient, fs, null, param.getSubDir());
util.verifyNfsACLs(param);
_log.info("No Errors found proceeding further {}, {}, {}", new Object[] { _dbClient, fs, param });
op = _dbClient.createTaskOpStatus(FileShare.class, fs.getId(), task, ResourceOperationTypeEnum.UPDATE_FILE_SYSTEM_NFS_ACL);
op.setDescription("Filesystem NFS ACL update");
controller.updateNFSAcl(device.getId(), fs.getId(), param, task);
auditOp(OperationTypeEnum.UPDATE_FILE_SYSTEM_NFS_ACL, true, AuditLogManager.AUDITOP_BEGIN, fs.getId().toString(), device.getId().toString(), param);
} catch (BadRequestException e) {
op = _dbClient.error(FileShare.class, fs.getId(), task, e);
_log.error("Error Processing File System ACL Updates {}, {}", e.getMessage(), e);
throw e;
} catch (Exception e) {
_log.error("Error Processing File System ACL Updates {}, {}", e.getMessage(), e);
throw APIException.badRequests.unableToProcessRequest(e.getMessage());
}
return toTask(fs, task, op);
}
use of com.emc.storageos.api.service.impl.resource.utils.NfsACLUtility in project coprhd-controller by CoprHD.
the class FileService method getFileShareACLs.
/**
* GET all ACLs for a fileSystem
*
* @param id
* the URN of a ViPR fileSystem
* @param allDirs
* all directory within a fileSystem
* @param subDir
* sub-directory within a fileSystem
* @brief List the ACLs for a file system
* @return list of ACLs for file system.
* @throws InternalException
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/acl")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public NfsACLs getFileShareACLs(@PathParam("id") URI id, @QueryParam("allDirs") boolean allDirs, @QueryParam("subDir") String subDir) {
_log.info("Request recieved for Acl with Id : {} allDirs : {} subDir : {}", new Object[] { id, allDirs, subDir });
// Validate the FS id.
ArgValidator.checkFieldUriType(id, FileShare.class, "id");
FileShare fs = queryResource(id);
// Check for VirtualPool whether it has NFS v4 enabled
VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, fs.getVirtualPool());
if (!vpool.getProtocols().contains(StorageProtocol.File.NFSv4.name())) {
// Throw an error
throw APIException.methodNotAllowed.vPoolDoesntSupportProtocol("Vpool does not support " + StorageProtocol.File.NFSv4.name() + " protocol");
}
// Get All ACLs of FS from data base and group them based on path!!
NfsACLUtility util = new NfsACLUtility(_dbClient, fs, null, subDir);
NfsACLs acls = util.getNfsAclFromDB(allDirs);
if (acls.getNfsACLs() != null && !acls.getNfsACLs().isEmpty()) {
_log.info("Found {} Acl rules for filesystem {}", acls.getNfsACLs().size(), fs.getId());
} else {
_log.info("No Acl rules found for filesystem {}", fs.getId());
}
return acls;
}
Aggregations