Lior Vernia has uploaded a new change for review.

Change subject: webadmin: Suggest bond name when creating new bond
......................................................................

webadmin: Suggest bond name when creating new bond

Ever since the user has been able to create new bonds from the engine,
the default suggest bond name was "bond" to show all existing bond
names upon focus. Now a valid bond name is suggested instead.

Change-Id: I059a02cca35c91bdf4c44ffbdfa88326fe20ee2f
Bug-Url: https://bugzilla.redhat.com/988425
Signed-off-by: Lior Vernia <lver...@redhat.com>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/SetupNetworksAddBondModel.java
2 files changed, 19 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/41/17841/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
index 956071e..1d95746 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
@@ -2,6 +2,7 @@
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -9,7 +10,9 @@
 import org.ovirt.engine.core.common.action.SetupNetworksParameters;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VdcReturnValueBase;
+import 
org.ovirt.engine.core.common.businessentities.BusinessEntitiesDefinitions;
 import org.ovirt.engine.core.common.businessentities.VDS;
+import 
org.ovirt.engine.core.common.businessentities.comparators.LexoNumericComparator;
 import org.ovirt.engine.core.common.businessentities.network.Bond;
 import org.ovirt.engine.core.common.businessentities.network.Network;
 import 
org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface;
@@ -122,6 +125,7 @@
     private NetworkOperation currentCandidate;
     private NetworkItemModel<?> currentOp1;
     private NetworkItemModel<?> currentOp2;
+    private String nextBondName;
 
     private final UICommand okCommand;
     public static final String NIC = "nic"; //$NON-NLS-1$
@@ -384,7 +388,7 @@
         } else if (operation == NetworkOperation.BOND_WITH || operation == 
NetworkOperation.JOIN_BONDS) {
             final SetupNetworksBondModel bondPopup;
             if (operation == NetworkOperation.BOND_WITH) {
-                bondPopup = new SetupNetworksAddBondModel(getFreeBonds());
+                bondPopup = new SetupNetworksAddBondModel(getFreeBonds(), 
nextBondName);
             } else {
                 bondPopup =
                         new SetupNetworksJoinBondsModel(getFreeBonds(),
@@ -587,6 +591,18 @@
                     netToBeforeSyncParams.put(networkName, new 
NetworkParameters(nic));
                 }
             }
+
+            // calculate the next available bond name
+            List<String> bondNames = new ArrayList<String>(bondToNic.keySet());
+            Collections.sort(bondNames, new LexoNumericComparator());
+            nextBondName = BusinessEntitiesDefinitions.BOND_NAME_PREFIX + 0;
+            for (int i=0; i<bondNames.size(); ++i) {
+                if (nextBondName.equals(bondNames.get(i))) {
+                    nextBondName = 
BusinessEntitiesDefinitions.BOND_NAME_PREFIX + (i + 1);
+                } else {
+                    break;
+                }
+            }
         }
 
         // build models
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/SetupNetworksAddBondModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/SetupNetworksAddBondModel.java
index cf2454d..baae66a 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/SetupNetworksAddBondModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/SetupNetworksAddBondModel.java
@@ -7,10 +7,10 @@
 
 public class SetupNetworksAddBondModel extends SetupNetworksBondModel {
 
-    public SetupNetworksAddBondModel(List<String> freeBonds) {
+    public SetupNetworksAddBondModel(List<String> freeBonds, String 
defaultBondName) {
         
setTitle(ConstantsManager.getInstance().getConstants().createNewBondTitle());
         getBond().setItems(freeBonds);
-        
getBond().setSelectedItem(BusinessEntitiesDefinitions.BOND_NAME_PREFIX);
+        getBond().setSelectedItem(defaultBondName);
     }
 
 }


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

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

Reply via email to