Maor Lipchuk has uploaded a new change for review.

Change subject: core: Add validation for locked template
......................................................................

core: Add validation for locked template

Engine should validate the template status before updating it, same as
being done in the GUI.
The proposed fix is adding a validation for template status.

Change-Id: If4e25d5e9badd3169b2b5a65c3a7e745adadf379
Bug-Url: https://bugzilla.redhat.com/856515
Signed-off-by: Maor Lipchuk <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java
1 file changed, 5 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/70/9070/1

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 f5ad2e6..7c2c0b6 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
@@ -11,6 +11,7 @@
 import org.ovirt.engine.core.common.businessentities.ActionGroup;
 import org.ovirt.engine.core.common.businessentities.QuotaEnforcementTypeEnum;
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
+import org.ovirt.engine.core.common.businessentities.VmTemplateStatus;
 import org.ovirt.engine.core.common.validation.group.UpdateEntity;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.VdcBllMessages;
@@ -36,6 +37,10 @@
     protected boolean canDoAction() {
         boolean returnValue = false;
         mOldTemplate = 
DbFacade.getInstance().getVmTemplateDao().get(getVmTemplate().getId());
+        if (mOldTemplate.getstatus() == VmTemplateStatus.Locked) {
+            addCanDoActionMessage(VdcBllMessages.VM_TEMPLATE_IMAGE_IS_LOCKED);
+            return false;
+        }
         VmTemplateHandler.UpdateDisksFromDb(mOldTemplate);
         if (mOldTemplate != null) {
             if 
(VmTemplateHandler.BlankVmTemplateId.equals(mOldTemplate.getId())) {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If4e25d5e9badd3169b2b5a65c3a7e745adadf379
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