Lior Vernia has uploaded a new change for review.

Change subject: webadmin: Extended capabilities of bond operations
......................................................................

webadmin: Extended capabilities of bond operations

The BOND_WITH operation used to only received regular NICs as arguments,
but from now on will be able to handle bond arguments as well. When
dealing with them, NICs are "collected" and put into the new bond, and
any bond passed as argument is broken.

Also created the EXTEND_BOND operation, which executes ADD_TO_BOND but
receives a bond as its first argument rather than its second argument.

Change-Id: I6bcd6e55f0cf852581541462a7fe0e8d7c44fec7
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=825801
Signed-off-by: Lior Vernia <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkOperation.java
M 
frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Messages.java
2 files changed, 47 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/73/13773/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkOperation.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkOperation.java
index 9ba84a1..ef6ba65 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkOperation.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkOperation.java
@@ -1,8 +1,10 @@
 package org.ovirt.engine.ui.uicommonweb.models.hosts.network;
 
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Set;
 
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
 import org.ovirt.engine.ui.uicompat.ConstantsManager;
@@ -143,15 +145,28 @@
                 protected void ExecuteNetworkCommand(NetworkItemModel<?> op1,
                         NetworkItemModel<?> op2,
                         List<VdsNetworkInterface> allNics, Object... params) {
-                    assert op1 instanceof NetworkInterfaceModel && !(op1 
instanceof BondNetworkInterfaceModel);
-                    assert op2 instanceof NetworkInterfaceModel && !(op2 
instanceof BondNetworkInterfaceModel);
+                    assert op1 instanceof NetworkInterfaceModel;
+                    assert op2 instanceof NetworkInterfaceModel;
                     assert params.length == 1 : "incorrect params length"; 
//$NON-NLS-1$
-                    NetworkInterfaceModel nic1 = (NetworkInterfaceModel) op1;
-                    NetworkInterfaceModel nic2 = (NetworkInterfaceModel) op2;
+
+                    Set<NetworkInterfaceModel> nics = new 
HashSet<NetworkInterfaceModel>();
+                    if (op1 instanceof BondNetworkInterfaceModel) {
+                        nics.addAll(((BondNetworkInterfaceModel) 
op1).getBonded());
+                        NetworkOperation.BREAK_BOND.getCommand(op1, null, 
allNics).Execute();
+                    } else {
+                        nics.add((NetworkInterfaceModel) op1);
+                    }
+                    if (op2 instanceof BondNetworkInterfaceModel) {
+                        nics.addAll(((BondNetworkInterfaceModel) 
op2).getBonded());
+                        NetworkOperation.BREAK_BOND.getCommand(op2, null, 
allNics).Execute();
+                    } else {
+                        nics.add((NetworkInterfaceModel) op2);
+                    }
 
                     // detach possible networks from both nics
-                    clearNetworks(nic1, allNics);
-                    clearNetworks(nic2, allNics);
+                    for (NetworkInterfaceModel nic : nics) {
+                        clearNetworks(nic, allNics);
+                    }
 
                     // param
                     VdsNetworkInterface bond = (VdsNetworkInterface) params[0];
@@ -160,8 +175,9 @@
                     // add to nic list
                     allNics.add(bond);
 
-                    nic1.getEntity().setBondName(bondName);
-                    nic2.getEntity().setBondName(bondName);
+                    for (NetworkInterfaceModel nic : nics) {
+                        nic.getEntity().setBondName(bondName);
+                    }
                 }
             };
         }
@@ -204,6 +220,26 @@
         }
 
     },
+    EXTEND_BOND {
+
+        @Override
+        public String getVerb(NetworkItemModel<?> op1) {
+            return 
ConstantsManager.getInstance().getMessages().extendBond(op1.getName());
+        }
+
+        @Override
+        protected NetworkOperationCommandTarget getTarget() {
+            return new NetworkOperationCommandTarget() {
+                @Override
+                protected void ExecuteNetworkCommand(NetworkItemModel<?> op1,
+                        NetworkItemModel<?> op2,
+                        List<VdsNetworkInterface> allNics, Object... params) {
+                    NetworkOperation.ADD_TO_BOND.getCommand(op2, op1, 
allNics).Execute();
+                }
+            };
+        }
+
+    },
     REMOVE_FROM_BOND {
 
         @Override
diff --git 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Messages.java
 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Messages.java
index 49de335..c4ea902 100644
--- 
a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Messages.java
+++ 
b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Messages.java
@@ -186,6 +186,9 @@
     @DefaultMessage("Add {0} to Bond")
     String addToBond(String name);
 
+    @DefaultMessage("Extend {0} with")
+    String extendBond(String name);
+
     @DefaultMessage("Remove {0} from Bond")
     String removeFromBond(String name);
 


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

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

Reply via email to