Search in sources :

Example 61 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class ResourceManager method setVmUnknown.

/**
 * Set vm status to Unknown and save to DB.
 */
public void setVmUnknown(VM vm) {
    removeAsyncRunningVm(vm.getId());
    internalSetVmStatus(vm.getDynamicData(), VMStatus.Unknown);
    // log VM transition to unknown status
    AuditLogable logable = new AuditLogableImpl();
    logable.setVmId(vm.getId());
    logable.setVmName(vm.getName());
    auditLogDirector.log(logable, AuditLogType.VM_SET_TO_UNKNOWN_STATUS);
    storeVm(vm);
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 62 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class SetVdsStatusVDSCommand method executeVdsIdCommand.

@Override
protected void executeVdsIdCommand() {
    final SetVdsStatusVDSCommandParameters parameters = getParameters();
    if (_vdsManager != null) {
        final VDS vds = getVds();
        if (vds.getSpmStatus() != VdsSpmStatus.None && parameters.getStatus() != VDSStatus.Up) {
            log.info("VDS '{}' is spm and moved from up calling resetIrs.", vds.getName());
            // check if this host was spm and reset if do.
            getVDSReturnValue().setSucceeded(resourceManager.runVdsCommand(VDSCommandType.ResetIrs, new ResetIrsVDSCommandParameters(vds.getStoragePoolId(), vds.getId())).getSucceeded());
            if (!getVDSReturnValue().getSucceeded()) {
                if (getParameters().isStopSpmFailureLogged()) {
                    AuditLogable base = new AuditLogableImpl();
                    base.setVdsId(vds.getId());
                    base.setVdsName(vds.getName());
                    auditLogDirector.log(base, AuditLogType.VDS_STATUS_CHANGE_FAILED_DUE_TO_STOP_SPM_FAILURE);
                }
                if (parameters.getStatus() == VDSStatus.PreparingForMaintenance) {
                    // ResetIrs command failed, SPM host status cannot be moved to Preparing For Maintenance
                    return;
                }
            }
        }
        TransactionSupport.executeInNewTransaction(() -> {
            _vdsManager.setStatus(parameters.getStatus(), vds);
            _vdsManager.updatePartialDynamicData(parameters.getNonOperationalReason(), parameters.getMaintenanceReason());
            _vdsManager.updateStatisticsData(vds.getStatisticsData());
            return null;
        });
    } else {
        getVDSReturnValue().setSucceeded(false);
    }
}
Also used : SetVdsStatusVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.SetVdsStatusVDSCommandParameters) VDS(org.ovirt.engine.core.common.businessentities.VDS) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) ResetIrsVDSCommandParameters(org.ovirt.engine.core.common.vdscommands.ResetIrsVDSCommandParameters) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 63 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class VdsManager method handleVdsRecoveringException.

private void handleVdsRecoveringException(VDSRecoveringException ex) {
    if (cachedVds.getStatus() != VDSStatus.Initializing && cachedVds.getStatus() != VDSStatus.NonOperational) {
        setStatus(VDSStatus.Initializing, cachedVds);
        vdsDynamicDao.updateStatus(cachedVds.getId(), VDSStatus.Initializing);
        AuditLogable logable = createAuditLogableForHost(cachedVds);
        logable.addCustomValue("ErrorMessage", ex.getMessage());
        logable.updateCallStackFromThrowable(ex);
        auditLogDirector.log(logable, AuditLogType.VDS_INITIALIZING);
        log.warn("Failed to refresh VDS, continuing, vds='{}'({}): {}", cachedVds.getName(), cachedVds.getId(), ex.getMessage());
        log.debug("Exception", ex);
        final long VDS_RECOVERY_TIMEOUT_IN_MINUTES = Config.<Long>getValue(ConfigValues.VdsRecoveryTimeoutInMinutes);
        ScheduledFuture scheduled = executor.schedule(this::handleVdsRecovering, VDS_RECOVERY_TIMEOUT_IN_MINUTES, TimeUnit.MINUTES);
        recoveringJobIdMap.put(cachedVds.getId(), scheduled);
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) ScheduledFuture(java.util.concurrent.ScheduledFuture)

Example 64 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class VdsManager method processRefreshCapabilitiesResponse.

public VDSStatus processRefreshCapabilitiesResponse(AtomicBoolean processHardwareCapsNeeded, VDS vds, VDS oldVDS, VDSReturnValue caps) {
    if (caps.getSucceeded()) {
        // hence warning in case of permissive as well.
        if (vds.getSELinuxEnforceMode() == null || vds.getSELinuxEnforceMode().equals(SELinuxMode.DISABLED) || (vds.getClusterSupportsGlusterService() && vds.getSELinuxEnforceMode().equals(SELinuxMode.PERMISSIVE))) {
            AuditLogable auditLogable = createAuditLogableForHost(vds);
            auditLogable.addCustomValue("Mode", vds.getSELinuxEnforceMode() == null ? "UNKNOWN" : vds.getSELinuxEnforceMode().name());
            auditLogDirector.log(auditLogable, AuditLogType.VDS_NO_SELINUX_ENFORCEMENT);
            if (vds.getSELinuxEnforceMode() != null) {
                log.warn("Host '{}' is running with SELinux in '{}' mode", vds.getName(), vds.getSELinuxEnforceMode());
            } else {
                log.warn("Host '{}' does not report SELinux enforcement information.", vds.getName());
            }
        }
        VDSStatus returnStatus = vds.getStatus();
        NonOperationalReason nonOperationalReason = getHostNetworkTopologyPersister().persistAndEnforceNetworkCompliance(vds);
        if (nonOperationalReason != NonOperationalReason.NONE) {
            setIsSetNonOperationalExecuted(true);
            if (returnStatus != VDSStatus.NonOperational) {
                log.debug("monitoring: vds '{}' networks do not match its cluster networks, vds will be moved to NonOperational", vds);
                vds.setStatus(VDSStatus.NonOperational);
                vds.setNonOperationalReason(nonOperationalReason);
            }
        }
        // We process the software capabilities.
        VDSStatus oldStatus = vds.getStatus();
        if (oldStatus != VDSStatus.Up) {
            // persist to db the host's cpu_flags.
            // TODO this needs to be revisited - either all the logic is in-memory or based on db
            vdsDynamicDao.updateCpuFlags(vds.getId(), vds.getCpuFlags());
            processHostFeaturesReported(vds);
            monitoringStrategy.processHardwareCapabilities(vds);
        }
        monitoringStrategy.processSoftwareCapabilities(vds);
        returnStatus = vds.getStatus();
        if (returnStatus != oldStatus && returnStatus == VDSStatus.NonOperational) {
            setIsSetNonOperationalExecuted(true);
        }
        processHardwareCapsNeeded.set(monitoringStrategy.processHardwareCapabilitiesNeeded(oldVDS, vds));
        return returnStatus;
    } else if (caps.getExceptionObject() != null) {
        throw caps.getExceptionObject();
    } else {
        log.error("refreshCapabilities:GetCapabilitiesVDSCommand failed with no exception!");
        throw new RuntimeException(caps.getExceptionString());
    }
}
Also used : VDSStatus(org.ovirt.engine.core.common.businessentities.VDSStatus) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) NonOperationalReason(org.ovirt.engine.core.common.businessentities.NonOperationalReason)

Example 65 with AuditLogable

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.

the class VdsManager method createAuditLogableForHost.

private AuditLogable createAuditLogableForHost(VDS vds) {
    AuditLogable logable = new AuditLogableImpl();
    logable.setVdsId(vds.getId());
    logable.setVdsName(vds.getName());
    return logable;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Aggregations

AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)126 AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)86 AuditLogType (org.ovirt.engine.core.common.AuditLogType)10 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)9 Guid (org.ovirt.engine.core.compat.Guid)8 VdsNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)6 ArrayList (java.util.ArrayList)5 Date (java.util.Date)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Map (java.util.Map)3 Collectors (java.util.stream.Collectors)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 VDS (org.ovirt.engine.core.common.businessentities.VDS)3 EngineException (org.ovirt.engine.core.common.errors.EngineException)3 HashSet (java.util.HashSet)2 Inject (javax.inject.Inject)2 Singleton (javax.inject.Singleton)2 HostUpgradeManagerResult (org.ovirt.engine.core.common.HostUpgradeManagerResult)2 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)2