Search in sources :

Example 96 with AuditLogable

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

the class AsyncTaskManager method cleanZombieTasks.

private void cleanZombieTasks() {
    long maxTime = DateTime.getNow().addMinutes(-1 * Config.<Integer>getValue(ConfigValues.AsyncTaskZombieTaskLifeInMinutes)).getTime();
    for (SPMTask task : tasks.values()) {
        if (task.getParameters().getDbAsyncTask().getStartTime().getTime() < maxTime) {
            AuditLogable logable = new AuditLogableImpl();
            logable.addCustomValue("CommandName", task.getParameters().getDbAsyncTask().getActionType().toString());
            logable.addCustomValue("Date", task.getParameters().getDbAsyncTask().getStartTime().toString());
            // status
            if (task.getLastTaskStatus().getStatus() != AsyncTaskStatusEnum.finished && task.getLastTaskStatus().getStatus() != AsyncTaskStatusEnum.unknown) {
                // mark it as a zombie task, Will result in failure of the command
                task.setZombieTask(true);
                auditLogDirector.log(logable, AuditLogType.TASK_STOPPING_ASYNC_TASK);
                log.info("Cleaning zombie tasks: Stopping async task '{}' that started at '{}'", task.getParameters().getDbAsyncTask().getActionType(), task.getParameters().getDbAsyncTask().getStartTime());
                task.stopTask(true);
            } else {
                auditLogDirector.log(logable, AuditLogType.TASK_CLEARING_ASYNC_TASK);
                log.info("Cleaning zombie tasks: Clearing async task '{}' that started at '{}'", task.getParameters().getDbAsyncTask().getActionType(), task.getParameters().getDbAsyncTask().getStartTime());
                task.clearAsyncTask(true);
            }
        }
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) SPMTask(org.ovirt.engine.core.bll.tasks.interfaces.SPMTask) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 97 with AuditLogable

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

the class FenceVdsVDSCommand method alertActionSkippedAlreadyInStatus.

/**
 * Alerts when power management stop was skipped because host is already down.
 */
protected void alertActionSkippedAlreadyInStatus() {
    AuditLogable auditLogable = new AuditLogableImpl();
    auditLogable.addCustomValue("HostName", getTargetVds().getName());
    auditLogable.addCustomValue("AgentStatus", getParameters().getAction().getValue());
    auditLogable.addCustomValue("Operation", getParameters().getAction().toString());
    auditLogDirector.log(auditLogable, AuditLogType.VDS_ALREADY_IN_REQUESTED_STATUS);
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 98 with AuditLogable

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

the class FenceVdsVDSCommand method alertPowerManagementStatusFailed.

/**
 * Alerts if power management status failed.
 *
 * @param reason
 *            The reason.
 */
protected void alertPowerManagementStatusFailed(String reason) {
    AuditLogable alert = new AuditLogableImpl();
    alert.setVdsId(getParameters().getTargetVdsID());
    alert.setVdsName(getTargetVds().getName());
    alert.addCustomValue("Reason", reason);
    auditLogDirector.log(alert, AuditLogType.VDS_ALERT_FENCE_TEST_FAILED);
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 99 with AuditLogable

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

the class ExternalNetworkManager method deallocateIfExternal.

/**
 * Deallocate the vNIC from the external network, if it's attached to a network and the network is indeed an
 * external network (otherwise, nothing is done).
 */
public void deallocateIfExternal() {
    if (getNetwork() != null && getNetwork().isExternal()) {
        Provider<?> provider = providerDao.get(getNetwork().getProvidedBy().getProviderId());
        NetworkProviderProxy providerProxy = providerProxyFactory.create(provider);
        try {
            providerProxy.deallocate(nic);
        } catch (EngineException e) {
            AuditLogable removePortFailureEvent = new AuditLogableImpl();
            removePortFailureEvent.addCustomValue("NicName", nic.getName());
            removePortFailureEvent.addCustomValue("NicId", nic.getId().toString());
            removePortFailureEvent.addCustomValue("ProviderName", provider.getName());
            auditLogDirector.log(removePortFailureEvent, AuditLogType.REMOVE_PORT_FROM_EXTERNAL_PROVIDER_FAILED);
        }
    }
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) EngineException(org.ovirt.engine.core.common.errors.EngineException) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) NetworkProviderProxy(org.ovirt.engine.core.bll.provider.network.NetworkProviderProxy)

Example 100 with AuditLogable

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

the class NetworkConfigurator method findNicToSetupManagementNetwork.

private VdsNetworkInterface findNicToSetupManagementNetwork() {
    VdsNetworkInterface nic = Entities.entitiesByName(host.getInterfaces()).get(host.getActiveNic());
    if (nic == null) {
        log.warn("Failed to find a valid interface for the management network of host {}." + " If the interface {} is a bridge, it should be torn-down manually.", host.getName(), host.getActiveNic());
        throw new NetworkConfiguratorException(String.format("Interface %s is invalid for management network", host.getActiveNic()));
    }
    if (managementNetwork.getName().equals(nic.getNetworkName())) {
        return null;
    }
    if (!nicHasValidVlanId(managementNetwork, nic)) {
        final AuditLogable event = createEvent();
        event.addCustomValue("VlanId", resolveVlanId(nic.getVlanId()));
        event.addCustomValue("MgmtVlanId", resolveVlanId(managementNetwork.getVlanId()));
        event.addCustomValue("InterfaceName", nic.getName());
        auditLogDirector.log(event, AuditLogType.VLAN_ID_MISMATCH_FOR_MANAGEMENT_NETWORK_CONFIGURATION);
        throw new NetworkConfiguratorException(MANAGEMENT_NETWORK_CONFIG_ERR);
    }
    return nic;
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) VdsNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface)

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