use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl in project ovirt-engine by oVirt.
the class InstallerMessages method post.
public void post(Severity severity, String text) {
AuditLogType logType;
AuditLogable logable = new AuditLogableImpl();
logable.setVdsId(_vds.getId());
logable.setVdsName(_vds.getName());
logable.setCorrelationId(_correlationId);
logable.addCustomValue("Message", text);
switch(severity) {
case INFO:
logType = AuditLogType.VDS_INSTALL_IN_PROGRESS;
log.info("Installation '{}': {}", _vds.getHostName(), text);
break;
default:
case WARNING:
logType = AuditLogType.VDS_INSTALL_IN_PROGRESS_WARNING;
log.warn("Installation '{}': {}", _vds.getHostName(), text);
break;
case ERROR:
logType = AuditLogType.VDS_INSTALL_IN_PROGRESS_ERROR;
log.error("Installation '{}': {}", _vds.getHostName(), text);
break;
}
Injector.get(AuditLogDirector.class).log(logable, logType);
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl in project ovirt-engine by oVirt.
the class HostUpgradeManager method checkForUpdates.
@Override
public HostUpgradeManagerResult checkForUpdates(final VDS host) {
AnsibleReturnValue ansibleReturnValue = null;
try {
AnsibleCommandBuilder command = new AnsibleCommandBuilder().hostnames(host.getHostName()).checkMode(true).enableLogging(false).verboseLevel(AnsibleVerbosity.LEVEL0).stdoutCallback(AnsibleConstants.HOST_UPGRADE_CALLBACK_PLUGIN).playbook(AnsibleConstants.HOST_UPGRADE_PLAYBOOK);
ansibleReturnValue = ansibleExecutor.runCommand(command);
if (ansibleReturnValue.getAnsibleReturnCode() != AnsibleReturnCode.OK) {
String error = String.format("Failed to run check-update of host '%1$s'.", host.getHostName());
log.error(error);
throw new RuntimeException(error);
}
List<String> availablePackages = JsonHelper.jsonToList(ansibleReturnValue.getStdout());
boolean updatesAvailable = !availablePackages.isEmpty();
HostUpgradeManagerResult hostUpgradeManagerResult = new HostUpgradeManagerResult();
hostUpgradeManagerResult.setUpdatesAvailable(updatesAvailable);
if (updatesAvailable) {
hostUpgradeManagerResult.setAvailablePackages(availablePackages);
log.info("There are available package updates ({}) for host '{}'", StringUtils.join(availablePackages, ", "), host.getHostName());
AuditLogable auditLog = new AuditLogableImpl();
auditLog.setVdsId(host.getId());
auditLog.setVdsName(host.getName());
if (availablePackages.isEmpty()) {
auditLogDirector.log(auditLog, AuditLogType.HOST_UPDATES_ARE_AVAILABLE);
} else {
if (availablePackages.size() > MAX_NUM_OF_DISPLAYED_UPDATES) {
auditLog.addCustomValue("Packages", String.format("%1$s and %2$s others. To see all packages check engine.log.", StringUtils.join(availablePackages.subList(0, MAX_NUM_OF_DISPLAYED_UPDATES), ", "), availablePackages.size() - MAX_NUM_OF_DISPLAYED_UPDATES));
} else {
auditLog.addCustomValue("Packages", StringUtils.join(availablePackages, ", "));
}
auditLogDirector.log(auditLog, AuditLogType.HOST_UPDATES_ARE_AVAILABLE_WITH_PACKAGES);
}
}
return hostUpgradeManagerResult;
} catch (final IOException e) {
log.error("Failed to read host packages: {}", e.getMessage());
if (ansibleReturnValue != null) {
log.debug("Ansible packages output: {}", ansibleReturnValue.getStdout());
}
throw new RuntimeException(e.getMessage(), e);
} catch (final Exception e) {
throw new RuntimeException(e.getMessage(), e);
}
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl in project ovirt-engine by oVirt.
the class OvirtNodeUpgradeManager method checkForUpdates.
@Override
public HostUpgradeManagerResult checkForUpdates(VDS host) {
QueryReturnValue returnValue = backendInternal.runInternalQuery(QueryType.GetoVirtISOs, new IdQueryParameters(host.getId()));
List<RpmVersion> isos = returnValue.getReturnValue();
boolean updateAvailable = RpmVersionUtils.isUpdateAvailable(isos, host.getHostOs());
HostUpgradeManagerResult hostUpgradeManagerResult = new HostUpgradeManagerResult();
hostUpgradeManagerResult.setUpdatesAvailable(updateAvailable);
if (updateAvailable) {
AuditLogable auditLog = new AuditLogableImpl();
auditLog.setVdsName(host.getName());
auditLog.setVdsId(host.getId());
auditLog.setClusterName(host.getClusterName());
auditLog.setClusterId(host.getClusterId());
auditLogDirector.log(auditLog, AuditLogType.HOST_UPDATES_ARE_AVAILABLE);
}
return hostUpgradeManagerResult;
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl in project ovirt-engine by oVirt.
the class MetadataDiskDescriptionHandler method createDiskEvent.
private AuditLogable createDiskEvent(String diskAlias) {
AuditLogable logable = new AuditLogableImpl();
logable.addCustomValue("DiskAlias", diskAlias);
return logable;
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableImpl in project ovirt-engine by oVirt.
the class BlockStorageDomainHelper method checkDomainMetadataDevices.
public boolean checkDomainMetadataDevices(StorageDomain domain) {
if (domain.getVgMetadataDevice() == null || domain.getFirstMetadataDevice() == null) {
AuditLogable logable = new AuditLogableImpl();
logable.setStorageDomainName(domain.getName());
logable.setStorageDomainId(domain.getId());
auditLogDirector.log(logable, AuditLogType.FAILED_DETERMINE_STORAGE_DOMAIN_METADATA_DEVICES);
return false;
}
return true;
}
Aggregations