Omer Frenkel has uploaded a new change for review.

Change subject: core: update vms on update of instance type
......................................................................

core: update vms on update of instance type

when instance type values are updated, we need to update also all the
vms that are using this instance type.

also, added audit log for vm update that is done internaly (by system)
otherwise log will show "user <unknown>"

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1136372
Change-Id: Ic229a677bdd61a7f522548d9abf68476fbe219e7
Signed-off-by: Omer Frenkel <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
4 files changed, 27 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/68/32368/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
index 046dc45..379dea2 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java
@@ -109,7 +109,9 @@
 
     @Override
     public AuditLogType getAuditLogTypeValue() {
-        return getSucceeded() ? AuditLogType.USER_UPDATE_VM : 
AuditLogType.USER_FAILED_UPDATE_VM;
+        return isInternalExecution() ?
+                getSucceeded() ? AuditLogType.SYSTEM_UPDATE_VM : 
AuditLogType.SYSTEM_FAILED_UPDATE_VM
+                : getSucceeded() ? AuditLogType.USER_UPDATE_VM : 
AuditLogType.USER_FAILED_UPDATE_VM;
     }
 
     @Override
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java
index 40ece2e..4b43583 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java
@@ -17,8 +17,11 @@
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.UpdateVmTemplateParameters;
+import org.ovirt.engine.core.common.action.VdcActionType;
+import org.ovirt.engine.core.common.action.VmManagementParametersBase;
 import org.ovirt.engine.core.common.businessentities.ActionGroup;
 import org.ovirt.engine.core.common.businessentities.DiskImageBase;
+import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VmEntityType;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
 import org.ovirt.engine.core.common.businessentities.VmTemplateStatus;
@@ -202,10 +205,26 @@
             updateWatchdog(getParameters().getVmTemplateData().getId());
             updateRngDevice(getParameters().getVmTemplateData().getId());
             checkTrustedService();
+            updateVmsOfInstanceType();
             setSucceeded(true);
         }
     }
 
+    /**
+     * only in case of InstanceType update, update all vms that are bound to it
+     */
+    private void updateVmsOfInstanceType() {
+        if (getVmTemplate().getTemplateType() != VmEntityType.INSTANCE_TYPE) {
+            return;
+        }
+
+        // get vms from db
+        List<VM> vmsToUpdate = 
getVmDAO().getVmsListByInstanceType(getVmTemplateId());
+        for (VM vm : vmsToUpdate) {
+            runInternalAction(VdcActionType.UpdateVm, new 
VmManagementParametersBase(vm));
+        }
+    }
+
     private void checkTrustedService() {
         if (getVdsGroup() == null) {
             return;
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 9c65292..4dca090 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
@@ -174,7 +174,9 @@
     USER_ADD_VM_FINISHED_FAILURE(60, AuditLogSeverity.ERROR),
     USER_FAILED_ADD_VM(57, AuditLogSeverity.ERROR),
     USER_UPDATE_VM(35),
+    SYSTEM_UPDATE_VM(253),
     USER_FAILED_UPDATE_VM(58, AuditLogSeverity.ERROR),
+    SYSTEM_FAILED_UPDATE_VM(252, AuditLogSeverity.ERROR),
     USER_UPDATE_VM_CLUSTER_DEFAULT_HOST_CLEARED(250),
     USER_REMOVE_VM_FINISHED(113),
     USER_REMOVE_VM_FINISHED_WITH_ILLEGAL_DISKS(172, AuditLogSeverity.WARNING),
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 03f0641..90cea81 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -158,6 +158,7 @@
 USER_FAILED_TRY_BACK_TO_SNAPSHOT=Failed to preview Snapshot ${SnapshotName} 
for VM ${VmName} (User: ${UserName}).
 USER_FAILED_UPDATE_VDS=Failed to update Host ${VdsName} (User: ${UserName}).
 USER_FAILED_UPDATE_VM=Failed to update VM ${VmName} (User: ${UserName}).
+SYSTEM_FAILED_UPDATE_VM=Failed to Update VM ${VmName} that was initiated by 
system.
 USER_FAILED_UPDATE_VM_TEMPLATE=Failed to update Template ${VmTemplateName} 
(User: ${UserName}).
 USER_FAILED_VDS_RESTART=Failed to restart Host ${VdsName}, (User: ${UserName}).
 USER_FAILED_VDS_START=Failed to start Host ${VdsName}, (User: ${UserName}).
@@ -195,6 +196,7 @@
 
 USER_UPDATE_VDS=Host ${VdsName} configuration was updated by ${UserName}.
 USER_UPDATE_VM=VM ${VmName} configuration was updated by ${UserName}.
+SYSTEM_UPDATE_VM=VM ${VmName} configuration was updated by system.
 USER_EXTEND_DISK_SIZE_UPDATE_VM_FAILURE=Failed to update VM '${VmName}' with 
the new volume size. VM restart is recommended.
 USER_EXTEND_DISK_SIZE_FAILURE=Failed to extend size of the disk '${DiskAlias}' 
to ${NewSize} GB, User: ${UserName}.
 USER_EXTEND_DISK_SIZE_SUCCESS=Size of the disk '${DiskAlias}' was successfully 
updated to ${NewSize} GB by ${UserName}.
@@ -852,4 +854,4 @@
 KDUMP_FLOW_DETECTED_ON_VDS=Kdump flow is in progress on host '${VdsName}'.
 KDUMP_FLOW_NOT_DETECTED_ON_VDS=Kdump flow is not in progress on host 
'${VdsName}'.
 KDUMP_FLOW_FINISHED_ON_VDS=Kdump flow finished on host '${VdsName}'.
-KDUMP_DETECTION_NOT_CONFIGURED_ON_VDS=Kdump integration is enabled for host 
'${VdsName}', but kdump is not configured properly on host.
+KDUMP_DETECTION_NOT_CONFIGURED_ON_VDS=Kdump integration is enabled for host 
'${VdsName}', but kdump is not configured properly on host.
\ No newline at end of file


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

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

Reply via email to