Search in sources :

Example 11 with ShareACL

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;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ArrayList(java.util.ArrayList) NetAppApi(com.emc.storageos.netapp.NetAppApi) ShareACL(com.emc.storageos.model.file.ShareACL) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 12 with ShareACL

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;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 13 with ShareACL

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;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 14 with ShareACL

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;
}
Also used : ShareACLs(com.emc.storageos.model.file.ShareACLs) ArrayList(java.util.ArrayList) SetFileSystemShareACL(com.emc.sa.service.vipr.file.tasks.SetFileSystemShareACL) ShareACL(com.emc.storageos.model.file.ShareACL) SetFileSnapshotShareACL(com.emc.sa.service.vipr.file.tasks.SetFileSnapshotShareACL)

Example 15 with ShareACL

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);
}
Also used : SnapshotCifsShareACLUpdateParams(com.emc.storageos.model.file.SnapshotCifsShareACLUpdateParams) ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) ShareACLs(com.emc.storageos.model.file.ShareACLs) ArrayList(java.util.ArrayList) ShareACL(com.emc.storageos.model.file.ShareACL) FlashException(controllers.util.FlashException)

Aggregations

ShareACL (com.emc.storageos.model.file.ShareACL)36 ArrayList (java.util.ArrayList)22 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 ShareACLs (com.emc.storageos.model.file.ShareACLs)13 ControllerException (com.emc.storageos.volumecontroller.ControllerException)13 CifsShareACL (com.emc.storageos.db.client.model.CifsShareACL)10 NetAppException (com.emc.storageos.netapp.NetAppException)9 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)7 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)7 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)5 NetAppCException (com.emc.storageos.netappc.NetAppCException)4 CifsAcl (com.iwave.ext.netapp.model.CifsAcl)4 NFSShareACL (com.emc.storageos.db.client.model.NFSShareACL)3 IsilonApi (com.emc.storageos.isilon.restapi.IsilonApi)3 IsilonSMBShare (com.emc.storageos.isilon.restapi.IsilonSMBShare)3 Permission (com.emc.storageos.isilon.restapi.IsilonSMBShare.Permission)3 ShareACLOperationErrorType (com.emc.storageos.model.file.CifsShareACLUpdateParams.ShareACLOperationErrorType)3 FileCifsShareACLUpdateParams (com.emc.storageos.model.file.FileCifsShareACLUpdateParams)3 NetAppApi (com.emc.storageos.netapp.NetAppApi)3 NetAppClusterApi (com.emc.storageos.netappc.NetAppClusterApi)3