Mike Kolesnik has uploaded a new change for review.

Change subject: engine: Obtain old network name from correct NIC (#849971)
......................................................................

engine: Obtain old network name from correct NIC (#849971)

https://bugzilla.redhat.com/849971

The old network name should be taken from the NIC it's defined on.
If there is more than one network defined on the given NICs, this
command can't handle it and should fail.

VLANs are also handled since a NIC can have several VLANs based on it
which in turn can have networks attached to them.

Change-Id: I1311be342aa72bac9f1b79cec816be52f37d966d
Signed-off-by: Mike Kolesnik <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateNetworkToVdsInterfaceCommand.java
1 file changed, 12 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/10/7410/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateNetworkToVdsInterfaceCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateNetworkToVdsInterfaceCommand.java
index 2a3c94d..b019427 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateNetworkToVdsInterfaceCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateNetworkToVdsInterfaceCommand.java
@@ -160,27 +160,34 @@
     protected boolean canDoAction() {
         String ifaceGateway = null;
         interfaces = 
getInterfaceDAO().getAllInterfacesForVds(getParameters().getVdsId());
-        VdsNetworkInterface updatedIface = null;
 
-        // check that interface exists
         for (final VdsNetworkInterface i : getParameters().getInterfaces()) {
+            VdsNetworkInterface updatedIface = null;
             for (VdsNetworkInterface iface : interfaces) {
                 if (iface.getName().equals(i.getName())) {
                     updatedIface = iface;
+                }
+
+                if (NetworkUtils.interfaceBasedOn(iface.getName(), i.getName())
+                        && StringUtils.isNotEmpty(iface.getNetworkName())) {
+                    if (oldNetworkName != null) {
+                        
addCanDoActionMessage(VdcBllMessages.MORE_THAN_ONE_NETWORK_ATTACHED);
+                        return false;
+                    }
+
+                    oldNetworkName = iface.getNetworkName();
                 }
             }
             if (updatedIface == null) {
                 
addCanDoActionMessage(VdcBllMessages.NETWORK_INTERFACE_NOT_EXISTS);
                 return false;
             }
+
             ifaceGateway = updatedIface.getGateway();
         }
 
         boolean managementNetworkUpdated =
                 StringUtils.equals(getParameters().getNetwork().getname(), 
NetworkUtils.getEngineNetwork());
-
-        // obtain the network name from the host interface and check that the 
old network name is not null
-        oldNetworkName = StringUtils.isEmpty(updatedIface.getNetworkName()) ? 
null : updatedIface.getNetworkName();
 
         if (oldNetworkName == null) {
             if (managementNetworkUpdated) {


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

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

Reply via email to