use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase in project ovirt-engine by oVirt.
the class RestartVdsVmsOperation method restartVms.
/**
* Changes status of specified VMs to Down and starts HA VMs on another hosts
*
* @param vms list of VM to stopped/restarted
*/
public void restartVms(List<VM> vms) {
List<Guid> autoStartVmIdsToRerun = new ArrayList<>();
// restart all running vms of a failed vds.
for (VM vm : vms) {
destroyVmOnDestination(vm);
VDSReturnValue returnValue = Backend.getInstance().getResourceManager().runVdsCommand(VDSCommandType.SetVmStatus, new SetVmStatusVDSCommandParameters(vm.getId(), VMStatus.Down, VmExitStatus.Error));
// Write that this VM was shut down by host reboot or manual fence
if (returnValue != null && returnValue.getSucceeded()) {
Injector.get(AuditLogDirector.class).log(Injector.injectMembers(new AuditLogableBase(vds.getId(), vm.getId())), AuditLogType.VM_WAS_SET_DOWN_DUE_TO_HOST_REBOOT_OR_MANUAL_FENCE);
}
Backend.getInstance().runInternalAction(ActionType.ProcessDownVm, new ProcessDownVmParameters(vm.getId(), true), ExecutionHandler.createDefaultContextForTasks(commandContext));
// Handle highly available VMs
if (vm.isAutoStartup()) {
autoStartVmIdsToRerun.add(vm.getId());
}
}
if (!autoStartVmIdsToRerun.isEmpty()) {
Injector.get(HaAutoStartVmsRunner.class).addVmsToRun(autoStartVmIdsToRerun);
}
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase in project ovirt-engine by oVirt.
the class QuotaManager method consume.
/**
* Consume from quota according to the parameters.
*
* @param parameters
* - Quota consumption parameters
* @return - true if the request was validated and set
*/
public boolean consume(QuotaConsumptionParametersWrapper parameters) throws InvalidQuotaParametersException {
Pair<AuditLogType, AuditLogableBase> auditLogPair = new Pair<>();
auditLogPair.setSecond(parameters.getAuditLogable());
StoragePool storagePool = parameters.getAuditLogable().getStoragePool();
if (storagePool == null) {
throw new InvalidQuotaParametersException("Null storage pool passed to QuotaManager");
}
addStoragePoolToCacheWithLock(storagePool.getId());
lock.readLock().lock();
try {
if (parameters.getStoragePool().getQuotaEnforcementType() != QuotaEnforcementTypeEnum.DISABLED) {
synchronized (storagePoolQuotaMap.get(storagePool.getId())) {
return validateAndCompleteParameters(parameters, auditLogPair) && internalConsumeAndReleaseHandler(parameters, auditLogPair);
}
}
} finally {
lock.readLock().unlock();
getQuotaManagerAuditLogger().auditLog(auditLogPair.getFirst(), auditLogPair.getSecond());
}
return true;
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase in project ovirt-engine by oVirt.
the class RegisterVdsQuery method reportClusterError.
private void reportClusterError() {
log.error("No default or valid cluster was found, host registration failed.");
AuditLogableBase logableBase = Injector.injectMembers(new AuditLogableBase());
logableBase.setVdsId(getParameters().getVdsId());
auditLogDirector.log(logableBase, AuditLogType.HOST_REGISTRATION_FAILED_INVALID_CLUSTER);
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase in project ovirt-engine by oVirt.
the class RegisterVdsQuery method validateInputs.
@Override
protected boolean validateInputs() {
if (!super.validateInputs()) {
return false;
}
QueryReturnValue returnValue = getQueryReturnValue();
returnValue.setExceptionString("");
try {
String hostName = getParameters().getVdsHostName();
if (StringUtils.isEmpty(hostName)) {
returnValue.setExceptionString("Cannot register Host - no Hostname address specified.");
return false;
}
String vdsUniqueId = getParameters().getVdsUniqueId();
if (StringUtils.isEmpty(vdsUniqueId)) {
returnValue.setExceptionString(String.format("Cannot register host '%1$s' - host id is empty.", hostName));
AuditLogableBase logable = Injector.injectMembers(new AuditLogableBase());
logable.addCustomValue("VdsHostName", hostName);
auditLogDirector.log(logable, AuditLogType.VDS_REGISTER_EMPTY_ID);
return false;
}
List<VDS> vdssByUniqueId = getVdssByUniqueId();
if (vdssByUniqueId.size() > 1) {
returnValue.setExceptionString("Cannot register Host - unique id is ambigious.");
return false;
}
if (vdssByUniqueId.size() == 1) {
VDS vds = vdssByUniqueId.get(0);
if (!VdsHandler.isPendingOvirt(vds)) {
returnValue.setExceptionString(EngineMessage.VDS_STATUS_NOT_VALID_FOR_UPDATE.name());
return false;
}
}
} catch (RuntimeException ex) {
log.error("Exception", ex);
returnValue.setExceptionString(String.format("Cannot register Host - An exception has been thrown: %1$s", ex.getMessage()));
return false;
}
return true;
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase in project ovirt-engine by oVirt.
the class ConnectStorageServerVDSCommand method logFailedStorageConnections.
private void logFailedStorageConnections(Map<String, String> returnValue) {
StringBuilder failedDomainNames = new StringBuilder();
String namesSeparator = ",";
for (Entry<String, String> result : returnValue.entrySet()) {
if (!"0".equals(result.getValue())) {
List<StorageDomain> domains = DbFacade.getInstance().getStorageDomainDao().getAllByConnectionId(new Guid(result.getKey()));
if (!domains.isEmpty()) {
for (StorageDomain domain : domains) {
if (failedDomainNames.length() > 0) {
failedDomainNames.append(namesSeparator);
}
failedDomainNames.append(domain.getStorageName());
}
}
}
}
if (failedDomainNames.length() > 0) {
AuditLogableBase logable = Injector.injectMembers(new AuditLogableBase(getParameters().getVdsId()));
logable.addCustomValue("failedStorageDomains", failedDomainNames.toString());
auditLogDirector.log(logable, AuditLogType.VDS_STORAGES_CONNECTION_FAILED);
}
}
Aggregations