Search in sources :

Example 26 with VNXeException

use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.

the class VNXUnityFileStorageDevice method getFSSnapshotList.

@Override
public BiosCommandResult getFSSnapshotList(StorageSystem storage, FileDeviceInputOutput fd, List<String> snapshots) throws ControllerException {
    _logger.info("getFSSnapshotList {} - start", fd.getFsId());
    VNXeApiClient client = getVnxUnityClient(storage);
    try {
        List<VNXeFileSystemSnap> snaps = client.getFileSystemSnaps(fd.getFsNativeId());
        for (VNXeFileSystemSnap snap : snaps) {
            snapshots.add(snap.getName());
        }
        return BiosCommandResult.createSuccessfulResult();
    } catch (VNXeException e) {
        _logger.error("getFSSnapshotList failed.", e);
        return BiosCommandResult.createErrorResult(e);
    }
}
Also used : VNXeFileSystemSnap(com.emc.storageos.vnxe.models.VNXeFileSystemSnap) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException)

Example 27 with VNXeException

use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.

the class VNXUnityFileStorageDevice method doExpandFS.

@Override
public BiosCommandResult doExpandFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _logger.info("expanding file system: ", args.getFsName());
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    VNXeCommandJob job = null;
    VNXeFileTaskCompleter completer = null;
    try {
        job = apiClient.expandFileSystem(args.getFsNativeId(), args.getNewFSCapacity());
        if (job != null) {
            completer = new VNXeFileTaskCompleter(FileShare.class, args.getFsId(), args.getOpId());
            VNXeExpandFileSystemJob expandFSJob = new VNXeExpandFileSystemJob(job.getId(), storage.getId(), completer);
            ControllerServiceImpl.enqueueJob(new QueueJob(expandFSJob));
        } else {
            _logger.error("No job returned from expandFileSystem");
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("expandFileSystem", "No Job returned from expandFileSystem");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Expand file system got the exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Expand file system got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("ExpandFileSystem", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Expand filesystem job submitted - Array:%s, fileSystem: %s, new size: %d", storage.getSerialNumber(), args.getFsName(), args.getNewFSCapacity()));
    _logger.info(logMsgBuilder.toString());
    return BiosCommandResult.createPendingResult();
}
Also used : VNXeCommandJob(com.emc.storageos.vnxe.models.VNXeCommandJob) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) VNXeExpandFileSystemJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeExpandFileSystemJob) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) 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 28 with VNXeException

use of com.emc.storageos.vnxe.VNXeException 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 29 with VNXeException

use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.

the class VNXUnityFileStorageDevice method doCreateQuotaDirectory.

@Override
public BiosCommandResult doCreateQuotaDirectory(StorageSystem storage, FileDeviceInputOutput args, QuotaDirectory qd) throws ControllerException {
    _logger.info("creating Quota Directory: ", args.getQuotaDirectoryName());
    VNXUnityQuotaDirectoryTaskCompleter completer = null;
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    VNXeCommandJob job = null;
    try {
        Long softLimit = 0L;
        Long softGrace = 0L;
        Long size = 0L;
        if (qd.getSize() == 0) {
            // If quota directory has no size specified, inherit it from the parent fs
            size = args.getFsCapacity();
        // for the calculation of limit sizes
        } else {
            size = qd.getSize();
        }
        // conversion from percentage to bytes
        softLimit = Long.valueOf(qd.getSoftLimit() * size / 100);
        // using hard limit
        // conversion from days to seconds
        softGrace = Long.valueOf(qd.getSoftGrace() * 24 * 60 * 60);
        job = apiClient.createQuotaDirectory(args.getFsNativeId(), qd.getName(), qd.getSize(), softLimit, softGrace);
        if (job != null) {
            _logger.info("opid:" + args.getOpId());
            completer = new VNXUnityQuotaDirectoryTaskCompleter(QuotaDirectory.class, args.getQuotaDirectory().getId(), args.getOpId());
            if (args.getQuotaDirectory() == null) {
                _logger.error("Could not find the quota object");
            }
            VNXUnityCreateFileSystemQuotaDirectoryJob createQuotaJob = new VNXUnityCreateFileSystemQuotaDirectoryJob(job.getId(), storage.getId(), completer);
            ControllerServiceImpl.enqueueJob(new QueueJob(createQuotaJob));
        } else {
            _logger.error("No job returned from createQuotaDirectory");
            ServiceError error = DeviceControllerErrors.vnxe.jobFailed("No Job returned from createQuotaDirectory");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Create Quota Directory got an exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Create Quota Directory got an exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateQuotaDirectory", ex.getMessage());
        if (completer != null) {
            completer.error(dbClient, error);
        }
        return BiosCommandResult.createErrorResult(error);
    }
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create filesystem 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) ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException) QuotaDirectory(com.emc.storageos.db.client.model.QuotaDirectory) VNXUnityQuotaDirectoryTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxunity.job.VNXUnityQuotaDirectoryTaskCompleter) VNXUnityCreateFileSystemQuotaDirectoryJob(com.emc.storageos.volumecontroller.impl.vnxunity.job.VNXUnityCreateFileSystemQuotaDirectoryJob) 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 30 with VNXeException

use of com.emc.storageos.vnxe.VNXeException in project coprhd-controller by CoprHD.

the class VNXUnityFileStorageDevice method doDeleteFS.

/*
     * To get around the KH API delete file system async issues, using sync call for now.
     */
@Override
public BiosCommandResult doDeleteFS(StorageSystem storage, FileDeviceInputOutput fileInOut) throws ControllerException {
    _logger.info("deleting file system: ", fileInOut.getFsName());
    VNXeApiClient apiClient = getVnxUnityClient(storage);
    BiosCommandResult result = null;
    try {
        apiClient.deleteFileSystemSync(fileInOut.getFsNativeId(), fileInOut.getForceDelete());
        StringBuilder logMsgBuilder = new StringBuilder(String.format("Deleted filesystem - Array:%s, fileSystem: %s", storage.getSerialNumber(), fileInOut.getFsName()));
        _logger.info(logMsgBuilder.toString());
        result = BiosCommandResult.createSuccessfulResult();
    } catch (VNXeException e) {
        _logger.error("Delete file system got the exception", e);
        result = BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Delete file system got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", ex.getMessage());
        result = BiosCommandResult.createErrorResult(error);
    }
    return result;
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) BiosCommandResult(com.emc.storageos.volumecontroller.impl.BiosCommandResult) VNXeException(com.emc.storageos.vnxe.VNXeException) VNXeException(com.emc.storageos.vnxe.VNXeException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Aggregations

VNXeException (com.emc.storageos.vnxe.VNXeException)67 VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)60 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)41 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)40 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)40 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)36 ControllerException (com.emc.storageos.volumecontroller.ControllerException)34 FileShare (com.emc.storageos.db.client.model.FileShare)22 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)22 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)22 Snapshot (com.emc.storageos.db.client.model.Snapshot)20 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)18 ArrayList (java.util.ArrayList)17 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)16 FileExport (com.emc.storageos.db.client.model.FileExport)12 URI (java.net.URI)12 Test (org.junit.Test)10 FileShareExport (com.emc.storageos.volumecontroller.FileShareExport)8 HashMap (java.util.HashMap)8 StringSet (com.emc.storageos.db.client.model.StringSet)6