Search in sources :

Example 6 with DDServiceStatus

use of com.emc.storageos.datadomain.restapi.model.DDServiceStatus in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method ddDeleteShares.

private void ddDeleteShares(DataDomainClient ddClient, String storagePoolId, SMBShareMap currentShares, List<SMBFileShare> sharesToDelete) {
    if ((currentShares != null && (sharesToDelete != null))) {
        for (SMBFileShare fileShare : sharesToDelete) {
            String key = fileShare.getName();
            String ddShareId = null;
            SMBFileShare fShare = currentShares.get(key);
            if (fShare != null) {
                ddShareId = fShare.getNativeId();
            }
            if (ddShareId != null) {
                DDServiceStatus ddSvcStatus = ddClient.deleteShare(storagePoolId, ddShareId);
                if (ddSvcStatus.getCode() == DataDomainApiConstants.SVC_CODE_SUCCESS) {
                    currentShares.remove(key);
                }
            }
        }
    }
}
Also used : DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare)

Example 7 with DDServiceStatus

use of com.emc.storageos.datadomain.restapi.model.DDServiceStatus 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 8 with DDServiceStatus

use of com.emc.storageos.datadomain.restapi.model.DDServiceStatus in project coprhd-controller by CoprHD.

the class DataDomainFileStorageDevice method doDeleteFsExport.

private void doDeleteFsExport(DataDomainClient ddClient, String storagePoolId, String ddExportId) throws DataDomainApiException {
    if (ddExportId != null) {
        DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, ddExportId);
        if (ddSvcStatus.getCode() != DataDomainApiConstants.SVC_CODE_SUCCESS) {
            StringBuilder message = new StringBuilder(ddSvcStatus.getCode());
            message.append(": " + ddSvcStatus.getDetails());
            throw DataDomainApiException.exceptions.failedToDeleteExport(message.toString());
        }
    }
}
Also used : DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus)

Example 9 with DDServiceStatus

use of com.emc.storageos.datadomain.restapi.model.DDServiceStatus 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)

Aggregations

DDServiceStatus (com.emc.storageos.datadomain.restapi.model.DDServiceStatus)9 FileExport (com.emc.storageos.db.client.model.FileExport)4 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)3 DataDomainClient (com.emc.storageos.datadomain.restapi.DataDomainClient)2 DataDomainApiException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException)2 DDExportInfo (com.emc.storageos.datadomain.restapi.model.DDExportInfo)2 DDExportInfoDetail (com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail)2 DDShareInfo (com.emc.storageos.datadomain.restapi.model.DDShareInfo)2 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)2 StoragePool (com.emc.storageos.db.client.model.StoragePool)2 URI (java.net.URI)2 DataDomainResourceNotFoundException (com.emc.storageos.datadomain.restapi.errorhandling.DataDomainResourceNotFoundException)1 DDExportClient (com.emc.storageos.datadomain.restapi.model.DDExportClient)1 DDExportClientModify (com.emc.storageos.datadomain.restapi.model.DDExportClientModify)1 DDShareInfoDetail (com.emc.storageos.datadomain.restapi.model.DDShareInfoDetail)1 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)1