use of com.emc.storageos.model.file.NfsACLs in project coprhd-controller by CoprHD.
the class NfsACLUtility method getNfsAclFromDB.
/**
* This function return all the ACL in the DB in the format of xml Object
*
* @param allDirs if true function will return complete list of ACL including its SubDir
* @return list of NFS ACLs.
*/
public NfsACLs getNfsAclFromDB(boolean allDirs) {
NfsACLs acls = new NfsACLs();
List<NfsACL> nfsAclList = new ArrayList<NfsACL>();
Map<String, List<NfsACE>> nfsAclMap = new HashMap<String, List<NfsACE>>();
_log.info("Sub-directory {} and allDirs {}", this.subDir, allDirs);
// Query All ACl Specific to a File System.
List<NFSShareACL> nfsAcls = queryDBSFileNfsACLs(allDirs);
_log.info("Number of existing ACL found : {} ", nfsAcls.size());
// Group the ACLs based on file system path!!!
for (NFSShareACL nfsAcl : nfsAcls) {
String fsPath = nfsAcl.getFileSystemPath();
List<NfsACE> nfsAceList = nfsAclMap.get(fsPath);
if (nfsAceList == null) {
nfsAceList = new ArrayList<NfsACE>();
}
NfsACE ace = getNFSAce(nfsAcl);
nfsAceList.add(ace);
nfsAclMap.put(fsPath, nfsAceList);
}
// Convert all ACE to ACLs!!
for (Map.Entry<String, List<NfsACE>> pathAcls : nfsAclMap.entrySet()) {
String mountPath = pathAcls.getKey();
NfsACL nfsAcl = new NfsACL(mountPath, pathAcls.getValue());
if (mountPath.length() > fs.getPath().length()) {
nfsAcl.setSubDir(mountPath.substring(fs.getPath().length() + 1));
}
nfsAclList.add(nfsAcl);
}
if (!nfsAclList.isEmpty()) {
acls.setNfsACLs(nfsAclList);
}
return acls;
}
use of com.emc.storageos.model.file.NfsACLs in project coprhd-controller by CoprHD.
the class FileSystems method getNfsACLs.
/**
* Gets the NFS ACLs for the given file system by ID.
* <p>
* API Call: <tt>GET /file/filesystems/{id}/acl?subDir=subDirId</tt>
*
* @param id
* the ID of the file system.
* @param subDir
* the subDir to get list of ACLS associated.
* @return the list of NFS ACLs for the given file system.
*/
public List<NfsACL> getNfsACLs(URI id, String subDir) {
Properties queryParam = new Properties();
NfsACLs response;
if (subDir != null && !"null".equals(subDir)) {
queryParam.setProperty("subDir", subDir);
response = client.get(NfsACLs.class, getNfsACLsUrl(), queryParam, id);
} else {
response = client.get(NfsACLs.class, getNfsACLsUrl(), id);
}
return defaultList(response.getNfsACLs());
}
use of com.emc.storageos.model.file.NfsACLs in project coprhd-controller by CoprHD.
the class FileSystems method getAllNfsACLs.
/**
* Gets the all NFS ACLs for the given file system by ID.
* <p>
* API Call: <tt>GET /file/filesystems/{id}/acl?allDir=true</tt>
*
* @param id
* the ID of the file system.
*
* @return the list of NFS ACLs for the given file system.
*/
public List<NfsACL> getAllNfsACLs(URI id) {
Properties queryParam = new Properties();
queryParam.setProperty("allDirs", "true");
NfsACLs response = client.get(NfsACLs.class, getNfsACLsUrl(), queryParam, id);
return defaultList(response.getNfsACLs());
}
use of com.emc.storageos.model.file.NfsACLs 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