use of com.iwave.ext.netappc.model.CifsAcl in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method createNtpShare.
/**
* create NetAppC share with right permissions
*
* @param StorageSystem mount path of the fileshare
* @param args containing input/out arguments of filedevice
* @param smbFileShare smbFileshare object
* @param forceGroup Name of the group the fileshare belongs.
* @return
*/
private Boolean createNtpShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare, String forceGroup) throws NetAppCException {
String shareId = null;
String portGroup = findSVMName(args.getFs());
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
shareId = smbFileShare.getPath();
_log.info("NetAppClusterModeDevice doShare for {} with id {}", shareId, args.getFileObjId());
if (!ncApi.doShare(shareId, smbFileShare.getName(), smbFileShare.getDescription(), smbFileShare.getMaxUsers(), smbFileShare.getPermission(), forceGroup)) {
_log.info("NetAppClusterModeDevice doShare for {} with id {} - failed", shareId, args.getFileObjId());
return false;
} else {
// permission.
if (!ncApi.modifyShare(shareId, smbFileShare.getName(), smbFileShare.getDescription(), smbFileShare.getMaxUsers(), smbFileShare.getPermission(), forceGroup)) {
// Cleanup the share if permission update is
// unsuccessful.
doDeleteShare(storage, args, smbFileShare);
_log.info("NetAppClusterModeDevice doShare for {} with id {} - failed", shareId, args.getFileObjId());
return false;
} else {
smbFileShare.setNativeId(shareId);
// share creation is successful,no need to set permission,clear the default one.
List<CifsAcl> existingAcls = new ArrayList<CifsAcl>();
CifsAcl defaultAcl = new CifsAcl();
// By default NetApp share get everyone full access.
defaultAcl.setUserName("everyone");
defaultAcl.setAccess(CifsAccess.full);
existingAcls.add(defaultAcl);
ncApi.deleteCIFSShareAcl(smbFileShare.getName(), existingAcls);
smbFileShare.setNetBIOSName(ncApi.getNetBiosName());
_log.info("NetAppClusterModeDevice doShare for {} with id {} - complete", shareId, args.getFileObjId());
return true;
}
}
}
use of com.iwave.ext.netappc.model.CifsAcl in project coprhd-controller by CoprHD.
the class NetAppClusterApi method modifyShare.
public Boolean modifyShare(String mntpath, String shareName, String comment, int maxusers, String permission, String forcegroup) throws NetAppCException {
try {
netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
CifsAcl acl = new CifsAcl();
acl.setShareName(shareName);
acl.setAccess(CifsAccess.valueOfAccess(cifsPermissionMap.get(permission)));
acl.setUserName(CIFS_DEFAULT_GROUP);
netAppClusterFacade.setCIFSAcl(acl);
return true;
} catch (Exception e) {
throw NetAppCException.exceptions.modifyShareFailed(_ipAddress, e.getMessage());
}
}
use of com.iwave.ext.netappc.model.CifsAcl in project coprhd-controller by CoprHD.
the class NetAppClusterApi method modifyCIFSShareAcl.
public boolean modifyCIFSShareAcl(String shareName, List<CifsAcl> acls) {
try {
netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
_logger.info("Facade created : {} ", netAppClusterFacade);
for (CifsAcl acl : acls) {
acl.setShareName(shareName);
netAppClusterFacade.setCIFSAcl(acl);
}
} catch (Exception e) {
_logger.error("Error Occured {} ", e.getMessage(), e);
throw NetAppCException.exceptions.modifyCifsShareAclFailed(shareName, e.getMessage());
}
return true;
}
use of com.iwave.ext.netappc.model.CifsAcl in project coprhd-controller by CoprHD.
the class NetAppClusterApi method deleteCIFSShareAcl.
public boolean deleteCIFSShareAcl(String shareName, List<CifsAcl> acls) {
try {
netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
_logger.info("Facade created : {} ", netAppClusterFacade);
for (CifsAcl acl : acls) {
acl.setShareName(shareName);
netAppClusterFacade.deleteCIFSAcl(acl);
}
} catch (Exception e) {
_logger.error("Error Occured {} ", e.getMessage(), e);
throw NetAppCException.exceptions.deleteCIFSShareAclFailed(shareName, e.getMessage());
}
return true;
}
use of com.iwave.ext.netappc.model.CifsAcl in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method updateShareAcl.
/**
* updateShareAcl is method to perform add, modify and delete acl operation based
* on the param action
*
* @param ncApi
* @param shareName
* @param inputAcls
* @param action
*/
private void updateShareAcl(NetAppClusterApi ncApi, String shareName, List<ShareACL> inputAcls, AclOperation action) {
if (inputAcls.isEmpty()) {
return;
}
List<CifsAcl> acls = new ArrayList<CifsAcl>();
for (ShareACL newAcl : inputAcls) {
CifsAcl cif_new = new CifsAcl();
String domain = newAcl.getDomain();
String userOrGroup = newAcl.getGroup() == null ? newAcl.getUser() : newAcl.getGroup();
if (domain != null && !domain.isEmpty()) {
userOrGroup = domain + "\\" + userOrGroup;
}
cif_new.setUserName(userOrGroup);
cif_new.setAccess(getAccessEnum(newAcl.getPermission()));
acls.add(cif_new);
}
switch(action) {
case ADD:
ncApi.addCIFSShareAcl(shareName, acls);
break;
case MODIFY:
ncApi.modifyCIFSShareAcl(shareName, acls);
break;
case DELETE:
ncApi.deleteCIFSShareAcl(shareName, acls);
break;
case FORCE_ADD:
for (CifsAcl cifsAcl : acls) {
try {
List<CifsAcl> singleACL = new ArrayList<CifsAcl>();
singleACL.add(cifsAcl);
ncApi.addCIFSShareAcl(shareName, singleACL);
} catch (Exception e) {
_log.error("NetAppClusterModeDevice:: Force add of ACL for user [" + cifsAcl.getUserName() + "] failed with an Exception", e);
}
}
break;
case FORCE_DELETE:
for (CifsAcl cifsAcl : acls) {
try {
List<CifsAcl> singleACL = new ArrayList<CifsAcl>();
singleACL.add(cifsAcl);
ncApi.deleteCIFSShareAcl(shareName, singleACL);
} catch (Exception e) {
_log.error("NetAppClusterModeDevice:: Force delete of ACL for user [" + cifsAcl.getUserName() + "] failed with an Exception", e);
}
}
break;
default:
throw new IllegalArgumentException(action + " is not a valid action for acl");
}
}
Aggregations