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);
}
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);
}
}
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;
}
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;
}
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);
}
Aggregations