Gustavo Frederico Temple Pedrosa has uploaded a new change for review.

Change subject: core: Disable balloon by default - Patch 2 of 2
......................................................................

core: Disable balloon by default - Patch 2 of 2

The "New VM"/"New Pool" dialogs in the frontend were changed to disable
the balloon device in guest OSes where the "balloonDisabledByDefault"
osinfo property is enabled. This way the system administrator will have
an usable VM by default even in problematic guest OSes.

Change-Id: I7803e45f07539090e5527ebc81bbc6c31df4e120
Signed-off-by: Gustavo Pedrosa <gustavo.pedr...@eldorado.org.br>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
2 files changed, 42 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/22107/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
index a33ba74..cb1360a 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java
@@ -175,6 +175,9 @@
     // cached disk hotpluggable interfaces map
     private static Map<Pair<Integer, Version>, Set<String>> 
diskHotpluggableInterfacesMap;
 
+    // cached os's balloon disabled by default map (given compatibility 
version)
+    private static Map<Integer, Map<Version, Boolean>> 
balloonDisabledByDefaultMatrix;
+
     // cached windows OS
     private static List<Integer> windowsOsIds;
 
@@ -220,6 +223,7 @@
         initDisplayTypes();
         initNicHotplugSupportMap();
         initDiskHotpluggableInterfacesMap();
+        initBalloonDisabledByDefaultMatrix();
     }
 
     public static void initNicHotplugSupportMap() {
@@ -249,6 +253,27 @@
         return false;
     }
 
+    public static Map<Integer, Map<Version, Boolean>> 
getBalloonDisabledByDefaultMatrix() {
+        return balloonDisabledByDefaultMatrix;
+    }
+
+    public static Boolean isBalloonDisabledByDefault(int osId, Version 
version) {
+        return getBalloonDisabledByDefaultMatrix().get(osId).get(version);
+    }
+
+    public static void initBalloonDisabledByDefaultMatrix() {
+        AsyncQuery callback = new AsyncQuery();
+        callback.asyncCallback = new INewAsyncCallback() {
+            @Override
+            public void onSuccess(Object model, Object returnValue) {
+                balloonDisabledByDefaultMatrix = (Map<Integer, Map<Version, 
Boolean>>) ((VdcQueryReturnValue) returnValue)
+                        .getReturnValue();
+            }
+        };
+        Frontend.RunQuery(VdcQueryType.OsRepository, new OsQueryParameters(
+                OsRepositoryVerb.GetBalloonDisabledByDefaultMatrix), callback);
+    }
+
     public static void initDiskHotpluggableInterfacesMap() {
         AsyncQuery callback = new AsyncQuery();
         callback.asyncCallback = new INewAsyncCallback() {
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
index 394b559..2f4b4ba 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/UnitVmModel.java
@@ -1418,6 +1418,7 @@
             {
                 dataCenterWithClusterSelectedItemChanged(sender, args);
                 updateDisplayProtocol();
+                updateMemoryBalloonDevice();
                 initUsbPolicy();
             }
             else if (sender == getTemplate())
@@ -1436,6 +1437,7 @@
             {
                 oSType_SelectedItemChanged(sender, args);
                 updateDisplayProtocol();
+                updateMemoryBalloonDevice();
                 initUsbPolicy();
             }
             else if (sender == getFirstBootDevice())
@@ -1713,6 +1715,21 @@
         behavior.postDisplayTypeItemChanged(oldDisplayProtocolOption);
     }
 
+    private void updateMemoryBalloonDevice() {
+
+        VDSGroup cluster = getSelectedCluster();
+        Integer osType = getOSType().getSelectedItem();
+
+        if (cluster == null || osType == null) {
+            return;
+        }
+
+        boolean isBalloonDisabledByDefault = 
AsyncDataProvider.isBalloonDisabledByDefault(osType,
+                        cluster.getcompatibility_version());
+
+        getMemoryBalloonDeviceEnabled().setEntity(!isBalloonDisabledByDefault);
+    }
+
     private void initFirstBootDevice()
     {
         EntityModel tempVar = new EntityModel();


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7803e45f07539090e5527ebc81bbc6c31df4e120
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Gustavo Frederico Temple Pedrosa <gustavo.pedr...@eldorado.org.br>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to