Search in sources :

Example 41 with Snapshot

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

the class VNXUnityFileStorageDevice method doDeleteSnapshot.

@Override
public BiosCommandResult doDeleteSnapshot(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _logger.info("Deleting file system {} snapshot {} ", args.getFsName(), args.getSnapshotLabel());
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    VNXeCommandJob job = null;
    VNXeFileTaskCompleter completer = null;
    try {
        job = apiClient.deleteFileSystemSnap(args.getSnapNativeId());
        if (job != null) {
            completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
            VNXeDeleteFileSystemSnapshotJob snapJob = new VNXeDeleteFileSystemSnapshotJob(job.getId(), storage.getId(), completer);
            ControllerServiceImpl.enqueueJob(new QueueJob(snapJob));
        } else {
            _logger.error("No job returned from deleteFileSystemSnap");
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("snapshotFileSystem", "No Job returned from deleteFileSystemSnap");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Delete file system snapshot got the exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Delete file system snpashot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystemSnapshot", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Delete filesystem snapshot job submitted - Array:%s, fileSystem: %s, snapshot: %s", storage.getSerialNumber(), args.getFsName(), args.getSnapshotName()));
    _logger.info(logMsgBuilder.toString());
    return BiosCommandResult.createPendingResult();
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeDeleteFileSystemSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeDeleteFileSystemSnapshotJob) VNXeException(com.emc.storageos.vnxe.VNXeException) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 42 with Snapshot

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

the class VNXUnityFileStorageDevice method doRestoreFS.

@Override
public BiosCommandResult doRestoreFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _logger.info("restoring file system {} snap {} ", args.getFsName(), args.getSnapshotLabel());
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    VNXeCommandJob job = null;
    VNXeFSSnapshotTaskCompleter completer = null;
    try {
        job = apiClient.restoreFileSystemSnap(args.getSnapNativeId());
        if (job != null) {
            completer = new VNXeFSSnapshotTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
            VNXeRestoreFileSystemSnapshotJob snapJob = new VNXeRestoreFileSystemSnapshotJob(job.getId(), storage.getId(), completer);
            ControllerServiceImpl.enqueueJob(new QueueJob(snapJob));
        } else {
            _logger.error("No job returned from restoreFileSystemSnap");
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("restoreSnapshotFileSystem", "No Job returned from restoreFileSystemSnap");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Restore file system snapshot got the exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Restore file system snpashot got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("RestoreFileSystemSnapshot", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Restore filesystem snapshot job submitted - Array:%s, fileSystem: %s, snapshot: %s", storage.getSerialNumber(), args.getFsName(), args.getSnapshotLabel()));
    _logger.info(logMsgBuilder.toString());
    return BiosCommandResult.createPendingResult();
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeFSSnapshotTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter) VNXeRestoreFileSystemSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeRestoreFileSystemSnapshotJob) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 43 with Snapshot

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

the class VNXUnityFileStorageDevice method doSnapshotFS.

@Override
public BiosCommandResult doSnapshotFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _logger.info("creating file system {} snap {} ", args.getFsName(), args.getSnapshotLabel());
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    VNXeCommandJob job = null;
    VNXeFSSnapshotTaskCompleter completer = null;
    try {
        job = apiClient.createFileSystemSnap(args.getFsNativeId(), args.getSnapshotName());
        if (job != null) {
            completer = new VNXeFSSnapshotTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
            VNXeCreateFileSystemSnapshotJob snapJob = new VNXeCreateFileSystemSnapshotJob(job.getId(), storage.getId(), completer);
            ControllerServiceImpl.enqueueJob(new QueueJob(snapJob));
        } else {
            _logger.error("No job returned from createFileSystemSnap");
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("snapshotFileSystem", "No Job returned from createFileSystemSnap");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Create file system snapshot got an exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Create file system snapshot got an exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateFileSystemSnapshot", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create filesystem snapshot job submitted - Array:%s, fileSystem: %s", storage.getSerialNumber(), args.getFsName()));
    _logger.info(logMsgBuilder.toString());
    return BiosCommandResult.createPendingResult();
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeFSSnapshotTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFSSnapshotTaskCompleter) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeCreateFileSystemSnapshotJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeCreateFileSystemSnapshotJob) VNXeException(com.emc.storageos.vnxe.VNXeException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 44 with Snapshot

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

the class VNXUnityFileStorageDevice method doShare.

@Override
public BiosCommandResult doShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    _logger.info("creating smbShare: " + smbFileShare.getName());
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    String permission = smbFileShare.getPermission();
    String shareName = smbFileShare.getName();
    String path = "/";
    VNXeCommandJob job = null;
    VNXeFileTaskCompleter completer = null;
    FileSMBShare newShare = new FileSMBShare(smbFileShare);
    String absolutePath = smbFileShare.getPath();
    newShare.setStoragePortNetworkId(smbFileShare.getStoragePortNetworkId());
    newShare.setStoragePortName(smbFileShare.getStoragePortName());
    try {
        if (args.getFileOperation()) {
            if (newShare.isSubDirPath()) {
                String basePath = args.getFsPath();
                /*
                     * The below line will allow us to get the relative path of subdir
                     * For example: absolutePath = /vnxeShare1/subdir1
                     * Then, the below line will assign path = subdir
                     * VNXe takes the relative path of the sub-directory. Not the absolute path
                     */
                path = "/" + new File(basePath).toURI().relativize(new File(absolutePath).toURI()).getPath();
            }
            String fsNativeId = args.getFs().getNativeId();
            _logger.info("Creating CIFS share for path {}", path);
            job = apiClient.createCIFSShare(fsNativeId, shareName, permission, path);
            if (job != null) {
                newShare.setNetBIOSName(apiClient.getNetBios());
                completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
                VNXeCreateShareJob createShareJob = new VNXeCreateShareJob(job.getId(), storage.getId(), completer, newShare, true);
                ControllerServiceImpl.enqueueJob(new QueueJob(createShareJob));
            } else {
                _logger.error("No job returned from creaetCifsShare");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("createShare", "No Job returned");
                return BiosCommandResult.createErrorResult(error);
            }
        } else {
            // create share for a snapshot
            if (newShare.isSubDirPath()) {
                String basePath = args.getSnapshotPath();
                /*
                     * The below line will allow us to get the relative path of subdir
                     * For example: absolutePath = /vnxeShare1/subdir1
                     * Then, the below line will assign path = subdir
                     * VNXe takes the relative path of the sub-directory. Not the absolute path
                     */
                path = "/" + new File(basePath).toURI().relativize(new File(absolutePath).toURI()).getPath();
            }
            String fsNativeId = args.getFs().getNativeId();
            String snapId = args.getSnapNativeId();
            job = apiClient.createCifsShareForSnap(snapId, shareName, permission, path, fsNativeId);
            if (job != null) {
                newShare.setNetBIOSName(apiClient.getNetBios());
                completer = new VNXeFileTaskCompleter(Snapshot.class, args.getSnapshotId(), args.getOpId());
                VNXeCreateShareJob createShareJob = new VNXeCreateShareJob(job.getId(), storage.getId(), completer, newShare, false);
                ControllerServiceImpl.enqueueJob(new QueueJob(createShareJob));
            } else {
                _logger.error("No job returned from creaetCifsShare");
                ServiceError error = DeviceControllerErrors.vnxe.jobFailed("createShare", "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("create 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("Create 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) 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) VNXeCreateShareJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeCreateShareJob) File(java.io.File) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 45 with Snapshot

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

the class NetAppClusterModeDevice method doDeleteShare.

@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
    BiosCommandResult result = new BiosCommandResult();
    try {
        _log.info("NetAppClusterModeDevice doDeleteShare - start");
        FileShare fileshare = null;
        if (args.getFileOperation() == true) {
            fileshare = args.getFs();
        } else {
            URI snapShotUID = args.getSnapshotId();
            Snapshot snapshot = _dbClient.queryObject(Snapshot.class, snapShotUID);
            fileshare = _dbClient.queryObject(FileShare.class, snapshot.getParent().getURI());
        }
        // Now get the VFiler from the fileShare
        String portGroup = findSVMName(fileshare);
        NetAppClusterApi ncApi = new NetAppClusterApi.Builder(storage.getIpAddress(), storage.getPortNumber(), storage.getUsername(), storage.getPassword()).https(true).svm(portGroup).build();
        SMBShareMap shares = args.getFileObjShares();
        if (shares == null || shares.isEmpty()) {
            _log.error("NetAppClusterModeDevice::doDeleteShare failed: FileShare(s) is either missing or empty");
            ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
            serviceError.setMessage("FileShare(s) is either missing or empty");
            result = BiosCommandResult.createErrorResult(serviceError);
        }
        SMBFileShare fileShare = shares.get(smbFileShare.getName());
        if (fileShare != null) {
            if (!ncApi.deleteShare(smbFileShare.getName())) {
                _log.error("NetAppClusterModeDevice doDeleteShare {} - failed", args.getFileObjId());
                ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
                serviceError.setMessage("Deletion of CIFS File Share failed");
                result = BiosCommandResult.createErrorResult(serviceError);
            } else {
                _log.info("NetAppClusterModeDevice doDeleteShare {} - complete", args.getFileObjId());
                args.getFileObjShares().remove(smbFileShare.getName());
                args.getFileObjShares().remove(smbFileShare.getNativeId());
                result = BiosCommandResult.createSuccessfulResult();
            }
        }
    } catch (NetAppCException e) {
        _log.error("NetAppClusterModeDevice::doDeleteShare failed with a NetAppCException", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    } catch (Exception e) {
        _log.error("NetAppClusterModeDevice::doDeleteShare failed with an Exception", e);
        ServiceError serviceError = DeviceControllerErrors.netappc.unableToDeleteFileShare();
        serviceError.setMessage(e.getLocalizedMessage());
        result = BiosCommandResult.createErrorResult(serviceError);
    }
    return result;
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) SMBShareMap(com.emc.storageos.db.client.model.SMBShareMap) NetAppClusterApi(com.emc.storageos.netappc.NetAppClusterApi) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) NetAppCException(com.emc.storageos.netappc.NetAppCException) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) ControllerException(com.emc.storageos.volumecontroller.ControllerException) NetAppCException(com.emc.storageos.netappc.NetAppCException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) NetAppException(com.emc.storageos.netapp.NetAppException)

Aggregations

Snapshot (com.emc.storageos.db.client.model.Snapshot)92 FileShare (com.emc.storageos.db.client.model.FileShare)59 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)52 URI (java.net.URI)36 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)34 ControllerException (com.emc.storageos.volumecontroller.ControllerException)34 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)32 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)31 ArrayList (java.util.ArrayList)24 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)23 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)22 FileObject (com.emc.storageos.db.client.model.FileObject)21 URISyntaxException (java.net.URISyntaxException)21 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)19 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)19 WorkflowException (com.emc.storageos.workflow.WorkflowException)19 MapFileSnapshot (com.emc.storageos.api.mapper.functions.MapFileSnapshot)18 Path (javax.ws.rs.Path)18 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)17 Produces (javax.ws.rs.Produces)17