use of com.emc.storageos.isilon.restapi.IsilonNFSACL in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method getIsilonAclFromNfsACE.
/**
* getIsilonAclFromNfsACE function will convert the nfsACE object to Isilon
* ACL object.
*
* @param nfsACE
* vipr ACE object.
* @return
*/
private Acl getIsilonAclFromNfsACE(NfsACE nfsACE) {
IsilonNFSACL isilonAcl = new IsilonNFSACL();
Acl acl = isilonAcl.new Acl();
ArrayList<String> inheritFlags = new ArrayList<String>();
// Set empty inherit flag for now TODO make it user configurable.
acl.setInherit_flags(inheritFlags);
acl.setAccessrights(getIsilonAccessList(nfsACE.getPermissionSet()));
acl.setOp("add");
acl.setAccesstype(nfsACE.getPermissionType());
String user = nfsACE.getUser();
String domain = nfsACE.getDomain();
if (domain != null && !domain.isEmpty()) {
user = domain + "\\" + user;
}
String sid = null;
if (nfsACE.getSid() != null && !nfsACE.getSid().isEmpty()) {
sid = nfsACE.getSid();
}
IsilonNFSACL.Persona trustee = isilonAcl.new Persona(nfsACE.getType(), sid, user);
acl.setTrustee(trustee);
return acl;
}
use of com.emc.storageos.isilon.restapi.IsilonNFSACL in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method updateNfsACLs.
@Override
public BiosCommandResult updateNfsACLs(StorageSystem storage, FileDeviceInputOutput args) {
try {
// read nameToSid flag from controller config.
Boolean sidEnable = customConfigHandler.getComputedCustomConfigBooleanValue(CustomConfigConstants.ISILON_USER_TO_SID_MAPPING_FOR_NFS_ENABLED, storage.getSystemType(), null);
// get sid mapping based on Controller config and it belong to VirtualNAS.
if (sidEnable && args.getvNAS() != null) {
updateSidInfoForNfsACE(args, storage);
}
IsilonNFSACL isilonAcl = new IsilonNFSACL();
ArrayList<Acl> aclCompleteList = new ArrayList<Acl>();
List<NfsACE> aceToAdd = args.getNfsAclsToAdd();
for (NfsACE nfsACE : aceToAdd) {
Acl acl = getIsilonAclFromNfsACE(nfsACE);
acl.setOp("add");
aclCompleteList.add(acl);
}
List<NfsACE> aceToModify = args.getNfsAclsToModify();
for (NfsACE nfsACE : aceToModify) {
Acl acl = getIsilonAclFromNfsACE(nfsACE);
acl.setOp("replace");
aclCompleteList.add(acl);
}
List<NfsACE> aceToDelete = args.getNfsAclsToDelete();
for (NfsACE nfsACE : aceToDelete) {
Acl acl = getIsilonAclFromNfsACE(nfsACE);
acl.setOp("delete");
aclCompleteList.add(acl);
}
isilonAcl.setAction("update");
isilonAcl.setAuthoritative("acl");
isilonAcl.setAcl(aclCompleteList);
String path = args.getFileSystemPath();
if (args.getSubDirectory() != null && !args.getSubDirectory().isEmpty()) {
path = path + "/" + args.getSubDirectory();
}
// Process new ACLs
IsilonApi isi = getIsilonDevice(storage);
_log.info("Calling Isilon API: modify NFS Acl for {}, acl {}", args.getFileSystemPath(), isilonAcl);
isi.modifyNFSACL(path, isilonAcl);
_log.info("End updateNfsACLs");
BiosCommandResult result = BiosCommandResult.createSuccessfulResult();
return result;
} catch (IsilonException e) {
_log.error("updateNfsACLs failed ", e);
return BiosCommandResult.createErrorResult(e);
} catch (Exception e) {
_log.error("updateNfsACLs failed ", e);
final ServiceCoded serviceCoded = DeviceControllerException.errors.jobFailedOpMsg(OperationTypeEnum.UPDATE_FILE_SYSTEM_NFS_ACL.toString(), e.getMessage());
return BiosCommandResult.createErrorResult(serviceCoded);
}
}
use of com.emc.storageos.isilon.restapi.IsilonNFSACL in project coprhd-controller by CoprHD.
the class IsilonCommunicationInterface method setUnmanagedNfsShareACL.
/**
* get UnManaged NFS Shares and their ACLs
*
* @param unManagedFileSystem
* @param unManagedNfsACLList
* @param storagePort
* @param fs
* @param isilonApi
*/
private void setUnmanagedNfsShareACL(UnManagedFileSystem unManagedFileSystem, StorageSystem storageSystem, IsilonApi isilonApi, Set<String> fsExportPaths, List<UnManagedNFSShareACL> unManagedNfsACLList, List<UnManagedNFSShareACL> oldunManagedNfsShareACLList) {
UnManagedNFSShareACL existingNfsACL;
for (String exportPath : fsExportPaths) {
_log.info("getUnmanagedNfsShareACL for UnManagedFileSystem file path{} - start", exportPath);
if (exportPath == null || exportPath.isEmpty()) {
_log.info("Export path is empty");
continue;
}
try {
IsilonNFSACL isilonNFSAcl = isilonApi.getNFSACL(exportPath);
for (IsilonNFSACL.Acl tempAcl : isilonNFSAcl.getAcl()) {
if (tempAcl.getTrustee() != null) {
UnManagedNFSShareACL unmanagedNFSAcl = new UnManagedNFSShareACL();
unmanagedNFSAcl.setFileSystemPath(exportPath);
// and avoid null pointers too
if (tempAcl.getTrustee().getName() != null) {
String[] tempUname = StringUtils.split(tempAcl.getTrustee().getName(), "\\");
if (tempUname.length > 1) {
unmanagedNFSAcl.setDomain(tempUname[0]);
unmanagedNFSAcl.setUser(tempUname[1]);
} else {
unmanagedNFSAcl.setUser(tempUname[0]);
}
unmanagedNFSAcl.setType(tempAcl.getTrustee().getType());
unmanagedNFSAcl.setPermissionType(tempAcl.getAccesstype());
unmanagedNFSAcl.setPermissions(StringUtils.join(getIsilonAccessList(tempAcl.getAccessrights()), ","));
unmanagedNFSAcl.setFileSystemId(unManagedFileSystem.getId());
unmanagedNFSAcl.setId(URIUtil.createId(UnManagedNFSShareACL.class));
_log.info("Unmanaged File share acls : {}", unmanagedNFSAcl);
String fsShareNativeId = unmanagedNFSAcl.getFileSystemNfsACLIndex();
_log.info("UMFS Share ACL index {}", fsShareNativeId);
String fsUnManagedFileShareNativeGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingFileShare(storageSystem, fsShareNativeId);
_log.info("Native GUID {}", fsUnManagedFileShareNativeGuid);
// set native guid, so each entry unique
unmanagedNFSAcl.setNativeGuid(fsUnManagedFileShareNativeGuid);
unManagedNfsACLList.add(unmanagedNFSAcl);
// Check whether the NFS share ACL was present in ViPR DB.
existingNfsACL = checkUnManagedFsNfssACLExistsInDB(_dbClient, unmanagedNFSAcl.getNativeGuid());
if (existingNfsACL != null) {
// delete the existing acl
existingNfsACL.setInactive(true);
oldunManagedNfsShareACLList.add(existingNfsACL);
}
} else {
_log.warn("Trustee name is null, and so skipping the File share ACL entry");
}
}
if (unManagedNfsACLList != null && !unManagedNfsACLList.isEmpty()) {
unManagedFileSystem.setHasNFSAcl(true);
}
}
} catch (Exception ex) {
_log.warn("Unble to access NFS ACLs for path {}", exportPath);
}
}
}
use of com.emc.storageos.isilon.restapi.IsilonNFSACL in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method deleteNfsACLs.
@Override
public BiosCommandResult deleteNfsACLs(StorageSystem storage, FileDeviceInputOutput args) {
IsilonNFSACL isilonAcl = new IsilonNFSACL();
ArrayList<Acl> aclCompleteList = new ArrayList<Acl>();
List<NfsACE> aceToDelete = args.getNfsAclsToDelete();
for (NfsACE nfsACE : aceToDelete) {
Acl acl = getIsilonAclFromNfsACE(nfsACE);
acl.setOp("delete");
aclCompleteList.add(acl);
}
isilonAcl.setAction("update");
isilonAcl.setAuthoritative("acl");
isilonAcl.setAcl(aclCompleteList);
String path = args.getFileSystemPath();
if (args.getSubDirectory() != null && !args.getSubDirectory().isEmpty()) {
path = path + "/" + args.getSubDirectory();
}
// Process new ACLs
IsilonApi isi = getIsilonDevice(storage);
_log.info("Calling Isilon API: to delete NFS Acl for {}, acl {}", args.getFileSystemPath(), isilonAcl);
isi.modifyNFSACL(path, isilonAcl);
_log.info("End deleteNfsACLs");
BiosCommandResult result = BiosCommandResult.createSuccessfulResult();
return result;
}
Aggregations