Moti Asayag has uploaded a new change for review.

Change subject: engine: Networks with role configured with DHCP in nic
......................................................................

engine: Networks with role configured with DHCP in nic

Network with roles must have an IP address in order for
the host to be operational (either for display or for
migration purposes).

A mass operation to configure networks on various hosts,
where some of the networks might have roles, is by setting
the boot protocol to DHCP. This will configure the networks
on the hosts in a way that will enable to IP assignment.

If the DHCP request fails, there is a change the network
will not be configure on the host. This will cause the host
to be non-operational, with a simple resolution for the
nature of the problem.

Change-Id: I3ee53ec1f354ea766cea59977e869f97c2be94df
Bug-Url: https://bugzilla.redhat.com/1073043
Signed-off-by: Moti Asayag <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/AddNetworkParametersBuilder.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/NetworkParametersBuilder.java
2 files changed, 23 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/51/25551/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/AddNetworkParametersBuilder.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/AddNetworkParametersBuilder.java
index 051e76e..6c3f1ba 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/AddNetworkParametersBuilder.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/AddNetworkParametersBuilder.java
@@ -9,6 +9,7 @@
 import org.ovirt.engine.core.common.action.PersistentSetupNetworksParameters;
 import org.ovirt.engine.core.common.action.VdcActionParametersBase;
 import org.ovirt.engine.core.common.businessentities.network.Network;
+import org.ovirt.engine.core.common.businessentities.network.NetworkCluster;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
 import org.ovirt.engine.core.common.errors.VdcBLLException;
 import org.ovirt.engine.core.common.errors.VdcBllErrors;
@@ -37,11 +38,14 @@
                 throw new 
VdcBLLException(VdcBllErrors.LABELED_NETWORK_INTERFACE_NOT_FOUND);
             }
 
+            NetworkCluster networkCluster = getNetworkCluster(nicToConfigure, 
network);
             if (vlanNetwork) {
                 VdsNetworkInterface vlan = createVlanDevice(nic, network);
+                addBootProtocolForRoleNetwork(networkCluster, vlan);
                 setupNetworkParams.getInterfaces().add(vlan);
             } else if (nicToConfigure.getNetworkName() == null) {
                 nicToConfigure.setNetworkName(network.getName());
+                addBootProtocolForRoleNetwork(networkCluster, nicToConfigure);
             } else {
                 // if a network is already assigned to that nic, it cannot be 
configured
                 nonUpdateableHosts.add(nic.getVdsId());
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/NetworkParametersBuilder.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/NetworkParametersBuilder.java
index 0fccbe8..629b6f7 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/NetworkParametersBuilder.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/NetworkParametersBuilder.java
@@ -11,6 +11,8 @@
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import 
org.ovirt.engine.core.common.businessentities.network.NetworkBootProtocol;
+import org.ovirt.engine.core.common.businessentities.network.NetworkCluster;
+import org.ovirt.engine.core.common.businessentities.network.NetworkClusterId;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
 import org.ovirt.engine.core.common.businessentities.network.Vlan;
 import org.ovirt.engine.core.common.errors.VdcBLLException;
@@ -94,10 +96,14 @@
      *            the network to attach
      */
     protected void configureNetwork(VdsNetworkInterface nic, 
List<VdsNetworkInterface> nics, Network network) {
+        NetworkCluster networkCluster = getNetworkCluster(nic, network);
         if (NetworkUtils.isVlan(network)) {
-            nics.add(createVlanDevice(nic, network));
+            VdsNetworkInterface vlan = createVlanDevice(nic, network);
+            addBootProtocolForRoleNetwork(networkCluster, vlan);
+            nics.add(vlan);
         } else if (StringUtils.isEmpty(nic.getNetworkName())) {
             nic.setNetworkName(network.getName());
+            addBootProtocolForRoleNetwork(networkCluster, nic);
         } else {
             throw new VdcBLLException(VdcBllErrors.NETWORK_LABEL_CONFLICT);
         }
@@ -145,4 +151,16 @@
             setupNetworkParameters.setShouldBeLogged(true);
         }
     }
+
+    protected void addBootProtocolForRoleNetwork(NetworkCluster 
networkCluster, VdsNetworkInterface nic) {
+        if ((networkCluster.isDisplay() || networkCluster.isMigration())
+                && (nic.getBootProtocol() == null || nic.getBootProtocol() == 
NetworkBootProtocol.NONE)) {
+            nic.setBootProtocol(NetworkBootProtocol.DHCP);
+        }
+    }
+
+    protected NetworkCluster getNetworkCluster(VdsNetworkInterface nic, 
Network network) {
+        Guid clusterId = 
getDbFacade().getVdsStaticDao().get(nic.getVdsId()).getVdsGroupId();
+        return getDbFacade().getNetworkClusterDao().get(new 
NetworkClusterId(clusterId, network.getId()));
+    }
 }


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

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

Reply via email to