Search in sources :

Example 46 with VNXeException

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

the class VNXeStorageDevice method doDisconnect.

@Override
public void doDisconnect(StorageSystem storage) {
    try {
        _logger.info("doConnect {} - start", storage.getId());
        VNXeApiClient client = getVnxeClient(storage);
        client.logout();
        String msg = String.format("doDisconnect %1$s - complete", storage.getId());
        _logger.info(msg);
    } catch (VNXeException e) {
        _logger.error("doDisconnect failed.", e);
        throw DeviceControllerException.exceptions.disconnectStorageFailed(e);
    }
}
Also used : VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) VNXeException(com.emc.storageos.vnxe.VNXeException)

Example 47 with VNXeException

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

the class VNXeStorageDevice method doCreateFS.

@Override
public BiosCommandResult doCreateFS(StorageSystem storage, FileDeviceInputOutput fileInOut) throws ControllerException {
    _logger.info("creating file system: ", fileInOut.getFsName());
    Long fsSize = fileInOut.getFsCapacity();
    if (fsSize < 1) {
        // Invalid size throw an error
        _logger.error("doCreateFS failed : FileSystem size in bytes is not valid {}", fileInOut.getFsCapacity());
        ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("FileSystem size in bytes is not valid");
        return BiosCommandResult.createErrorResult(error);
    }
    VNXeFileTaskCompleter completer = null;
    VNXeApiClient apiClient = getVnxeClient(storage);
    VNXeCommandJob job = null;
    try {
        FileShare fs = fileInOut.getFs();
        URI port = fs.getStoragePort();
        if (port == null) {
            _logger.error("No storageport uri found in the fs");
            ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("No storageport uri found in the fs");
            return BiosCommandResult.createErrorResult(error);
        }
        StoragePort portObj = _dbClient.queryObject(StoragePort.class, port);
        URI haDomainUri = portObj.getStorageHADomain();
        StorageHADomain haDomainObj = _dbClient.queryObject(StorageHADomain.class, haDomainUri);
        StringSet protocols = fs.getProtocol();
        if (protocols.contains(StorageProtocol.File.NFS_OR_CIFS.name())) {
            /*
                 * the protocol is set to NFS_OR_CIFS, only if virtual pool's protocol is not set
                 * and the pool's protocol is set to NFS_OR_CIFS, since pool's protocol is set based on
                 * storageHADomain's protocol, setting the protocols to the selected StorageHADomain.
                 */
            protocols = haDomainObj.getFileSharingProtocols();
        }
        VNXeFSSupportedProtocolEnum protocolEnum = null;
        if (protocols.contains(StorageProtocol.File.NFS.name()) && protocols.contains(StorageProtocol.File.CIFS.name())) {
            protocolEnum = VNXeFSSupportedProtocolEnum.NFS_CIFS;
        } else if (protocols.contains(StorageProtocol.File.NFS.name())) {
            protocolEnum = VNXeFSSupportedProtocolEnum.NFS;
        } else if (protocols.contains(StorageProtocol.File.CIFS.name())) {
            protocolEnum = VNXeFSSupportedProtocolEnum.CIFS;
        } else {
            _logger.error("protocol is not support: " + protocols);
            ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("protocol is not support:" + protocols);
            return BiosCommandResult.createErrorResult(error);
        }
        job = apiClient.createFileSystem(fileInOut.getFsName(), fsSize, fileInOut.getPoolNativeId(), haDomainObj.getSerialNumber(), fileInOut.getThinProvision(), protocolEnum);
        if (job != null) {
            _logger.info("opid:" + fileInOut.getOpId());
            completer = new VNXeFileTaskCompleter(FileShare.class, fileInOut.getFsId(), fileInOut.getOpId());
            if (fileInOut.getFs() == null) {
                _logger.error("Could not find the fs object");
            }
            VNXeCreateFileSystemJob createFSJob = new VNXeCreateFileSystemJob(job.getId(), storage.getId(), completer, fileInOut.getPoolId());
            ControllerServiceImpl.enqueueJob(new QueueJob(createFSJob));
        } else {
            _logger.error("No job returned from creatFileSystem");
            ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("No Job returned from createFileSystem");
            return BiosCommandResult.createErrorResult(error);
        }
    } catch (VNXeException e) {
        _logger.error("Create file system got the exception", e);
        if (completer != null) {
            completer.error(_dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Create file system got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("CreateFileSystem", 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, Pool:%s, fileSystem: %s", storage.getSerialNumber(), fileInOut.getPoolNativeId(), fileInOut.getFsName()));
    _logger.info(logMsgBuilder.toString());
    return BiosCommandResult.createPendingResult();
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeFSSupportedProtocolEnum(com.emc.storageos.vnxe.models.VNXeFSSupportedProtocolEnum) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) StoragePort(com.emc.storageos.db.client.model.StoragePort) VNXeFileTaskCompleter(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) URI(java.net.URI) VNXeCreateFileSystemJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeCreateFileSystemJob) 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) VNXeException(com.emc.storageos.vnxe.VNXeException) StringSet(com.emc.storageos.db.client.model.StringSet) StorageHADomain(com.emc.storageos.db.client.model.StorageHADomain) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob)

Example 48 with VNXeException

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

the class VNXeStorageDevice method doExpandVolume.

@Override
public void doExpandVolume(StorageSystem storage, StoragePool pool, Volume volume, Long size, TaskCompleter taskCompleter) throws DeviceControllerException {
    _logger.info(String.format("Expand Volume Start - Array: %s, Pool: %s, Volume: %s, New size: %d", storage.getSerialNumber(), pool.getNativeGuid(), volume.getLabel(), size));
    String consistencyGroupId = null;
    URI consistencyGroupURI = volume.getConsistencyGroup();
    if (consistencyGroupURI != null) {
        BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupURI);
        if (consistencyGroup != null) {
            consistencyGroupId = consistencyGroup.getCgNameOnStorageSystem(storage.getId());
        }
    }
    try {
        VNXeApiClient apiClient = getVnxeClient(storage);
        VNXeCommandJob commandJob = apiClient.expandLun(volume.getNativeId(), size, consistencyGroupId);
        VNXeExpandVolumeJob expandVolumeJob = new VNXeExpandVolumeJob(commandJob.getId(), storage.getId(), taskCompleter);
        ControllerServiceImpl.enqueueJob(new QueueJob(expandVolumeJob));
    } catch (VNXeException e) {
        _logger.error("Expand volume got the exception", e);
        taskCompleter.error(_dbClient, e);
    } catch (Exception ex) {
        _logger.error("Expand volume got the exception", ex);
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("ExpandVolume", ex.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
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) URI(java.net.URI) VNXeExpandVolumeJob(com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeExpandVolumeJob) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) 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) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup)

Example 49 with VNXeException

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

the class VNXeStorageDevice method doDeleteFS.

/*
     * @Override
     * public BiosCommandResult doDeleteFS(StorageSystem storage,
     * FileDeviceInputOutput fileInOut) throws ControllerException {
     * _logger.info("deleting file system: ", fileInOut.getFsName());
     * VNXeApiClient apiClient = getVnxeClient(storage);
     * VNXeCommandJob job = null;
     * VNXeFileTaskCompleter completer = null;
     * try {
     * job = apiClient.deleteFileSystem(fileInOut.getFsNativeId(), fileInOut.getForceDelete());
     * if (job != null) {
     * completer = new VNXeFileTaskCompleter(FileShare.class, fileInOut.getFsId(), fileInOut.getOpId(),
     * OperationTypeEnum.DELETE_FILE_SYSTEM);
     * VNXeDeleteFileSystemJob deleteFSJob = new VNXeDeleteFileSystemJob(job.getId(), storage.getId(),
     * completer, fileInOut.getForceDelete());
     * ControllerServiceImpl.enqueueJob(new QueueJob(deleteFSJob));
     * } else {
     * _logger.error("No job returned from deleteFileSystem");
     * ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem",
     * "No Job returned from deleteFileSystem");
     * return BiosCommandResult.createErrorResult(error);
     * }
     * 
     * }catch (VNXeException e) {
     * _logger.error("Delete file system got the exception", e);
     * if (completer != null) {
     * completer.error(_dbClient, e);
     * }
     * return BiosCommandResult.createErrorResult(e);
     * } catch (Exception ex) {
     * _logger.error("Delete file system got the exception", ex);
     * ServiceError error = DeviceControllerErrors.vnxe.jobFailed("DeleteFileSystem", ex.getMessage());
     * if (completer != null) {
     * completer.error(_dbClient, error);
     * }
     * return BiosCommandResult.createErrorResult(error);
     * }
     * StringBuilder logMsgBuilder = new StringBuilder(String.format(
     * "Delete filesystem job submitted - Array:%s, fileSystem: %s", storage.getSerialNumber(),
     * fileInOut.getFsName()));
     * _logger.info(logMsgBuilder.toString());
     * return BiosCommandResult.createPendingResult();
     * }
     */
/*
     * 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 = getVnxeClient(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) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) ControllerException(com.emc.storageos.volumecontroller.ControllerException)

Example 50 with VNXeException

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

the class VNXeStorageDevice method doSnapshotFS.

@Override
public BiosCommandResult doSnapshotFS(StorageSystem storage, FileDeviceInputOutput args) throws ControllerException {
    _logger.info("creating file system {} snap {} ", args.getFsName(), args.getSnapshotLabel());
    VNXeApiClient apiClient = getVnxeClient(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 the exception", e);
        if (completer != null) {
            completer.error(_dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Create file system snpashot got the 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) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) 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) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) 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