Search in sources :

Example 1 with VNXeDeleteShareJob

use of com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeDeleteShareJob in project coprhd-controller by CoprHD.

the class VNXeStorageDevice 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 = getVnxeClient(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) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) 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) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) VNXeException(com.emc.storageos.vnxe.VNXeException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 2 with VNXeDeleteShareJob

use of com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeDeleteShareJob 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)

Aggregations

FileShare (com.emc.storageos.db.client.model.FileShare)2 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)2 Snapshot (com.emc.storageos.db.client.model.Snapshot)2 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)2 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)2 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)2 VNXeException (com.emc.storageos.vnxe.VNXeException)2 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 FileSMBShare (com.emc.storageos.volumecontroller.FileSMBShare)2 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)2 VNXeDeleteShareJob (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeDeleteShareJob)2 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)1 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1