use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class CifsShareUtility method verifyAddShareACLs.
private void verifyAddShareACLs(List<ShareACL> shareAclList) {
if (shareAclList == null) {
return;
}
_log.info("Number of share ACL(s) to add {} ", shareAclList.size());
for (ShareACL acl : shareAclList) {
acl.proceedToNextStep();
_log.info("Verifying ACL {}", acl.toString());
// Are there same user or group found in other acls. If so, report
// error
verifyUserGroup(acl);
if (!acl.canProceedToNextStep()) {
break;
}
validatePermissions(acl);
if (!acl.canProceedToNextStep()) {
break;
}
// Verify with existing ACL
CifsShareACL dbShareAcl = getExistingACL(acl);
// If same acl exists, don't allow to add again.
if (dbShareAcl != null) {
_log.error("Duplicate ACL in add request. User/group in ACL for share already exists: {}", dbShareAcl);
acl.cancelNextStep(ShareACLOperationErrorType.ACL_EXISTS);
break;
} else // If not found proceed for further verifications.
{
if (acl.canProceedToNextStep()) {
_log.info("No existing ACL found in DB {}", acl);
}
}
}
}
use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method deleteShareACLs.
@Override
public BiosCommandResult deleteShareACLs(StorageSystem storage, FileDeviceInputOutput args) {
BiosCommandResult result = new BiosCommandResult();
List<ShareACL> existingAcls = new ArrayList<ShareACL>();
existingAcls = args.getExistingShareAcls();
NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).build();
try {
deleteShareAcl(nApi, args.getShareName(), existingAcls);
result = BiosCommandResult.createSuccessfulResult();
} catch (Exception e) {
_log.error("NetAppFileStorageDevice::Delete All ACL failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netapp.unableToDeleteCIFSShareAcl();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
}
return result;
}
use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method addShareAcl.
private void addShareAcl(NetAppApi nApi, String shareName, List<ShareACL> aclsToAdd) {
if (aclsToAdd == null || aclsToAdd.isEmpty()) {
return;
}
List<CifsAcl> acls = new ArrayList<CifsAcl>();
for (ShareACL newAcl : aclsToAdd) {
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;
}
// for netapp api user and group are same.and need to set only user
cif_new.setUserName(userOrGroup);
cif_new.setShareName(shareName);
cif_new.setAccess(getAccessEnum(newAcl.getPermission()));
acls.add(cif_new);
}
nApi.modifyCIFSShareAcl(shareName, acls);
}
use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method deleteShareAcl.
private void deleteShareAcl(NetAppApi nApi, String shareName, List<ShareACL> aclsToDelete) {
if (aclsToDelete == null || aclsToDelete.isEmpty()) {
return;
}
List<CifsAcl> acls = new ArrayList<CifsAcl>();
for (ShareACL newAcl : aclsToDelete) {
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;
}
// for netapp api user and group are same.and need to set only user
cif_new.setUserName(userOrGroup);
cif_new.setShareName(shareName);
cif_new.setAccess(getAccessEnum(newAcl.getPermission()));
acls.add(cif_new);
}
nApi.deleteCIFSShareAcl(shareName, acls);
}
use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method forceDeleteShareAcl.
private void forceDeleteShareAcl(NetAppApi nApi, String shareName, List<ShareACL> aclsToDelete) {
if (aclsToDelete == null || aclsToDelete.isEmpty()) {
return;
}
List<CifsAcl> acls = new ArrayList<CifsAcl>();
for (ShareACL newAcl : aclsToDelete) {
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;
}
// for netapp api user and group are same.and need to set only user
cif_new.setUserName(userOrGroup);
cif_new.setShareName(shareName);
cif_new.setAccess(getAccessEnum(newAcl.getPermission()));
acls.add(cif_new);
}
for (CifsAcl cifsAcl : acls) {
try {
List<CifsAcl> singleACL = new ArrayList<CifsAcl>();
singleACL.add(cifsAcl);
nApi.deleteCIFSShareAcl(shareName, singleACL);
} catch (Exception e) {
_log.error("NetAppFileStorageDevice:: Force delete of ACL for user [" + cifsAcl.getUserName() + "] failed with an Exception", e);
}
}
}
Aggregations