use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class NetAppFileStorageDevice method updateShareACLs.
@Override
public BiosCommandResult updateShareACLs(StorageSystem storage, FileDeviceInputOutput args) {
List<ShareACL> existingAcls = new ArrayList<ShareACL>();
existingAcls = args.getExistingShareAcls();
BiosCommandResult result = new BiosCommandResult();
NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).build();
try {
processAclsForShare(nApi, args);
result = BiosCommandResult.createSuccessfulResult();
} catch (Exception e) {
_log.error("NetAppFileStorageDevice::updateShareACLs failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netapp.unableToUpdateCIFSShareAcl();
serviceError.setMessage(e.getLocalizedMessage());
result = BiosCommandResult.createErrorResult(serviceError);
// if delete or modify fails , revert to old acl
_log.info("update ACL failed ,going to roll back to existing ACLs");
rollbackShareACLs(storage, args, existingAcls);
}
return result;
}
use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class NetAppClusterModeDevice method deleteShareACLs.
@Override
public BiosCommandResult deleteShareACLs(StorageSystem storage, FileDeviceInputOutput args) {
BiosCommandResult result = new BiosCommandResult();
List<ShareACL> existingAcls = new ArrayList<ShareACL>();
existingAcls = args.getExistingShareAcls();
String portGroup = findSVMName(args.getFs());
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
try {
updateShareAcl(ncApi, args.getShareName(), existingAcls, AclOperation.DELETE);
result = BiosCommandResult.createSuccessfulResult();
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::Delete All ACL failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.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 NetAppClusterModeDevice method rollbackShareACLs.
private BiosCommandResult rollbackShareACLs(StorageSystem storage, FileDeviceInputOutput args, List<ShareACL> existingList) {
BiosCommandResult result = new BiosCommandResult();
String portGroup = findSVMName(args.getFs());
NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
try {
// We can have multiple ace added/modified in one put call ,some of them can fail due to some reason.
// In case of failure, to make it consistent in vipr db and NetApp share, delete all currently
// added and modified ace and revert it to old acl list
_log.info("NetAppClusterModeDevice::Rolling back update ACL by trying delete ACL for share {}", args.getShareName());
List<ShareACL> aclsToClear = new ArrayList<ShareACL>();
aclsToClear.addAll(args.getShareAclsToAdd());
aclsToClear.addAll(args.getShareAclsToModify());
updateShareAcl(ncApi, args.getShareName(), aclsToClear, AclOperation.FORCE_DELETE);
_log.info("NetAppClusterModeDevice::Adding back old ACL to Share {}", args.getShareName());
updateShareAcl(ncApi, args.getShareName(), existingList, AclOperation.FORCE_ADD);
result = BiosCommandResult.createSuccessfulResult();
} catch (Exception e) {
_log.error("NetAppClusterModeDevice::Roll Back of ACL failed with an Exception", e);
ServiceError serviceError = DeviceControllerErrors.netappc.unableToUpdateCIFSShareAcl();
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 FileStorageUtils method createShareACLs.
public static ShareACLs createShareACLs(FileSystemACLs[] acls) {
ShareACLs aclsToAdd = new ShareACLs();
List<ShareACL> aclList = new ArrayList<ShareACL>();
for (FileSystemACLs fileSystemACL : acls) {
ShareACL shareAcl = new ShareACL();
if (fileSystemACL.aclType.equalsIgnoreCase("GROUP")) {
shareAcl.setGroup(fileSystemACL.aclName);
} else {
shareAcl.setUser(fileSystemACL.aclName);
}
if (!StringUtils.isEmpty(fileSystemACL.aclDomain)) {
shareAcl.setDomain(fileSystemACL.aclDomain);
}
shareAcl.setPermission(fileSystemACL.aclPermission);
aclList.add(shareAcl);
}
aclsToAdd.setShareACLs(aclList);
return aclsToAdd;
}
use of com.emc.storageos.model.file.ShareACL in project coprhd-controller by CoprHD.
the class FileSnapshots method removeSnapShotAcl.
/**
* This method called When user selects ACLs and hit delete button.
*
* @param aclURL
* URL of the snapshot share.
* @param ids
* ids of the selected ACL
*/
@FlashException(referrer = { "snapshot" })
public static void removeSnapShotAcl(String aclUrl, @As(",") String[] ids) {
ShareACLs aclsToDelete = new ShareACLs();
List<ShareACL> shareAcls = new ArrayList<ShareACL>();
String snapshotId = null;
String shareName = null;
if (ids != null && ids.length > 0) {
for (String id : ids) {
String type = SnapshotShareACLForm.extractTypeFromId(id);
String name = SnapshotShareACLForm.extractNameFromId(id);
String domain = SnapshotShareACLForm.extractDomainFromId(id);
snapshotId = SnapshotShareACLForm.extractSnapshotFromId(id);
shareName = SnapshotShareACLForm.extractShareNameFromId(id);
ShareACL ace = new ShareACL();
if (SnapshotShareACLForm.GROUP.equalsIgnoreCase(type)) {
ace.setGroup(name);
} else {
ace.setUser(name);
}
if (domain != null && !"".equals(domain) && !"null".equals(domain)) {
ace.setDomain(domain);
}
shareAcls.add(ace);
}
aclsToDelete.setShareACLs(shareAcls);
SnapshotCifsShareACLUpdateParams input = new SnapshotCifsShareACLUpdateParams();
input.setAclsToDelete(aclsToDelete);
ViPRCoreClient client = BourneUtil.getViprClient();
client.fileSnapshots().updateShareACL(uri(snapshotId), shareName, input);
}
flash.success(MessagesUtils.get("resources.filesystem.share.acl.deleted"));
listSnapshotAcl(snapshotId, shareName);
}
Aggregations