Maor Lipchuk has uploaded a new change for review.

Change subject: core: Add audit log for export repo image
......................................................................

core: Add audit log for export repo image

Adding an audit log when exporting a repository image (same as
importRepoImage)

Bug-Url: https://bugzilla.redhat.com/1021210
Signed-off-by: Maor Lipchuk <[email protected]>
Change-Id: Ifb79102b01b596a1ff74a1a38fdcb7dca71e0c7c
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportRepoImageCommand.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, 29 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/60/20660/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportRepoImageCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportRepoImageCommand.java
index 8c2ace0..18b6166 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportRepoImageCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExportRepoImageCommand.java
@@ -4,6 +4,7 @@
 import org.ovirt.engine.core.bll.provider.ProviderProxyFactory;
 import org.ovirt.engine.core.bll.utils.PermissionSubject;
 import org.ovirt.engine.core.bll.validator.StorageDomainValidator;
+import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.ExportRepoImageParameters;
 import org.ovirt.engine.core.common.action.VdcActionType;
@@ -161,6 +162,25 @@
     }
 
     @Override
+    public AuditLogType getAuditLogTypeValue() {
+        switch (getActionState()) {
+            case EXECUTE:
+                if (!getParameters().getTaskGroupSuccess()) {
+                    return AuditLogType.USER_EXPORT_IMAGE_FINISHED_FAILURE;
+                }
+                if (getParameters().getExecutionIndex() == 0 && 
getSucceeded()) {
+                    return AuditLogType.USER_EXPORT_IMAGE;
+                }
+                break;
+            case END_SUCCESS:
+                return AuditLogType.USER_EXPORT_IMAGE_FINISHED_SUCCESS;
+            case END_FAILURE:
+                return AuditLogType.USER_EXPORT_IMAGE_FINISHED_FAILURE;
+        }
+        return AuditLogType.UNASSIGNED;
+    }
+
+    @Override
     public Guid getStorageDomainId() {
         return getDiskImage() != null ? getDiskImage().getStorageIds().get(0) 
: null;
     }
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 a6530ff..9e5b5d2 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
@@ -189,6 +189,9 @@
     USER_IMPORT_IMAGE(2027),
     USER_IMPORT_IMAGE_FINISHED_SUCCESS(2028),
     USER_IMPORT_IMAGE_FINISHED_FAILURE(2029),
+    USER_EXPORT_IMAGE(2030),
+    USER_EXPORT_IMAGE_FINISHED_SUCCESS(2031),
+    USER_EXPORT_IMAGE_FINISHED_FAILURE(2032),
 
     // Used only from SQL script, therefor should not have severity & message
     USER_RUN_UNLOCK_ENTITY_SCRIPT(2024),
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 85ce98a..0dd56b3 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
@@ -466,6 +466,9 @@
         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);
+        severities.put(AuditLogType.USER_EXPORT_IMAGE, 
AuditLogSeverity.NORMAL);
+        severities.put(AuditLogType.USER_EXPORT_IMAGE_FINISHED_SUCCESS, 
AuditLogSeverity.NORMAL);
+        severities.put(AuditLogType.USER_EXPORT_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 eab93ad..9557318 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -87,6 +87,9 @@
 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_EXPORT_IMAGE=User ${UserName} exporting image ${RepoImageName} from 
domain ${StorageDomainName}.
+USER_EXPORT_IMAGE_FINISHED_SUCCESS=User ${UserName} successfully exported 
image ${RepoImageName} from domain ${StorageDomainName}.
+USER_EXPORT_IMAGE_FINISHED_FAILURE=User ${UserName} failed to export image 
${RepoImageName} from 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/20660
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifb79102b01b596a1ff74a1a38fdcb7dca71e0c7c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Maor Lipchuk <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to