Frank Kobzik has uploaded a new change for review.

Change subject: core: Adjust RNG commands for instance type support
......................................................................

core: Adjust RNG commands for instance type support

This small patch adjusts RNG commands so they ignore cluster level check
when edited entity is instance type since instance types aren't bound to
cluster.

Change-Id: I5078c22b60a99d1907eede3927f589d1e94565e0
Signed-off-by: Frantisek Kobzik <fkob...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractRngDeviceCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddRngDeviceCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateRngDeviceCommand.java
3 files changed, 19 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/90/28690/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractRngDeviceCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractRngDeviceCommand.java
index aadaa80..899b09c 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractRngDeviceCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AbstractRngDeviceCommand.java
@@ -10,7 +10,9 @@
 import org.ovirt.engine.core.common.businessentities.VmBase;
 import org.ovirt.engine.core.common.businessentities.VmDevice;
 import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType;
+import org.ovirt.engine.core.common.businessentities.VmEntityType;
 import org.ovirt.engine.core.common.businessentities.VmRngDevice;
+import org.ovirt.engine.core.common.businessentities.VmTemplate;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.compat.Version;
@@ -22,6 +24,7 @@
 public abstract class AbstractRngDeviceCommand<T extends RngDeviceParameters> 
extends CommandBase<T>  {
 
     private VmBase cachedEntity = null;
+    private VmEntityType templateType = null;
     private List<VmDevice> cachedRngDevices = null;
 
     protected AbstractRngDeviceCommand(T parameters) {
@@ -34,9 +37,14 @@
         Guid vmId = parameters.getRngDevice().getVmId();
         setVmId(vmId);
 
-        cachedEntity = getParameters().isVm()
-                ? getVmStaticDAO().get(vmId)
-                : getVmTemplateDAO().get(vmId);
+        if (getParameters().isVm()) {
+            cachedEntity = getVmStaticDAO().get(vmId);
+        } else {
+            VmTemplate template = getVmTemplateDAO().get(vmId);
+            templateType = template.getTemplateType();
+            cachedEntity = template;
+        }
+
         if (cachedEntity != null) {
             setVdsGroupId(cachedEntity.getVdsGroupId());
         }
@@ -90,4 +98,8 @@
         return getDbFacade().getVmDeviceDao();
     }
 
+    protected VmEntityType getTemplateType() {
+        return templateType;
+    }
+
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddRngDeviceCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddRngDeviceCommand.java
index f26a5ee..96a205b 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddRngDeviceCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddRngDeviceCommand.java
@@ -1,6 +1,7 @@
 package org.ovirt.engine.core.bll;
 
 import org.ovirt.engine.core.common.action.RngDeviceParameters;
+import org.ovirt.engine.core.common.businessentities.VmEntityType;
 import org.ovirt.engine.core.common.businessentities.VmRngDevice;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.compat.Guid;
@@ -16,7 +17,7 @@
             return false;
         }
 
-        if (!isRngSupportedByCluster()) {
+        if (!isRngSupportedByCluster() && getTemplateType() != 
VmEntityType.INSTANCE_TYPE) {
             return 
failCanDoAction(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL);
         }
 
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateRngDeviceCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateRngDeviceCommand.java
index 1553c43..3c4db1f 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateRngDeviceCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateRngDeviceCommand.java
@@ -2,6 +2,7 @@
 
 import org.ovirt.engine.core.common.action.RngDeviceParameters;
 import org.ovirt.engine.core.common.businessentities.VmDevice;
+import org.ovirt.engine.core.common.businessentities.VmEntityType;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 
 public class UpdateRngDeviceCommand extends 
AbstractRngDeviceCommand<RngDeviceParameters> {
@@ -16,7 +17,7 @@
             return false;
         }
 
-        if (!isRngSupportedByCluster()) {
+        if (!isRngSupportedByCluster() && getTemplateType() != 
VmEntityType.INSTANCE_TYPE) {
             return 
failCanDoAction(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL);
         }
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5078c22b60a99d1907eede3927f589d1e94565e0
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Frank Kobzik <fkob...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to