Search in sources :

Example 26 with SMBFileShare

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

the class VNXUnityFileStorageDevice method doDeleteShare.

@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    _logger.info(String.format(String.format("Deleting smbShare: %s, nativeId: %s", smbFileShare.getName(), smbFileShare.getNativeId())));
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    String shareId = smbFileShare.getNativeId();
    VNXeCommandJob job = null;
    VNXeFileTaskCompleter completer = null;
    boolean isFile = args.getFileOperation();
    FileSMBShare newShare = new FileSMBShare(smbFileShare);
    try {
        if (isFile) {
            String fsId = args.getFs().getNativeId();
            job = apiClient.removeCifsShare(shareId, fsId);
        } else {
            job = apiClient.deleteCifsShareForSnapshot(shareId);
        }
        if (job != null) {
            if (isFile) {
                completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
            } else {
                completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
            }
            VNXeDeleteShareJob deleteShareJob = new VNXeDeleteShareJob(job.getId(), storage.getId(), completer, newShare, isFile);
            ControllerServiceImpl.enqueueJob(new QueueJob(deleteShareJob));
        } else {
            _logger.error("No job returned from deleteCifsShare");
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("deleteShare", "No Job returned");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Create share got the exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("delete share got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("create share", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete share job submitted - Array:%s, share: %s", storage.getSerialNumber(), smbFileShare.getName()));
    _logger.info(logMsgBuilder.toString());
    return BiosCommandResult.createPendingResult();
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeDeleteShareJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeDeleteShareJob) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) FileSMBShare(com.emc.storageos.volumecontroller.FileSMBShare) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) Snapshot(com.emc.storageos.db.client.model.Snapshot) VNXeException(com.emc.storageos.vnxe.VNXeException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 27 with SMBFileShare

use of com.emc.storageos.db.client.model.SMBFileShare 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 28 with SMBFileShare

use of com.emc.storageos.db.client.model.SMBFileShare 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 29 with SMBFileShare

use of com.emc.storageos.db.client.model.SMBFileShare 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 30 with SMBFileShare

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

the class DataDomainFileStorageDevice method doDeleteShares.

@Override
public BiosCommandResult doDeleteShares(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    try {
        _log.info("DataDomainFileStorageDevice doDeleteShares: {} - start");
        DataDomainClient ddClient = getDataDomainClient(storage);
        if (ddClient == null) {
            _log.error("doDeleteShares failed, provider unreachable");
            String op = "FS shares delete";
            return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
        }
        URI storagePoolId = args.getFs().getPool();
        StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
        SMBShareMap currentShares = args.getFileObjShares();
        List<SMBFileShare> sharesToDelete = new ArrayList<SMBFileShare>();
        sharesToDelete.addAll(currentShares.values());
        ddDeleteShares(ddClient, storagePool.getNativeId(), currentShares, sharesToDelete);
        _log.info("DataDomainFileStorageDevice doDeleteShare {} - complete");
        return BiosCommandResult.createSuccessfulResult();
    } catch (DataDomainApiException e) {
        _log.error("doDeleteShare failed, device error.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : DataDomainApiException(com.emc.storageos.datadomain.restapi.errorhandling.DataDomainApiException) StoragePool(com.emc.storageos.db.client.model.StoragePool) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) ArrayList(java.util.ArrayList) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) DataDomainClient(com.emc.storageos.datadomain.restapi.DataDomainClient) URI(java.net.URI)

Aggregations

SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)46 SMBShareMap (com.emc.storageos.db.client.model.SMBShareMap)26 FileShare (com.emc.storageos.db.client.model.FileShare)21 Snapshot (com.emc.storageos.db.client.model.Snapshot)16 ArrayList (java.util.ArrayList)15 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)13 ControllerException (com.emc.storageos.volumecontroller.ControllerException)13 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)12 FileSMBShare (com.emc.storageos.volumecontroller.FileSMBShare)9 URI (java.net.URI)9 FileExport (com.emc.storageos.db.client.model.FileExport)8 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)8 VNXeException (com.emc.storageos.vnxe.VNXeException)8 FSExportMap (com.emc.storageos.db.client.model.FSExportMap)7 FileDeviceInputOutput (com.emc.storageos.volumecontroller.FileDeviceInputOutput)7 FileObject (com.emc.storageos.db.client.model.FileObject)5 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)5 BiosCommandResult (com.emc.storageos.volumecontroller.impl.BiosCommandResult)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5