Search in sources :

Example 41 with ExportRule

use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.

the class FileOperationUtils method getExportRules.

public static List<ExportRule> getExportRules(URI id, boolean allDirs, String subDir, DbClient dbClient) {
    FileShare fs = dbClient.queryObject(FileShare.class, id);
    List<ExportRule> exportRule = new ArrayList<>();
    // Query All Export Rules Specific to a File System.
    List<FileExportRule> exports = queryDBFSExports(fs, dbClient);
    _log.info("Number of existing exports found : {} ", exports.size());
    if (allDirs) {
        // ALL EXPORTS
        for (FileExportRule rule : exports) {
            ExportRule expRule = new ExportRule();
            // Copy Props
            copyPropertiesToSave(rule, expRule, fs);
            exportRule.add(expRule);
        }
    } else if (subDir != null && subDir.length() > 0) {
        // Filter for a specific Sub Directory export
        for (FileExportRule rule : exports) {
            if (rule.getExportPath().endsWith("/" + subDir)) {
                ExportRule expRule = new ExportRule();
                // Copy Props
                copyPropertiesToSave(rule, expRule, fs);
                exportRule.add(expRule);
            }
        }
    } else {
        // Filter for No SUBDIR - main export rules with no sub dirs
        for (FileExportRule rule : exports) {
            if (rule.getExportPath().equalsIgnoreCase(fs.getPath())) {
                ExportRule expRule = new ExportRule();
                // Copy Props
                copyPropertiesToSave(rule, expRule, fs);
                exportRule.add(expRule);
            }
        }
    }
    _log.info("Number of export rules returning {}", exportRule.size());
    return exportRule;
}
Also used : FileExportRule(com.emc.storageos.db.client.model.FileExportRule) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule) FileExportRule(com.emc.storageos.db.client.model.FileExportRule) FileShare(com.emc.storageos.db.client.model.FileShare)

Example 42 with ExportRule

use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.

the class NetAppApi method modifyNFSShare.

public Boolean modifyNFSShare(String exportPath, List<ExportRule> exportRules) throws NetAppException {
    try {
        if (netAppFacade == null) {
            _logger.warn("Invalid Facade found {} creating now...", netAppFacade);
            netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https);
            _logger.warn("Facade created : {} ", netAppFacade);
        }
        _logger.info("NetApp Inputs for modifyNFSShare exportPath: {} , exportRules size {}", exportPath, exportRules.size());
        List<com.iwave.ext.netapp.utils.ExportRule> netAppCompatableRules = new ArrayList<>();
        for (ExportRule rule : exportRules) {
            com.iwave.ext.netapp.utils.ExportRule netAppRule = new com.iwave.ext.netapp.utils.ExportRule();
            copyPropertiesToSave(netAppRule, rule);
            netAppCompatableRules.add(netAppRule);
        }
        netAppFacade.modifyNFSShare(exportPath, netAppCompatableRules);
    } catch (Exception e) {
        _logger.error("Error Occured {} ", e.getMessage(), e);
        throw NetAppException.exceptions.exportFSFailed(exportPath, exportPath, e.getMessage());
    }
    return true;
}
Also used : NetAppFacade(com.iwave.ext.netapp.NetAppFacade) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule)

Example 43 with ExportRule

use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.

the class NetAppApi method exportNewFS.

public Boolean exportNewFS(String exportPath, List<ExportRule> exportRules) throws NetAppException {
    try {
        List<String> fsList = null;
        if (netAppFacade == null) {
            _logger.warn("Invalid Facade found {} creating now...", netAppFacade);
            netAppFacade = new NetAppFacade(_ipAddress, _portNumber, _userName, _password, _https);
            _logger.warn("Facade created : {} ", netAppFacade);
        }
        _logger.info("NetApp Inputs for exportNewFS exportPath: {} , exportRules size {}", exportPath, exportRules.size());
        List<com.iwave.ext.netapp.utils.ExportRule> netAppCompatableRules = new ArrayList<>();
        for (ExportRule rule : exportRules) {
            com.iwave.ext.netapp.utils.ExportRule netAppRule = new com.iwave.ext.netapp.utils.ExportRule();
            copyPropertiesToSave(netAppRule, rule);
            netAppCompatableRules.add(netAppRule);
        }
        fsList = netAppFacade.addNewNFSShare(exportPath, netAppCompatableRules);
        if (fsList.isEmpty()) {
            return false;
        }
    } catch (Exception e) {
        _logger.error("Error Occured {} ", e.getMessage(), e);
        throw NetAppException.exceptions.exportFSFailed(exportPath, exportPath, e.getMessage());
    }
    return true;
}
Also used : NetAppFacade(com.iwave.ext.netapp.NetAppFacade) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule)

Example 44 with ExportRule

use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.

the class NetAppClusterApi method modifyNFSShare.

public Boolean modifyNFSShare(String fsName, String qtreeName, String exportPath, ExportRule oldRule, ExportRule newRule) throws NetAppCException {
    try {
        netAppClusterFacade = new NetAppClusterFacade(_ipAddress, _portNumber, _userName, _password, _https, true, _svmName);
        _logger.info("NetApp Inputs for modifyNFSShare exportPath: {} ", exportPath);
        List<com.iwave.ext.netapp.utils.ExportRule> netAppCompatableRules = new ArrayList<>();
        com.iwave.ext.netapp.utils.ExportRule netAppOldRule = new com.iwave.ext.netapp.utils.ExportRule();
        copyPropertiesToSave(netAppOldRule, oldRule);
        netAppCompatableRules.add(netAppOldRule);
        com.iwave.ext.netapp.utils.ExportRule netAppNewRule = new com.iwave.ext.netapp.utils.ExportRule();
        copyPropertiesToSave(netAppNewRule, newRule);
        netAppCompatableRules.add(netAppNewRule);
        netAppClusterFacade.modifyNFSShare(fsName, qtreeName, exportPath, netAppOldRule, netAppNewRule);
    } catch (Exception e) {
        _logger.error("Error Occured {} ", e.getMessage(), e);
        throw NetAppCException.exceptions.exportFSFailed(exportPath, exportPath, e.getMessage());
    }
    return true;
}
Also used : NetAppClusterFacade(com.iwave.ext.netappc.NetAppClusterFacade) ArrayList(java.util.ArrayList) ExportRule(com.emc.storageos.model.file.ExportRule)

Example 45 with ExportRule

use of com.emc.storageos.model.file.ExportRule in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method deleteExportRules.

@Override
public BiosCommandResult deleteExportRules(StorageSystem storage, FileDeviceInputOutput args) {
    try {
        // TODO - These lines may be removed once DD snapshot APIs become available.
        if (!args.getFileOperation()) {
            // Snapshot Export operation is not supported by Data Domain.
            ServiceError serviceError = DeviceControllerErrors.datadomain.operationNotSupported();
            serviceError.setMessage("Data Domain does not support snapshot export");
            return BiosCommandResult.createErrorResult(serviceError);
        }
        _log.info("DataDomainFileStorageDevice deleteExportRules - start");
        FileShare fs = args.getFs();
        // List of existing export rules
        List<ExportRule> existingExports = args.getExistingDBExportRules();
        if ((existingExports == null) || (existingExports.isEmpty())) {
            _log.info("Export rule delete, file system {} does not have an existing export to delete", args.getFsId());
            return BiosCommandResult.createSuccessfulResult();
        }
        _log.info("Number of existng Rules found {}", existingExports.size());
        // Build export path, adding sub-directory if not null and non-empty
        String exportPath;
        String subDir = args.getSubDirectory();
        StringBuilder expPath = new StringBuilder();
        if (!args.getFileOperation()) {
            expPath.append(args.getSnapshotPath());
        } else {
            expPath.append(args.getFs().getPath());
        }
        if ((subDir != null) && (subDir.length() > 0)) {
            expPath.append("/");
            expPath.append(subDir);
        }
        exportPath = expPath.toString();
        // Data Domain attaches a prefix to every file system path
        expPath = new StringBuilder();
        if (!exportPath.startsWith(DataDomainApiConstants.FS_PATH_BASE)) {
            expPath.append(DataDomainApiConstants.FS_PATH_BASE);
        }
        expPath.append(exportPath);
        _log.info("exportPath : {}", expPath);
        args.setExportPath(expPath.toString());
        for (ExportRule expRule : existingExports) {
            if (expRule.getExportPath().equals(expPath.toString())) {
                args.setObjIdOnDevice(expRule.getDeviceExportId());
                break;
            }
        }
        // Do we need to delete all subdirectories as well?
        boolean allDirs = args.isAllDir();
        // List of IDs of exports to delete
        List<String> exportIdsToDelete = new ArrayList<>();
        exportIdsToDelete.add(args.getObjIdOnDevice());
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("deleteExportRules failed, provider unreachable");
            String op = "Delete export rules";
            return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
        }
        URI storagePoolId = args.getFs().getPool();
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
        if (allDirs) {
            // Add to the list of IDs of exports to delete
            buildListOfIdsToDelete(ddClient, storagePool.getNativeId(), expPath.toString(), exportIdsToDelete);
        }
        doDeleteExports(ddClient, storagePool.getNativeId(), exportIdsToDelete);
        _log.info("DataDomainFileStorageDevice deleteExportRules {} - complete", args.getFsId());
        return BiosCommandResult.createSuccessfulResult();
    } catch (DataDomainApiException dde) {
        _log.error("Export update failed, device error:", dde);
        return BiosCommandResult.createErrorResult(dde);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) ArrayList(java.util.ArrayList) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) URI(java.net.URI) DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) ExportRule(com.emc.storageos.model.file.ExportRule)

Aggregations

ExportRule (com.emc.storageos.model.file.ExportRule)67 ArrayList (java.util.ArrayList)27 FileExportRule (com.emc.storageos.db.client.model.FileExportRule)22 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)17 FileShare (com.emc.storageos.db.client.model.FileShare)16 ExportRules (com.emc.storageos.model.file.ExportRules)13 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)12 ControllerException (com.emc.storageos.volumecontroller.ControllerException)12 HashSet (java.util.HashSet)12 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)10 HashMap (java.util.HashMap)10 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)8 Snapshot (com.emc.storageos.db.client.model.Snapshot)7 FileExport (com.emc.storageos.db.client.model.FileExport)6 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)6 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)6 URI (java.net.URI)6 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)5 VNXeException (com.emc.storageos.vnxe.VNXeException)4 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)4