Search in sources :

Example 46 with FileExport

use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method ddDeleteExports.

private void ddDeleteExports(DataDomainClient ddClient, String storagePoolId, FSExportMap currentExports, List<FileExport> exportsToDelete) {
    if ((currentExports != null && (exportsToDelete != null) && (!exportsToDelete.isEmpty()))) {
        for (FileExport fileExport : exportsToDelete) {
            String key = fileExport.getFileExportKey();
            String ddExportId = null;
            FileExport fExport = currentExports.get(key);
            if (fExport != null) {
                ddExportId = fExport.getNativeId();
            }
            if (ddExportId != null) {
                DDExportInfoDetail ddExport = ddClient.getExport(storagePoolId, ddExportId);
                if (ddExport.getPathStatus() == DataDomainApiConstants.PATH_EXISTS) {
                    DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, ddExportId);
                }
            }
        }
    }
}
Also used : DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) FileExport(com.emc.storageos.db.client.model.FileExport)

Example 47 with FileExport

use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method doDeleteFS.

@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("DataDomainFileStorageDevice doDeleteFS {} - start", args.getFsId());
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("doDeleteFS failed, provider unreachable");
            String op = "FS delete";
            return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
        }
        URI storagePoolId = args.getFs().getPool();
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
        // Delete the exports for this file system
        FSExportMap exportMap = args.getFsExports();
        List<FileExport> exportMapvalues = null;
        if (exportMap != null) {
            exportMapvalues = new ArrayList<>(exportMap.values());
        }
        if ((exportMap != null) && (exportMapvalues != null)) {
            try {
                ddDeleteExports(ddClient, storagePool.getNativeId(), exportMap, exportMapvalues);
            } catch (DataDomainApiException dde) {
                _log.error("Unable to delete exports for the FS: ", dde);
            }
        }
        // Delete the SMB shares for this file system
        SMBShareMap shareMap = args.getFsShares();
        List<SMBFileShare> shareMapValues = null;
        if (shareMap != null) {
            shareMapValues = new ArrayList<>(shareMap.values());
        }
        if ((shareMap != null) && (shareMapValues != null)) {
            try {
                ddDeleteShares(ddClient, storagePool.getNativeId(), shareMap, shareMapValues);
            } catch (DataDomainApiException dde) {
                _log.error("Unable to delete cifs shares for the FS: ", dde);
            }
        }
        // Delete mtree on the DD array
        DDServiceStatus ddSvcStatus = ddClient.deleteMTree(storagePool.getNativeId(), args.getFs().getNativeId());
        _log.info("DataDomainFileStorageDevice doDeleteFS {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (DataDomainApiException e) {
        _log.error("doDeleteFS failed, device error", e);
        return BiosCommandResult.createErrorResult(e);
    } catch (DataDomainResourceNotFoundException e) {
        _log.error("doDeleteFS failed, Mtree not found.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) DataDomainResourceNotFoundException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) URI(java.net.URI) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) FileExport(com.emc.storageos.db.client.model.FileExport) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare)

Example 48 with FileExport

use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method doExport.

@Override
public BiosCommandResult doExport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    _log.info("DataDomainFileStorageDevice doExport {} - start", args.getFileObjId());
    // Snapshot Export operation is not supported by Data Domain.
    if (args.getFileOperation() == false) {
        return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.doCreateSnapshotExportFailed());
    }
    if ((exportList == null) || (exportList.isEmpty())) {
        return BiosCommandResult.createSuccessfulResult();
    }
    try {
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("doExport failed, provider unreachable");
            String op = "FS export";
            return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
        }
        if ((args.getFsExports() == null) || (args.getFsExports().isEmpty())) {
            // Initialize exports map
            args.initFileObjExports();
        }
        // Go through the list of new exports and add each to create list
        // if not in the list of existing exports or to the modify list if
        // contained in the existing list
        FSExportMap currExpMap = args.getFsExports();
        List<FileExport> modifyFileExports = new ArrayList<>();
        List<FileExport> createFileExports = new ArrayList<>();
        ddInitCreateModifyFileExportLists(currExpMap, exportList, modifyFileExports, createFileExports);
        // Create new exports and add to file export map
        ddCreateExports(ddClient, args.getStoragePool().getNativeId(), args.getFsExports(), createFileExports);
        // Modify existing exports
        ddModifyExports(ddClient, args.getStoragePool().getNativeId(), args.getFsExports(), modifyFileExports);
        _log.info("DataDomainFileStorageDevice doExport {} - complete", args.getFileObjId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (DataDomainApiException e) {
        _log.error("doExport failed, device error.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) FileExport(com.emc.storageos.db.client.model.FileExport) ArrayList(java.util.ArrayList) FSExportMap(com.emc.storageos.db.client.model.FSExportMap) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient)

Example 49 with FileExport

use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method doUnexport.

@Override
public BiosCommandResult doUnexport(StorageSystem storage, FileDeviceInputOutput args, List<FileExport> exportList) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppFileStorageDevice doUnexport: {} - start", args.getFileObjId());
        for (int expCount = 0; expCount < exportList.size(); expCount++) {
            FileExport export = exportList.get(expCount);
            String portGroup = findVfilerName(args.getFs());
            NetAppApi nApi = new NetAppApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).vFiler(portGroup).build();
            if (export.getPermissions() == null) {
                export.setPermissions("ro");
            }
            String mountPath = export.getMountPath();
            String exportPath = export.getPath();
            if (!nApi.unexportFS(exportPath, mountPath)) {
                _log.error("NetAppFileStorageDevice::doUnexport {} failed", args.getFileObjId());
                ServiceError serviceError = DeviceControllerErrors.netapp.unableToUnexportFileSystem();
                serviceError.setMessage(genDetailedMessage("doUnexport", args.getFileObjId().toString()));
                result = BiosCommandResult.createErrorResult(serviceError);
                return result;
            } else {
                _log.info("NetAppFileStorageDevice doUnexport {} - completed", args.getFileObjId());
                result = BiosCommandResult.createSuccessfulResult();
            }
        }
    } catch (NetAppException e) {
        _log.error("NetAppFileStorageDevice::doUnexport failed with a NetAppException", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToUnexportFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppFileStorageDevice::doUnexport failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netapp.unableToUnexportFileSystem();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    _log.info("NetAppFileStorageDevice doUnexport {} - complete", args.getFileObjId());
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) FileExport(com.emc.storageos.db.client.model.FileExport) NetAppApi(com.emc.storageos.netapp.NetAppApi) NetAppException(com.emc.storageos.netapp.NetAppException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Example 50 with FileExport

use of com.emc.storageos.db.client.model.FileExport in project coprhd-controller by CoprHD.

the class NetAppFileStorageDevice method validateExportArgs.

// Validate the export arguments for the VNX.
// 
// The root user mapping must be an integer or the value 'nobody'. Since
// 'nobody' is the default value on the NetApp, it does not need to be sent.
// The CLI only accepts UIDs (integer values).
private void validateExportArgs(List<FileExport> exports) throws ControllerException {
    String rootUser = "";
    for (FileExport exp : exports) {
        // Validate the root user mapping (specific to VNX)
        _log.info("FileExport:Clients:" + exp.getClients() + ":SPName:" + exp.getStoragePortName() + ":SP:" + exp.getStoragePort() + ":rootusermapping:" + exp.getRootUserMapping() + ":perm:" + exp.getPermissions() + ":protocol:" + exp.getProtocol() + ":security:" + exp.getSecurityType() + ":subDir:" + exp.getPath());
        rootUser = exp.getRootUserMapping();
        try {
            if (!rootUser.equalsIgnoreCase("nobody") && !rootUser.equalsIgnoreCase("root")) {
                Integer.parseInt(rootUser);
            }
        } catch (NumberFormatException nfe) {
            throw new DeviceControllerException("Invalid Root User Mapping {0} ", new Object[] { nfe });
        }
    }
}
Also used : FileExport(com.emc.storageos.db.client.model.FileExport) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

FileExport (com.emc.storageos.db.client.model.FileExport)66 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)33 ArrayList (java.util.ArrayList)32 FileShare (com.emc.storageos.db.client.model.FileShare)31 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)29 Snapshot (com.emc.storageos.db.client.model.Snapshot)21 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)20 FileShareExport (com.emc.storageos.volumecontroller.FileShareExport)18 ControllerException (com.emc.storageos.volumecontroller.ControllerException)17 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)16 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)14 VNXeException (com.emc.storageos.vnxe.VNXeException)12 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)11 URI (java.net.URI)10 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)8 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)8 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)8 FileObject (com.emc.storageos.db.client.model.FileObject)7 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)7 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)7