use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.
the class IrsProxy method proceedStorageDomain.
private boolean proceedStorageDomain(StorageDomain domainFromVdsm, int dataMasterVersion, StoragePool storagePool) {
StorageDomain storage_domain = storageDomainDao.getForStoragePool(domainFromVdsm.getId(), storagePoolId);
if (storage_domain != null) {
StorageDomainStatic domainFromDb = storage_domain.getStorageStaticData();
StoragePoolIsoMap domainPoolMapFromDb = storage_domain.getStoragePoolIsoMapData();
// If the domain is master in the DB
if (domainFromDb.getStorageDomainType() == StorageDomainType.Master && domainPoolMapFromDb != null && domainPoolMapFromDb.getStatus() != StorageDomainStatus.Locked) {
// and the domain is not master in the VDSM
if (!((domainFromVdsm.getStorageDomainType() == StorageDomainType.Master) || (domainFromVdsm.getStorageDomainType() == StorageDomainType.Unknown))) {
reconstructMasterDomainNotInSync(domainFromVdsm.getStoragePoolId(), domainFromDb, "Mismatch between master in DB and VDSM", MessageFormat.format("Master domain is not in sync between DB and VDSM. " + "Domain {0} marked as master in DB and not in the storage", domainFromDb.getStorageName()));
} else // mismatch
if (dataMasterVersion != storagePool.getMasterDomainVersion()) {
reconstructMasterDomainNotInSync(domainFromVdsm.getStoragePoolId(), domainFromDb, "Mismatch between master version in DB and VDSM", MessageFormat.format("Master domain version is not in sync between DB and VDSM. " + "Domain {0} marked as master, but the version in DB: {1} and in VDSM: {2}", domainFromDb.getStorageName(), storagePool.getMasterDomainVersion(), dataMasterVersion));
}
}
boolean statusChanged = false;
if (domainPoolMapFromDb == null) {
domainFromVdsm.setStoragePoolId(storagePoolId);
storagePoolIsoMapDao.save(domainFromVdsm.getStoragePoolIsoMapData());
statusChanged = true;
} else if (!domainPoolMapFromDb.getStatus().isStorageDomainInProcess() && domainPoolMapFromDb.getStatus() != domainFromVdsm.getStatus()) {
if (domainPoolMapFromDb.getStatus() != StorageDomainStatus.Inactive && domainFromVdsm.getStatus() != StorageDomainStatus.Inactive) {
storagePoolIsoMapDao.update(domainFromVdsm.getStoragePoolIsoMapData());
statusChanged = true;
}
if (domainFromVdsm.getStatus() != null && domainFromVdsm.getStatus() == StorageDomainStatus.Inactive && domainFromDb.getStorageDomainType() == StorageDomainType.Master) {
StoragePool pool = storagePoolDao.get(domainPoolMapFromDb.getStoragePoolId());
if (pool != null) {
storagePoolDao.updateStatus(pool.getId(), StoragePoolStatus.Maintenance);
pool.setStatus(StoragePoolStatus.Maintenance);
getEventListener().storagePoolStatusChanged(pool.getId(), StoragePoolStatus.Maintenance);
}
}
}
// update dynamic data
if (statusChanged || (domainPoolMapFromDb.getStatus() != StorageDomainStatus.Inactive && domainFromVdsm.getStatus() == StorageDomainStatus.Active)) {
storageDomainDynamicDao.update(domainFromVdsm.getStorageDynamicData());
if (domainFromVdsm.getAvailableDiskSize() != null && domainFromVdsm.getUsedDiskSize() != null) {
double freePercent = domainFromVdsm.getStorageDynamicData().getfreeDiskPercent();
AuditLogType type = AuditLogType.UNASSIGNED;
Integer freeDiskInGB = domainFromVdsm.getStorageDynamicData().getAvailableDiskSize();
if (freeDiskInGB != null) {
if (freePercent < domainFromDb.getWarningLowSpaceIndicator()) {
type = AuditLogType.IRS_DISK_SPACE_LOW;
}
if (freeDiskInGB < domainFromDb.getCriticalSpaceActionBlocker()) {
// Note, if both conditions are met, only IRS_DISK_SPACE_LOW_ERROR will be shown
type = AuditLogType.IRS_DISK_SPACE_LOW_ERROR;
}
}
if (type != AuditLogType.UNASSIGNED) {
AuditLogable logable = new AuditLogableImpl();
logable.setStorageDomainName(domainFromDb.getStorageName());
logable.addCustomValue("DiskSpace", domainFromVdsm.getAvailableDiskSize().toString());
domainFromVdsm.setStorageName(domainFromDb.getStorageName());
auditLogDirector.log(logable, type);
}
}
Set<EngineError> alerts = domainFromVdsm.getAlerts();
if (alerts != null && !alerts.isEmpty()) {
AuditLogable logable = new AuditLogableImpl();
logable.setStorageDomainName(domainFromDb.getStorageName());
domainFromVdsm.setStorageName(domainFromDb.getStorageName());
for (EngineError alert : alerts) {
switch(alert) {
case VG_METADATA_CRITICALLY_FULL:
auditLogDirector.log(logable, AuditLogType.STORAGE_ALERT_VG_METADATA_CRITICALLY_FULL);
break;
case SMALL_VG_METADATA:
auditLogDirector.log(logable, AuditLogType.STORAGE_ALERT_SMALL_VG_METADATA);
break;
default:
log.error("Unrecognized alert for domain {}(id = {}): {}", domainFromVdsm.getStorageName(), domainFromVdsm.getId(), alert);
break;
}
}
}
}
// Block domains should have their LUNs synchronized and updated in the DB.
if (statusChanged && domainFromVdsm.getStatus() == StorageDomainStatus.Active && storage_domain.getStorageType().isBlockDomain()) {
return true;
}
} else {
log.debug("The domain with id '{}' was not found in DB", domainFromVdsm.getId());
}
return false;
}
use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.
the class VmAnalyzer method auditVmPausedError.
private void auditVmPausedError(VmDynamic vdsmVmDynamic) {
AuditLogType logType = vmPauseStatusToAuditLogType(vdsmVmDynamic.getPauseStatus());
AuditLogableBase logable = Injector.injectMembers(new AuditLogableBase(vdsManager.getVdsId(), dbVm.getId()));
auditLog(logable, logType);
}
use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.
the class VmAnalyzer method auditVmSuspended.
private void auditVmSuspended() {
VmDynamic vm = vdsmVm.getVmDynamic();
AuditLogType type = vm.getExitStatus() == VmExitStatus.Normal ? AuditLogType.USER_SUSPEND_VM_OK : AuditLogType.USER_FAILED_SUSPEND_VM;
AuditLogableBase logable = Injector.injectMembers(new AuditLogableBase(vdsManager.getVdsId(), vm.getId()));
auditLog(logable, type);
}
use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.
the class CreateSnapshotFromTemplateCommand method addAuditLogOnRemoveFailure.
private void addAuditLogOnRemoveFailure() {
addCustomValue("DiskAlias", getParameters().getDiskAlias());
AuditLogType logType = AuditLogType.USER_COPY_IMAGE_GROUP_FAILED_TO_DELETE_DST_IMAGE;
auditLogDirector.log(this, logType);
}
use of org.ovirt.engine.core.common.AuditLogType in project ovirt-engine by oVirt.
the class GlusterTasksSyncJob method logTaskStartedFromCLI.
private void logTaskStartedFromCLI(Cluster cluster, GlusterAsyncTask task, GlusterVolumeEntity vol) {
Map<String, String> values = new HashMap<>();
AuditLogType logType;
switch(task.getType()) {
case REBALANCE:
logType = AuditLogType.GLUSTER_VOLUME_REBALANCE_START_DETECTED_FROM_CLI;
break;
case REMOVE_BRICK:
logType = AuditLogType.START_REMOVING_GLUSTER_VOLUME_BRICKS_DETECTED_FROM_CLI;
values.put(GlusterConstants.BRICK, StringUtils.join(task.getTaskParameters().getBricks(), ','));
break;
default:
logType = AuditLogType.UNASSIGNED;
break;
}
logUtil.logAuditMessage(cluster.getId(), cluster.getName(), vol, null, logType, values);
}
Aggregations