Search in sources :

Example 1 with VNXeFSSupportedProtocolEnum

use of com.emc.storageos.vnxe.models.VNXeFSSupportedProtocolEnum 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 2 with VNXeFSSupportedProtocolEnum

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

the class VNXUnityFileStorageDevice 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 = getVnxUnityClient(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("The protocol is not supported: " + protocols);
            ServiceError error = DeviceControllerErrors.vnxe.unableToCreateFileSystem("The protocol is not supported:" + 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 an exception", e);
        if (completer != null) {
            completer.error(dbClient, e);
        }
        return BiosCommandResult.createErrorResult(e);
    } catch (Exception ex) {
        _logger.error("Create file system got an 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) 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)

Aggregations

FileShare (com.emc.storageos.db.client.model.FileShare)2 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)2 StorageHADomain (com.emc.storageos.db.client.model.StorageHADomain)2 StoragePort (com.emc.storageos.db.client.model.StoragePort)2 StringSet (com.emc.storageos.db.client.model.StringSet)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 VNXeFSSupportedProtocolEnum (com.emc.storageos.vnxe.models.VNXeFSSupportedProtocolEnum)2 ControllerException (com.emc.storageos.volumecontroller.ControllerException)2 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)2 VNXeCreateFileSystemJob (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeCreateFileSystemJob)2 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)2 URI (java.net.URI)2 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)1