Search in sources :

Example 86 with VNXeApiClient

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

the class VNXeStorageDevice method doDeleteConsistencyGroup.

@Override
public void doDeleteConsistencyGroup(StorageSystem storage, URI consistencyGroupId, String replicationGroupName, Boolean keepRGName, Boolean markInactive, TaskCompleter taskCompleter) throws DeviceControllerException {
    _logger.info("Deleting consistency group, array: {}", storage.getSerialNumber());
    BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupId);
    // check if lungroup has been created in the array
    String lunGroupId = consistencyGroup.getCgNameOnStorageSystem(storage.getId());
    if (lunGroupId == null || lunGroupId.isEmpty()) {
        _logger.error("The consistency group does not exist in the array: {}", storage.getSerialNumber());
        taskCompleter.error(_dbClient, DeviceControllerException.exceptions.consistencyGroupNotFound(consistencyGroup.getLabel(), consistencyGroup.getCgNameOnStorageSystem(storage.getId())));
        return;
    }
    VNXeApiClient apiClient = getVnxeClient(storage);
    try {
        apiClient.deleteLunGroup(lunGroupId, false, false);
        if (keepRGName) {
            taskCompleter.ready(_dbClient);
            return;
        }
        // Clean up the system consistency group references
        BlockConsistencyGroupUtils.cleanUpCGAndUpdate(consistencyGroup, storage.getId(), lunGroupId, markInactive, _dbClient);
        _logger.info("Consistency group {} deleted", consistencyGroup.getLabel());
        taskCompleter.ready(_dbClient);
    } catch (Exception e) {
        _logger.info("Failed to delete consistency group: " + e);
        // Set task to error
        ServiceError error = DeviceControllerErrors.vnxe.jobFailed("doDeleteConsistencyGroup", e.getMessage());
        taskCompleter.error(_dbClient, error);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) 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 87 with VNXeApiClient

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

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

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

the class VNXeExportMaskInitiatorsValidator method validate.

/**
 * Get list of initiators associated with the host.
 * If there are unknown initiators on the host, fail the validation
 */
@Override
public boolean validate() throws Exception {
    log.info("Initiating initiator validation of VNXe ExportMask: " + getId());
    DbClient dbClient = getDbClient();
    VNXeApiClient apiClient = getApiClient();
    ExportMask exportMask = getExportMask();
    try {
        // Don't validate against backing masks or RP
        if (ExportMaskUtils.isBackendExportMask(getDbClient(), exportMask)) {
            log.info("validation against backing mask for VPLEX or RP is disabled.");
            return true;
        }
        // all initiators of VNXe host should be on single ViPR host, or unknown to ViPR
        String vnxeHostId = getHostId();
        if (vnxeHostId == null) {
            return true;
        }
        List<VNXeHostInitiator> initiatorList = apiClient.getInitiatorsByHostId(vnxeHostId);
        URI hostId = null;
        if (initiatorList != null) {
            for (VNXeHostInitiator initiator : initiatorList) {
                String portWWN = null;
                if (HostInitiatorTypeEnum.INITIATOR_TYPE_ISCSI.equals(initiator.getType())) {
                    portWWN = initiator.getInitiatorId();
                } else {
                    portWWN = initiator.getPortWWN();
                }
                Initiator viprInitiator = NetworkUtil.findInitiatorInDB(portWWN, dbClient);
                if (viprInitiator != null) {
                    if (NullColumnValueGetter.isNullURI(hostId)) {
                        hostId = viprInitiator.getHost();
                    } else if (!hostId.equals(viprInitiator.getHost())) {
                        log.info("Initiator {} belongs to different host", portWWN);
                        setRemediation(misMatchInitiatorRemediation);
                        getLogger().logDiff(exportMask.getId().toString(), "initiators", ValidatorLogger.NO_MATCHING_ENTRY, portWWN);
                        break;
                    }
                } else {
                    // initiator not found in ViPR
                    log.info("Unknown initiator found: {}", portWWN);
                    setRemediation(unknownInitiatorRemediation);
                    getLogger().logDiff(exportMask.getId().toString(), "initiators", ValidatorLogger.NO_MATCHING_ENTRY, portWWN);
                    break;
                }
            }
        }
    } catch (Exception ex) {
        log.error("Unexpected exception validating ExportMask initiators: " + ex.getMessage(), ex);
        if (getConfig().isValidationEnabled()) {
            throw DeviceControllerException.exceptions.unexpectedCondition("Unexpected exception validating ExportMask initiators: " + ex.getMessage());
        }
    }
    checkForErrors();
    log.info("Completed initiator validation of VNXe ExportMask: " + getId());
    return true;
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) Initiator(com.emc.storageos.db.client.model.Initiator) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) ExportMask(com.emc.storageos.db.client.model.ExportMask) VNXeHostInitiator(com.emc.storageos.vnxe.models.VNXeHostInitiator) URI(java.net.URI) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Example 90 with VNXeApiClient

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

the class VNXeExportMaskVolumesValidator method validate.

@Override
public boolean validate() throws Exception {
    log.info("Initiating volume validation of VNXe ExportMask: " + getId());
    DbClient dbClient = getDbClient();
    VNXeApiClient apiClient = getApiClient();
    ExportMask exportMask = getExportMask();
    try {
        String vnxeHostId = getHostId();
        if (vnxeHostId != null) {
            VNXeHost vnxeHost = apiClient.getHostById(vnxeHostId);
            if (vnxeHost != null) {
                Set<String> lunIds = ExportUtils.getAllLUNsForHost(dbClient, exportMask);
                Set<String> lunIdsOnArray = apiClient.getHostLUNIds(vnxeHostId);
                lunIdsOnArray.removeAll(lunIds);
                if (!lunIdsOnArray.isEmpty()) {
                    String unknownLUNs = Joiner.on(',').join(lunIdsOnArray);
                    log.info("Unknown LUN/LUN Snap {}", unknownLUNs);
                    getLogger().logDiff(exportMask.getId().toString(), "volumes", ValidatorLogger.NO_MATCHING_ENTRY, unknownLUNs);
                }
            }
        }
    } catch (Exception ex) {
        log.error("Unexpected exception validating ExportMask volumes: " + ex.getMessage(), ex);
        throw DeviceControllerException.exceptions.unexpectedCondition("Unexpected exception validating ExportMask volumes: " + ex.getMessage());
    }
    setRemediation(unknownLUNRemediation);
    checkForErrors();
    log.info("Completed volume validation of VNXe ExportMask: " + getId());
    return true;
}
Also used : DbClient(com.emc.storageos.db.client.DbClient) VNXeApiClient(com.emc.storageos.vnxe.VNXeApiClient) ExportMask(com.emc.storageos.db.client.model.ExportMask) VNXeHost(com.emc.storageos.vnxe.models.VNXeHost) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException)

Aggregations

VNXeApiClient (com.emc.storageos.vnxe.VNXeApiClient)123 VNXeException (com.emc.storageos.vnxe.VNXeException)79 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)66 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)55 VNXeCommandJob (com.emc.storageos.vnxe.models.VNXeCommandJob)48 ControllerException (com.emc.storageos.volumecontroller.ControllerException)44 QueueJob (com.emc.storageos.volumecontroller.impl.job.QueueJob)40 URI (java.net.URI)37 ArrayList (java.util.ArrayList)34 FileShare (com.emc.storageos.db.client.model.FileShare)33 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)33 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)30 Snapshot (com.emc.storageos.db.client.model.Snapshot)27 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)24 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)23 DbClient (com.emc.storageos.db.client.DbClient)21 Volume (com.emc.storageos.db.client.model.Volume)18 VNXeFileTaskCompleter (com.emc.storageos.volumecontroller.impl.vnxe.job.VNXeFileTaskCompleter)18 FileExport (com.emc.storageos.db.client.model.FileExport)14 HashMap (java.util.HashMap)14