Federico Simoncelli has uploaded a new change for review. Change subject: backend: add audit logs for glance import ......................................................................
backend: add audit logs for glance import Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1005481 Change-Id: Ief70939697b5c9d38a850db5a4c9df10798ce1f3 Signed-off-by: Federico Simoncelli <fsimo...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportRepoImageCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java M backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties 4 files changed, 34 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/21/19221/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportRepoImageCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportRepoImageCommand.java index 348e9e1..e7e2183 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportRepoImageCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ImportRepoImageCommand.java @@ -9,6 +9,7 @@ import org.ovirt.engine.core.bll.tasks.SPMAsyncTaskHandler; import org.ovirt.engine.core.bll.tasks.TaskHandlerCommand; import org.ovirt.engine.core.bll.utils.PermissionSubject; +import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.action.ImportRepoImageParameters; import org.ovirt.engine.core.common.action.VdcActionType; @@ -141,16 +142,39 @@ return getParameters().getDiskImage(); } + public String getRepoImageName() { + return getDiskImage() != null ? getDiskImage().getDiskAlias() : ""; + } + @Override public Map<String, String> getJobMessageProperties() { if (jobProperties == null) { jobProperties = super.getJobMessageProperties(); - jobProperties.put("repoimagename", getDiskImage() != null ? getDiskImage().getDiskAlias() : ""); + jobProperties.put("repoimagename", getRepoImageName()); } return jobProperties; } @Override + public AuditLogType getAuditLogTypeValue() { + switch (getActionState()) { + case EXECUTE: + if (!getParameters().getTaskGroupSuccess()) { + return AuditLogType.USER_IMPORT_IMAGE_FINISHED_FAILURE; + } + if (getParameters().getExecutionIndex() == 0 && getSucceeded()) { + return AuditLogType.USER_IMPORT_IMAGE; + } + break; + case END_SUCCESS: + return AuditLogType.USER_IMPORT_IMAGE_FINISHED_SUCCESS; + case END_FAILURE: + return AuditLogType.USER_IMPORT_IMAGE_FINISHED_FAILURE; + } + return AuditLogType.UNASSIGNED; + } + + @Override protected boolean canDoAction() { if (!validate(new StoragePoolValidator(getStoragePool()).isUp())) { return false; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java index 68f2611..d26df0b 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java @@ -186,6 +186,9 @@ USER_ADD_DISK_FINISHED_SUCCESS(2021), USER_ADD_DISK_FINISHED_FAILURE(2022), USER_FAILED_ADD_DISK(2023), + USER_IMPORT_IMAGE(2024), + USER_IMPORT_IMAGE_FINISHED_SUCCESS(2025), + USER_IMPORT_IMAGE_FINISHED_FAILURE(2026), // Used only from SQL script, therefor should not have severity & message USER_RUN_UNLOCK_ENTITY_SCRIPT(2024), USER_MOVE_IMAGE_GROUP_FAILED_TO_DELETE_SRC_IMAGE(2025), diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java index 70cdd28..c12e8ef 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java @@ -456,6 +456,9 @@ severities.put(AuditLogType.DISK_ALIGNMENT_SCAN_START, AuditLogSeverity.NORMAL); severities.put(AuditLogType.DISK_ALIGNMENT_SCAN_FAILURE, AuditLogSeverity.WARNING); severities.put(AuditLogType.DISK_ALIGNMENT_SCAN_SUCCESS, AuditLogSeverity.NORMAL); + severities.put(AuditLogType.USER_IMPORT_IMAGE, AuditLogSeverity.NORMAL); + severities.put(AuditLogType.USER_IMPORT_IMAGE_FINISHED_SUCCESS, AuditLogSeverity.NORMAL); + severities.put(AuditLogType.USER_IMPORT_IMAGE_FINISHED_FAILURE, AuditLogSeverity.ERROR); } private static void initQuotaSeverities() { diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties index 5a78c63..be556b1 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -84,6 +84,9 @@ USER_ADD_DISK_FINISHED_SUCCESS=The disk '${DiskAlias}' was successfully added. USER_ADD_DISK_FINISHED_FAILURE=Operation Add-Disk failed to complete. USER_FAILED_ADD_DISK=Operation Add-Disk failed (User: ${UserName}). +USER_IMPORT_IMAGE=User ${UserName} importing image ${RepoImageName} to domain ${StorageDomainName}. +USER_IMPORT_IMAGE_FINISHED_SUCCESS=User ${UserName} successfully imported image ${RepoImageName} to domain ${StorageDomainName}. +USER_IMPORT_IMAGE_FINISHED_FAILURE=User ${UserName} failed to import image ${RepoImageName} to domain ${StorageDomainName}. USER_MOVE_IMAGE_GROUP_FAILED_TO_DELETE_SRC_IMAGE=Possible failure while deleting ${DiskAlias} from the source Storage Domain ${StorageDomainName} during the move operation. The Storage Domain may be manually cleaned-up from possible leftovers (User:${UserName}). USER_MOVE_IMAGE_GROUP_FAILED_TO_DELETE_DST_IMAGE=Possible failure while clearing possible leftovers of ${DiskAlias} from the target Storage Domain ${StorageDomainName} after the move operation failed to copy the image to it properly. The Storage Domain may be manually cleaned-up from possible leftovers (User:${UserName}). USER_REMOVE_DISK_FROM_VM=Disk was removed from VM ${VmName} by ${UserName}. -- To view, visit http://gerrit.ovirt.org/19221 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ief70939697b5c9d38a850db5a4c9df10798ce1f3 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Federico Simoncelli <fsimo...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches