Search in sources :

Example 1 with DDServiceStatus

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

the class DataDomainFileStorageDevice method ddModifyExports.

private void ddModifyExports(DataDomainClient ddClient, String storagePoolId, FSExportMap exportMap, List<FileExport> modifyFileExports) {
    for (FileExport fileExport : modifyFileExports) {
        fileExport.setNativeId(exportMap.get(fileExport.getFileExportKey()).getNativeId());
        List<DDExportClientModify> ddExportClients = ddBuildModifyExportClientList(exportMap, fileExport);
        DDExportInfoDetail ddExport = ddClient.getExport(storagePoolId, fileExport.getNativeId());
        if (ddExport.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
            DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, ddExport.getId());
            throw DataDomainApiException.exceptions.failedExportPathDoesNotExist(ddExport.getPath());
        } else {
            DDExportInfo ddExportInfo = ddClient.modifyExport(storagePoolId, fileExport.getNativeId(), ddExportClients);
            FileExport existingExport = exportMap.get(fileExport.getFileExportKey());
            ddSetExistingExportProperties(existingExport, fileExport, ddExportInfo);
        }
    }
}
Also used : DDExportInfoDetail(com.emc.storageos.datadomain.restapi.model.DDExportInfoDetail) DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) DDExportInfo(com.emc.storageos.datadomain.restapi.model.DDExportInfo) FileExport(com.emc.storageos.db.client.model.FileExport) DDExportClientModify(com.emc.storageos.datadomain.restapi.model.DDExportClientModify)

Example 2 with DDServiceStatus

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

the class DataDomainFileStorageDevice method ddCreateShare.

private void ddCreateShare(DataDomainClient ddClient, String storagePoolId, SMBFileShare smbFileShare, String sharePath) throws DataDomainApiException {
    String shareName = smbFileShare.getName();
    int maxUsers = smbFileShare.getMaxUsers();
    String desc = smbFileShare.getDescription();
    String permissionType = smbFileShare.getPermissionType();
    String permission = smbFileShare.getPermission();
    DDShareInfo ddShareInfo = ddClient.createShare(storagePoolId, shareName, sharePath, maxUsers, desc, permissionType, permission);
    if (ddShareInfo.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
        DDServiceStatus ddSvcStatus = ddClient.deleteShare(storagePoolId, ddShareInfo.getId());
        throw DataDomainApiException.exceptions.failedSharePathDoesNotExist(sharePath);
    }
    smbFileShare.setNativeId(ddShareInfo.getId());
}
Also used : DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) DDShareInfo(com.emc.storageos.datadomain.restapi.model.DDShareInfo)

Example 3 with DDServiceStatus

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

the class DataDomainFileStorageDevice method doShare.

@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    try {
        _log.info("DataDomainFileStorageDevice doShare() - start");
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("doShare failed, provider unreachable");
            String op = "FS share create";
            return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
        }
        // Check if this is a new share or update of the existing share
        SMBShareMap smbShareMap = args.getFileObjShares();
        SMBFileShare existingShare = (smbShareMap == null) ? null : smbShareMap.get(smbFileShare.getName());
        String shareId;
        DDShareInfo ddShareInfo;
        // Cannot send empty description, send the share name in that case
        if (smbFileShare.getDescription() == null || smbFileShare.getDescription().isEmpty()) {
            _log.debug("SMB Share creation was called with empty description and setting name as desc");
            smbFileShare.setDescription(smbFileShare.getName());
        }
        if (existingShare != null) {
            shareId = existingShare.getNativeId();
            // modify share
            URI storagePoolId = args.getFs().getPool();
            StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
            DDShareInfoDetail ddShareInfoDetail = ddClient.getShare(storagePool.getNativeId(), shareId);
            if (ddShareInfoDetail.getPathStatus() == 0) {
                DDServiceStatus ddSvcStatus = ddClient.deleteShare(storagePool.getNativeId(), shareId);
                throw DataDomainApiException.exceptions.failedSharePathDoesNotExist(ddShareInfoDetail.getPath());
            }
            ddShareInfo = ddClient.modifyShare(storagePool.getNativeId(), shareId, smbFileShare.getDescription());
        } else {
            // new share
            URI storagePoolId = args.getFs().getPool();
            StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
            ddCreateShare(ddClient, storagePool.getNativeId(), smbFileShare, smbFileShare.getPath());
        }
        // init file share map
        if (args.getFileObjShares() == null) {
            args.initFileObjShares();
        }
        args.getFileObjShares().put(smbFileShare.getName(), smbFileShare);
        _log.info("DataDomainFileStorageDevice doShare() - complete");
        // Set MountPoint
        smbFileShare.setMountPoint(smbFileShare.getStoragePortNetworkId(), smbFileShare.getStoragePortName(), smbFileShare.getName());
        return BiosCommandResult.createSuccessfulResult();
    } catch (DataDomainApiException e) {
        _log.error("doShare failed, device error.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) StoragePool(com.emc.storageos.db.client.model.StoragePool) DDShareInfoDetail(com.emc.storageos.datadomain.restapi.model.DDShareInfoDetail) DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) URI(java.net.URI) DDShareInfo(com.emc.storageos.datadomain.restapi.model.DDShareInfo)

Example 4 with DDServiceStatus

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

the class DataDomainFileStorageDevice method ddCreateExports.

private void ddCreateExports(DataDomainClient ddClient, String storagePoolId, FSExportMap exportMap, List<FileExport> createFileExports) throws DataDomainApiException {
    for (FileExport fileExport : createFileExports) {
        // Build export map for export create
        String exportName;
        if (!fileExport.getPath().startsWith(DataDomainApiConstants.FS_PATH_BASE)) {
            exportName = DataDomainApiConstants.FS_PATH_BASE + fileExport.getPath();
            fileExport.setPath(exportName);
        } else {
            exportName = fileExport.getPath();
        }
        List<DDExportClient> ddExportClients = ddBuildCreateExportClientList(fileExport);
        for (DDExportClient ddExpClient : ddExportClients) {
            _log.info("DD Export Client {}", ddExpClient.toString());
        }
        DDExportInfo ddExportInfo = ddClient.createExport(storagePoolId, exportName, ddExportClients);
        if (ddExportInfo.getPathStatus() != DataDomainApiConstants.PATH_EXISTS) {
            DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, ddExportInfo.getId());
            throw DataDomainApiException.exceptions.failedExportPathDoesNotExist(exportName);
        } else {
            ddSetNewExportProperties(fileExport, ddExportClients, ddExportInfo);
            String exportKey = fileExport.getFileExportKey();
            exportMap.put(exportKey, fileExport);
        }
    }
}
Also used : DDExportClient(com.emc.storageos.datadomain.restapi.model.DDExportClient) DDServiceStatus(com.emc.storageos.datadomain.restapi.model.DDServiceStatus) DDExportInfo(com.emc.storageos.datadomain.restapi.model.DDExportInfo) FileExport(com.emc.storageos.db.client.model.FileExport)

Example 5 with DDServiceStatus

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

the class DataDomainFileStorageDevice method doDeleteExports.

private void doDeleteExports(DataDomainClient ddClient, String storagePoolId, List<String> exportIdsToDelete) {
    if ((exportIdsToDelete != null) && (!exportIdsToDelete.isEmpty())) {
        for (String exportId : exportIdsToDelete) {
            DDServiceStatus ddSvcStatus = ddClient.deleteExport(storagePoolId, exportId);
            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)

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