Alona Kaplan has uploaded a new change for review.

Change subject: core: add NetworkLinking to AddVmTemplateInterfaceCommand
......................................................................

core: add NetworkLinking to AddVmTemplateInterfaceCommand

core: add NetworkLinking to AddVmInterfaceCommand

- canDoAction-
If "UnlinkingSupported" is false for the cluster compatibility version.
- block 'null' network.
- block unlinking.

If "UnlinkingSupported" is true
- allow 'null' network.

Change-Id: Id39e63f5061b694457de5918490e08bce3fb962c
Signed-off-by: Alona Kaplan <alkap...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateInterfaceCommand.java
1 file changed, 35 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/65/9565/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateInterfaceCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateInterfaceCommand.java
index 60ddca7..81af305 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateInterfaceCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateInterfaceCommand.java
@@ -7,10 +7,12 @@
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.action.AddVmTemplateInterfaceParameters;
 import org.ovirt.engine.core.common.businessentities.DiskImageBase;
+import org.ovirt.engine.core.common.businessentities.Network;
 import org.ovirt.engine.core.common.businessentities.VmDeviceId;
 import org.ovirt.engine.core.common.businessentities.VmInterfaceType;
 import org.ovirt.engine.core.common.businessentities.VmNetworkInterface;
-import org.ovirt.engine.core.common.businessentities.Network;
+import org.ovirt.engine.core.common.config.Config;
+import org.ovirt.engine.core.common.config.ConfigValues;
 import org.ovirt.engine.core.common.validation.group.CreateEntity;
 import org.ovirt.engine.core.compat.Guid;
 import org.ovirt.engine.core.dal.VdcBllMessages;
@@ -80,16 +82,39 @@
             return false;
         }
 
-        // check that the network exists in current cluster
-        List<Network> networks = 
DbFacade.getInstance().getNetworkDao().getAllForCluster(getVmTemplate().getvds_group_id());
-        if (null == LinqUtils.firstOrNull(networks, new Predicate<Network>() {
-            @Override
-            public boolean eval(Network network) {
-                return 
network.getname().equals(getParameters().getInterface().getNetworkName());
+        boolean unlinkingSupported =
+                Config.<Boolean> GetValue(ConfigValues.NetworkLinkingSupported,
+                        getVdsGroup().getcompatibility_version().getValue());
+
+        if (!unlinkingSupported) {
+            if (!getParameters().getInterface().isLinked()) {
+                
addCanDoActionMessage(VdcBllMessages.UNLINKING_IS_NOT_SUPPORTED);
+                
getReturnValue().getCanDoActionMessages().add(String.format("$version %1$s",
+                        getVdsGroup().getcompatibility_version().getValue()));
+                return false;
             }
-        })) {
-            
addCanDoActionMessage(VdcBllMessages.NETWORK_NOT_EXISTS_IN_CURRENT_CLUSTER);
-            return false;
+
+            if (getParameters().getInterface().getNetworkName() == null) {
+                
addCanDoActionMessage(VdcBllMessages.NULL_NETWORK_IS_NOT_SUPPORTED);
+                
getReturnValue().getCanDoActionMessages().add(String.format("$version %1$s",
+                        getVdsGroup().getcompatibility_version().getValue()));
+                return false;
+            }
+        }
+
+        if (getParameters().getInterface().getNetworkName() != null) {
+            // check that the network exists in current cluster
+            List<Network> networks =
+                    
DbFacade.getInstance().getNetworkDao().getAllForCluster(getVmTemplate().getvds_group_id());
+            if (null == LinqUtils.firstOrNull(networks, new 
Predicate<Network>() {
+                @Override
+                public boolean eval(Network network) {
+                    return 
network.getname().equals(getParameters().getInterface().getNetworkName());
+                }
+            })) {
+                
addCanDoActionMessage(VdcBllMessages.NETWORK_NOT_EXISTS_IN_CURRENT_CLUSTER);
+                return false;
+            }
         }
 
         return true;


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

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

Reply via email to