Search in sources :

Example 46 with AuditLogableImpl

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl 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 47 with AuditLogableImpl

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl 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 48 with AuditLogableImpl

use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl 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)

Example 49 with AuditLogableImpl

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

the class HostUpdatesChecker method checkForUpdates.

public HostUpgradeManagerResult checkForUpdates(VDS host) {
    AuditLogable auditLog = new AuditLogableImpl();
    auditLog.setVdsName(host.getName());
    auditLog.setVdsId(host.getId());
    if (!vdsDynamicDao.get(host.getId()).getStatus().isEligibleForOnDemandCheckUpdates()) {
        log.warn("Check for available updates is skipped for host '{}' due to unsupported host status '{}' ", host.getName(), host.getStatus());
        auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_SKIPPED_UNSUPPORTED_STATUS);
        return null;
    }
    HostUpgradeManagerResult updatesResult = null;
    try {
        updatesResult = availableUpdatesFinder.checkForUpdates(host);
        if (updatesResult.isUpdatesAvailable()) {
            List<String> availablePackages = updatesResult.getAvailablePackages();
            String message;
            if (availablePackages.size() > HostUpgradeManager.MAX_NUM_OF_DISPLAYED_UPDATES) {
                message = String.format("%1$s and %2$s others. To see all packages check engine.log.", StringUtils.join(availablePackages.subList(0, HostUpgradeManager.MAX_NUM_OF_DISPLAYED_UPDATES), ", "), availablePackages.size() - HostUpgradeManager.MAX_NUM_OF_DISPLAYED_UPDATES);
            } else {
                message = String.format("found updates for packages %s", StringUtils.join(updatesResult.getAvailablePackages(), ", "));
            }
            auditLog.addCustomValue("Message", message);
        } else {
            auditLog.addCustomValue("Message", "no updates found.");
        }
        auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_FINISHED);
    } catch (IllegalStateException e) {
        log.warn(e.getMessage());
        auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_PROCESS_IS_ALREADY_RUNNING);
    } catch (Exception e) {
        log.error("Failed to check if updates are available for host '{}' with error message '{}'", host.getName(), e.getMessage());
        log.debug("Exception", e);
        auditLog.addCustomValue("Message", StringUtils.defaultString(e.getMessage(), e.getCause() == null ? null : e.getCause().toString()));
        auditLogDirector.log(auditLog, AuditLogType.HOST_AVAILABLE_UPDATES_FAILED);
    }
    if (updatesResult != null && updatesResult.isUpdatesAvailable() != host.isUpdateAvailable()) {
        VdsManager hostManager = resourceManager.getVdsManager(host.getId());
        synchronized (hostManager) {
            hostManager.updateUpdateAvailable(updatesResult.isUpdatesAvailable());
        }
    }
    return updatesResult;
}
Also used : HostUpgradeManagerResult(org.ovirt.engine.core.common.HostUpgradeManagerResult) AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) VdsManager(org.ovirt.engine.core.vdsbroker.VdsManager) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)

Example 50 with AuditLogableImpl

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

the class InstallVdsInternalCommand method runAnsibleHostDeployPlaybook.

private void runAnsibleHostDeployPlaybook(Cluster hostCluster) throws IOException, InterruptedException {
    // TODO: Remove when we remove support for legacy oVirt node:
    if (getVds().getVdsType().equals(VDSType.oVirtVintageNode)) {
        log.warn("Skipping Ansible runner, because it isn't supported for legacy oVirt node.");
        return;
    }
    AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(getVds().getHostName()).variables(new Pair<>("host_deploy_cluster_version", hostCluster.getCompatibilityVersion()), new Pair<>("host_deploy_cluster_name", hostCluster.getName()), new Pair<>("host_deploy_gluster_enabled", hostCluster.supportsGlusterService()), new Pair<>("host_deploy_virt_enabled", hostCluster.supportsVirtService()), new Pair<>("host_deploy_vdsm_port", getVds().getPort()), new Pair<>("host_deploy_override_firewall", getParameters().getOverrideFirewall()), new Pair<>("host_deploy_firewall_type", hostCluster.getFirewallType().name()), new Pair<>("ansible_port", getVds().getSshPort()), new Pair<>("host_deploy_post_tasks", AnsibleConstants.HOST_DEPLOY_POST_TASKS_FILE_PATH), new Pair<>("host_deploy_ovn_tunneling_interface", NetworkUtils.getHostIp(getVds())), new Pair<>("host_deploy_ovn_central", getOvnCentral())).logFileDirectory(VdsDeployBase.HOST_DEPLOY_LOG_DIRECTORY).logFilePrefix("ovirt-host-deploy-ansible").logFileName(getVds().getHostName()).logFileSuffix(getCorrelationId()).playbook(AnsibleConstants.HOST_DEPLOY_PLAYBOOK);
    AuditLogable logable = new AuditLogableImpl();
    logable.setVdsName(getVds().getName());
    logable.setVdsId(getVds().getId());
    logable.setCorrelationId(getCorrelationId());
    auditLogDirector.log(logable, AuditLogType.VDS_ANSIBLE_INSTALL_STARTED);
    AnsibleReturnValue ansibleReturnValue = ansibleExecutor.runCommand(command);
    if (ansibleReturnValue.getAnsibleReturnCode() != AnsibleReturnCode.OK) {
        throw new VdsInstallException(VDSStatus.InstallFailed, String.format("Failed to execute Ansible host-deploy role. Please check logs for more details: %1$s", command.logFile()));
    }
    auditLogDirector.log(logable, AuditLogType.VDS_ANSIBLE_INSTALL_FINISHED);
}
Also used : AuditLogable(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable) AnsibleReturnValue(org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue) AnsibleCommandBuilder(org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder) AuditLogableImpl(org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl) Pair(org.ovirt.engine.core.common.utils.Pair)

Aggregations

AuditLogableImpl (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl)88 AuditLogable (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable)85 AuditLogDirector (org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector)8 AuditLogType (org.ovirt.engine.core.common.AuditLogType)6 Guid (org.ovirt.engine.core.compat.Guid)5 EngineException (org.ovirt.engine.core.common.errors.EngineException)4 HostUpgradeManagerResult (org.ovirt.engine.core.common.HostUpgradeManagerResult)3 ActionReturnValue (org.ovirt.engine.core.common.action.ActionReturnValue)3 AnsibleCommandBuilder (org.ovirt.engine.core.common.utils.ansible.AnsibleCommandBuilder)3 AnsibleReturnValue (org.ovirt.engine.core.common.utils.ansible.AnsibleReturnValue)3 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 StorageDomain (org.ovirt.engine.core.common.businessentities.StorageDomain)2 StorageDomainStatic (org.ovirt.engine.core.common.businessentities.StorageDomainStatic)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 DiskImage (org.ovirt.engine.core.common.businessentities.storage.DiskImage)2 LUNs (org.ovirt.engine.core.common.businessentities.storage.LUNs)2 Event (org.ovirt.engine.core.common.eventqueue.Event)2