Oved Ourfali has uploaded a new change for review.

Change subject: core: improve audit log when creating diskless template
......................................................................

core: improve audit log when creating diskless template

Change-Id: I99c88bbc84e19fef06d54bd25567500b056d6e20
Bug-Url: https://bugzilla.redhat.com/1053544
Signed-off-by: Oved Ourfali <oourf...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.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, 17 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/24307/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
index ba652e7..0e6b1f6 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java
@@ -81,6 +81,7 @@
     protected Map<Guid, DiskImage> diskInfoDestinationMap;
     protected Map<Guid, List<DiskImage>> sourceImageDomainsImageMap;
     private boolean isVmInDb;
+    private boolean pendingAsyncTasks;
 
     private static final String BASE_TEMPLATE_VERSION_NAME = "base version";
     private static Map<Guid, String> updateVmsJobIdMap = new 
ConcurrentHashMap<Guid, String>();
@@ -154,7 +155,15 @@
     public AuditLogType getAuditLogTypeValue() {
         switch (getActionState()) {
         case EXECUTE:
-            return getSucceeded() ? AuditLogType.USER_ADD_VM_TEMPLATE : 
AuditLogType.USER_FAILED_ADD_VM_TEMPLATE;
+            if (isVmInDb) {
+                if (pendingAsyncTasks) {
+                    return getSucceeded() ? AuditLogType.USER_ADD_VM_TEMPLATE 
: AuditLogType.USER_FAILED_ADD_VM_TEMPLATE;
+                } else {
+                    return getSucceeded() ? 
AuditLogType.USER_ADD_VM_TEMPLATE_FINISHED_SUCCESS : 
AuditLogType.USER_ADD_VM_TEMPLATE_FINISHED_FAILURE;
+                }
+            } else {
+                return getSucceeded() ? 
AuditLogType.USER_ADD_VM_TEMPLATE_SUCCESS : 
AuditLogType.USER_ADD_VM_TEMPLATE_FAILURE;
+            }
 
         case END_SUCCESS:
             return getSucceeded() ? 
AuditLogType.USER_ADD_VM_TEMPLATE_FINISHED_SUCCESS
@@ -275,7 +284,7 @@
 
         // means that there are no asynchronous tasks to execute and that we 
can
         // end the command synchronously
-        boolean pendingAsyncTasks = 
!getReturnValue().getVdsmTaskIdList().isEmpty();
+        pendingAsyncTasks = !getReturnValue().getVdsmTaskIdList().isEmpty();
         if (!pendingAsyncTasks) {
             endSuccessfullySynchronous();
         }
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 ea00ceb..dc84905 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
@@ -352,6 +352,8 @@
     USER_RESTORE_FROM_SNAPSHOT_FINISH_FAILURE(101),
     USER_FAILED_RESTORE_FROM_SNAPSHOT(116),
     USER_ADD_VM_TEMPLATE(48),
+    USER_ADD_VM_TEMPLATE_SUCCESS(53),
+    USER_ADD_VM_TEMPLATE_FAILURE(54),
     USER_ADD_VM_TEMPLATE_FINISHED_SUCCESS(51),
     USER_ADD_VM_TEMPLATE_FINISHED_FAILURE(52),
     USER_FAILED_ADD_VM_TEMPLATE(108),
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 53610ae..ee0e4cd 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
@@ -610,6 +610,8 @@
         severities.put(AuditLogType.USER_MOVED_VM_FINISHED_FAILURE, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.USER_FAILED_MOVE_VM, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.USER_ADD_VM_TEMPLATE_FINISHED_SUCCESS, 
AuditLogSeverity.NORMAL);
+        severities.put(AuditLogType.USER_ADD_VM_TEMPLATE_FAILURE, 
AuditLogSeverity.ERROR);
+        severities.put(AuditLogType.USER_ADD_VM_TEMPLATE_SUCCESS, 
AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.USER_ADD_VM_TEMPLATE_FINISHED_FAILURE, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.USER_REMOVE_VM_TEMPLATE_FINISHED, 
AuditLogSeverity.NORMAL);
         severities.put(AuditLogType.USER_FAILED_ADD_VM_TEMPLATE, 
AuditLogSeverity.ERROR);
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 cbecf1d..3591bdc 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -24,6 +24,8 @@
 USER_ADD_VM_TEMPLATE_FINISHED_FAILURE=Failed to complete creation of Template 
${VmTemplateName} from VM ${VmName}.
 USER_ADD_VM_TEMPLATE_FROM_TRUSTED_TO_UNTRUSTED=The non-trusted Template 
${VmTemplateName} was created from trusted Vm ${VmName}.
 USER_ADD_VM_TEMPLATE_FROM_UNTRUSTED_TO_TRUSTED=The trusted template 
${VmTemplateName} was created from non-trusted Vm ${VmName}.
+USER_ADD_VM_TEMPLATE_SUCCESS=Template ${VmTemplateName} was created 
successfully.
+USER_ADD_VM_TEMPLATE_FAILURE=Failed creating Template ${VmTemplateName}.
 USER_UPDATE_VM_TEMPLATE_FROM_TRUSTED_TO_UNTRUSTED=The Template 
${VmTemplateName} was updated from trusted cluster to non-trusted cluster.
 USER_UPDATE_VM_TEMPLATE_FROM_UNTRUSTED_TO_TRUSTED=The Template 
${VmTemplateName} was updated from non-trusted cluster to trusted cluster.
 USER_ADD_VM_FROM_TRUSTED_TO_UNTRUSTED=The VM ${VmName} was created in an 
untrusted cluster. It was originated from the Template ${VmTemplateName} which 
was created in a trusted cluster.


-- 
To view, visit http://gerrit.ovirt.org/24307
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I99c88bbc84e19fef06d54bd25567500b056d6e20
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Oved Ourfali <oourf...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to