Alona Kaplan has uploaded a new change for review.

Change subject: engine: Wrong vnic profiles on vm based on template from 
another cluster
......................................................................

engine: Wrong vnic profiles on vm based on template from another cluster

If-
1. New vm is based on template from different cluster (or even dc in
case of 'Blank' template).
And
2. The template has nics which's profile's network is not attached to the
vm's cluster.

Then-
The profiles on the vm's nics should be overridden by 'Empty' profiles.

Change-Id: I678c8db0e56c9ba9e9e947028d14ae4ddae76e0a
Bug-Url: https://bugzilla.redhat.com/1103058
Signed-off-by: Alona Kaplan <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
1 file changed, 10 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/39/30639/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
index 147a9b8..4b42aef 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java
@@ -13,6 +13,7 @@
 import org.ovirt.engine.core.bll.context.CommandContext;
 import org.ovirt.engine.core.bll.network.MacPoolManager;
 import org.ovirt.engine.core.bll.network.VmInterfaceManager;
+import org.ovirt.engine.core.bll.network.cluster.NetworkHelper;
 import org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter;
 import org.ovirt.engine.core.bll.quota.QuotaSanityParameter;
 import org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter;
@@ -62,8 +63,10 @@
 import org.ovirt.engine.core.common.businessentities.VmTemplate;
 import org.ovirt.engine.core.common.businessentities.VmType;
 import org.ovirt.engine.core.common.businessentities.VmWatchdog;
+import org.ovirt.engine.core.common.businessentities.network.Network;
 import org.ovirt.engine.core.common.businessentities.network.VmInterfaceType;
 import org.ovirt.engine.core.common.businessentities.network.VmNic;
+import org.ovirt.engine.core.common.businessentities.network.VnicProfileView;
 import org.ovirt.engine.core.common.config.Config;
 import org.ovirt.engine.core.common.config.ConfigValues;
 import org.ovirt.engine.core.common.errors.VdcBLLException;
@@ -900,6 +903,7 @@
             
iface.setSpeed(VmInterfaceType.forValue(iface.getType()).getSpeed());
             iface.setVmTemplateId(null);
             iface.setVmId(getParameters().getVmStaticData().getId());
+            updateProfiles(iface);
             getVmNicDao().save(iface);
             getCompensationContext().snapshotNewEntity(iface);
             
DbFacade.getInstance().getVmNetworkStatisticsDao().save(iface.getStatistics());
@@ -1332,4 +1336,10 @@
         return getVmTemplate().getStoragePoolId().equals(getStoragePoolId());
     }
 
+    protected void updateProfiles(VmNic iface) {
+        Network network = 
NetworkHelper.getNetworkByVnicProfileId(iface.getVnicProfileId());
+        if (network != null && !NetworkHelper.isNetworkInCluster(network, 
getVdsGroupId())) {
+            iface.setVnicProfileId(VnicProfileView.EMPTY.getId());
+        }
+    }
 }


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

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

Reply via email to