use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class FileSnapshots method createSnapshotCifsShareAclParams.
private static SnapshotCifsShareACLUpdateParams createSnapshotCifsShareAclParams(String formData) {
String[] uiAcls = formData.split(",");
List<ShareACL> acls = new ArrayList<ShareACL>();
for (String uiAce : uiAcls) {
String[] uiData = uiAce.split("~~~");
String uiType = uiData[0];
String uiName = uiData[1];
String uiDomain = uiData[2];
String uiPermission = uiData[3];
ShareACL shareAcl = new ShareACL();
if ("GROUP".equalsIgnoreCase(uiType)) {
shareAcl.setGroup(uiName);
} else {
shareAcl.setUser(uiName);
}
shareAcl.setPermission(uiPermission);
if (uiDomain != null && !"".equals(uiDomain)) {
shareAcl.setDomain(uiDomain);
}
acls.add(shareAcl);
}
SnapshotCifsShareACLUpdateParams input = new SnapshotCifsShareACLUpdateParams();
ShareACLs aclsToAdd = new ShareACLs();
aclsToAdd.setShareACLs(acls);
input.setAclsToAdd(aclsToAdd);
return input;
}
use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class FileSystems method listAclJson.
/**
* This method called during population of Datatable for ACL data.
*
* @param aclURL
* URL of the file system share.
*/
public static void listAclJson(String aclURL) {
String fileSystem = null;
String shareName = null;
if (StringUtils.isNotBlank(aclURL)) {
String[] parts = aclURL.split("/");
if (parts.length == 7) {
fileSystem = parts[3];
shareName = parts[5];
}
}
ViPRCoreClient client = BourneUtil.getViprClient();
List<ShareACL> shareAcls = client.fileSystems().getShareACLs(uri(fileSystem), shareName);
List<ShareACLDataTable.AclInfo> acl = Lists.newArrayList();
for (ShareACL shareAcl : shareAcls) {
String userOrGroup = shareAcl.getUser();
String type = "User";
if (shareAcl.getGroup() != null && shareAcl.getGroup() != "") {
type = "Group";
userOrGroup = shareAcl.getGroup();
}
acl.add(new ShareACLDataTable.AclInfo(userOrGroup, type, shareAcl.getPermission(), fileSystem, shareName, shareAcl.getDomain()));
}
renderJSON(DataTablesSupport.createJSON(acl, params));
}
use of com.emc.storageos.model.file.ShareACL 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");
}
}
use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method updateShareACLs.
@Override
public BiosCommandResult updateShareACLs(StorageSystem storage, FileDeviceInputOutput args) {
List<ShareACL> existingAcls = new ArrayList<ShareACL>();
existingAcls = args.getExistingShareAcls();
String portGroup = findSVMName(args.getFs());
BiosCommandResult result = new BiosCommandResult();
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
try {
processAclsForShare(ncApi, args);
result = BiosCommandResult.createSuccessfulResult();
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::updateShareACLs failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToUpdateCIFSShareAcl();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
// if delete or modify fails , revert to old acl
rollbackShareACLs(storage, args, existingAcls);
}
return result;
}
use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class IsilonFileStorageDevice method extraShareACLFromArray.
/**
* Get the Share ACL which are present in array but not in CoprHD Database.
*
* @param storage
* @param args
* @return Map with domain+ group or username with ShareACL
*/
private Map<String, ShareACL> extraShareACLFromArray(StorageSystem storage, FileDeviceInputOutput args) {
// get all Share ACL from CoprHD data base
List<ShareACL> existingDBShareACL = args.getExistingShareAcls();
Map<String, ShareACL> arrayShareACLMap = new HashMap<>();
// get the all the Share ACL from the storage system.
IsilonApi isi = getIsilonDevice(storage);
String zoneName = getZoneName(args.getvNAS());
IsilonSMBShare share = null;
if (zoneName != null) {
share = isi.getShare(args.getShareName(), zoneName);
} else {
share = isi.getShare(args.getShareName());
}
if (share != null) {
List<Permission> permissions = share.getPermissions();
for (Permission perm : permissions) {
if (perm.getPermissionType().equalsIgnoreCase(Permission.PERMISSION_TYPE_ALLOW)) {
ShareACL shareACL = new ShareACL();
shareACL.setPermission(perm.getPermission());
String userAndDomain = perm.getTrustee().getName();
String[] trustees = new String[2];
trustees = userAndDomain.split("\\\\");
String trusteesType = perm.getTrustee().getType();
if (trustees.length > 1) {
shareACL.setDomain(trustees[0]);
if (trusteesType.equals("group")) {
shareACL.setGroup(trustees[1]);
} else {
shareACL.setUser(trustees[1]);
}
} else {
if (trusteesType.equals("group")) {
shareACL.setGroup(trustees[0]);
} else {
shareACL.setUser(trustees[0]);
}
}
arrayShareACLMap.put(perm.getTrustee().getName(), shareACL);
}
}
for (Iterator iterator = existingDBShareACL.iterator(); iterator.hasNext(); ) {
ShareACL shareACL = (ShareACL) iterator.next();
String key = "";
String domain = "";
String user = shareACL.getUser();
String group = shareACL.getGroup();
if (shareACL.getDomain() != null && !shareACL.getDomain().isEmpty()) {
domain = shareACL.getDomain() + "\\";
}
if (user != null && !user.isEmpty()) {
key = domain + user;
} else if (group != null && !group.isEmpty()) {
key = domain + group;
}
if (arrayShareACLMap.containsKey(key)) {
arrayShareACLMap.remove(key);
}
}
}
return arrayShareACLMap;
}
Aggregations