Roy Golan has uploaded a new change for review.

Change subject: core: osinfo: add support for ballon device
......................................................................

core: osinfo: add support for ballon device

Change-Id: I07c39fc23ea9ffcd0e134362b225fdf3770bdeb3
Bug-Url: https://bugzilla.redhat.com/??????
Signed-off-by: Roy Golan <rgo...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java
M 
backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
M 
backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java
M packaging/conf/osinfo-defaults.properties
6 files changed, 54 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/64/33264/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java
index a362e82..e6f3de3 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/OsRepositoryQuery.java
@@ -48,6 +48,12 @@
             case GetDisplayTypes:
                 setReturnValue(osRepository.getDisplayTypes());
                 break;
+            case GetBalloonSupportMap:
+                setReturnValue(osRepository.getBalloonSupportMap());
+            break;
+            case IsBalloonEnabled:
+                
setReturnValue(osRepository.isBalloonEnabled(getParameters().getOsId(), 
getParameters().getVersion()));
+            break;
             case HasNicHotplugSupport:
                 
setReturnValue(osRepository.hasNicHotplugSupport(getParameters().getOsId(), 
getParameters().getVersion()));
                 break;
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java
index 6363423..df57009 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/osinfo/OsRepository.java
@@ -112,6 +112,20 @@
     public VmDeviceType getDisplayDevice(int osId, Version version, 
DisplayType displayType);
 
     /**
+     * @return map (osId -> compatibility version -> Boolean) that indicates 
balloon disabled for all OSs and
+     * compatibility versions
+     */
+    public Map<Integer, Map<Version, Boolean>> getBalloonSupportMap();
+
+    /**
+     * Checks if is recommended enable the OS balloon.
+     * @param osId
+     * @param version
+     * @return an boolean
+     */
+    public boolean isBalloonEnabled(int osId, Version version);
+
+    /**
      * Checks if that OS network devices support hotplug.
      * @param osId
      * @param version
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java
index cdaf5cc..4a807f3 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/queries/OsQueryParameters.java
@@ -39,6 +39,8 @@
 
     public enum OsRepositoryVerb {
         GetDisplayTypes,
+        GetBalloonSupportMap,
+        IsBalloonEnabled,
         HasNicHotplugSupport,
         GetNicHotplugSupportMap,
         GetDiskHotpluggableInterfacesMap,
diff --git 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
index d4ec245..64c32b0 100644
--- 
a/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
+++ 
b/backend/manager/modules/utils/src/main/java/org/ovirt/engine/core/utils/OsRepositoryImpl.java
@@ -350,6 +350,29 @@
     }
 
     @Override
+    public Map<Integer, Map<Version, Boolean>> getBalloonSupportMap() {
+        Map<Integer, Map<Version, Boolean>> balloonSupportMap = new 
HashMap<Integer, Map<Version, Boolean>>();
+        Set<Version> versionsWithNull = new HashSet<Version>(Version.ALL);
+        versionsWithNull.add(null);
+
+        Set<Integer> osIds = new HashSet<Integer>(getOsIds());
+        for (Integer osId : osIds) {
+            balloonSupportMap.put(osId, new HashMap<Version, Boolean>());
+
+            for (Version ver : versionsWithNull) {
+                balloonSupportMap.get(osId).put(ver, isBalloonEnabled(osId, 
ver));
+            }
+        }
+
+        return balloonSupportMap;
+    }
+
+    @Override
+    public boolean isBalloonEnabled(int osId, Version version) {
+        return getBoolean(getValueByVersion(idToUnameLookup.get(osId), 
"devices.balloon.enabled", version), false);
+    }
+
+    @Override
     public boolean hasNicHotplugSupport(int osId, Version version) {
         return getBoolean(getValueByVersion(idToUnameLookup.get(osId), 
"devices.network.hotplugSupport", version), false);
     }
diff --git 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java
 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java
index dd66445..fb8a237 100644
--- 
a/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java
+++ 
b/backend/manager/modules/utils/src/test/java/org/ovirt/engine/core/utils/OsRepositoryImplTest.java
@@ -46,6 +46,7 @@
         preferences.node("/os/rhel7/resources/minimum/ram").put("value.3.1", 
"512");
         preferences.node("/os/rhel7/resources/maximum/ram").put("value", 
"2048");
         preferences.node("/os/rhel7/devices/display/protocols").put("value", 
"vnc/cirrus,qxl/qxl");
+        preferences.node("/os/rhel7/devices/balloon/enabled").put("value", 
"true");
         preferences.node("/os/rhel7/sysprepPath").put("value", 
PATH_TO_SYSPREP);
         preferences.node("/os/rhel7/productKey").put("value", 
SOME_PRODUCT_KEY);
         preferences.node("/os/rhel7/devices/audio").put("value", SOUND_DEVICE);
@@ -166,6 +167,12 @@
         assertTrue(containsSameElements);
     }
 
+    @Test
+    public void testIsBalloonEnabled() throws Exception {
+        assertTrue(OsRepositoryImpl.INSTANCE.isBalloonEnabled(777, null));
+        
assertTrue(OsRepositoryImpl.INSTANCE.getBalloonSupportMap().get(777).get(null));
+    }
+
     public void testGetMaxPciDevices() throws Exception {
         assertTrue(OsRepositoryImpl.INSTANCE.getMaxPciDevices(777, null) == 
26);
     }
diff --git a/packaging/conf/osinfo-defaults.properties 
b/packaging/conf/osinfo-defaults.properties
index 6f1c07a..b2be6dc 100644
--- a/packaging/conf/osinfo-defaults.properties
+++ b/packaging/conf/osinfo-defaults.properties
@@ -57,6 +57,7 @@
 os.other.devices.disk.hotpluggableInterfaces.value = VirtIO_SCSI, VirtIO
 os.other.devices.disk.hotpluggableInterfaces.value.3.0 =
 
+os.other.devices.balloon.enabled.value = true
 os.other.devices.audio.value = ich6
 # See VmInterfaceType.java
 os.other.devices.network.value =  rtl8139, e1000, pv
@@ -274,6 +275,7 @@
 os.other_ppc64.bus.value = 64
 os.other_ppc64.devices.network.value = pv, spaprVlan, e1000, rtl8139
 os.other_ppc64.devices.cdInterface.value = scsi
+os.other_ppc64.devices.balloon.enabled.value = false
 os.other_ppc64.devices.diskInterfaces.value.3.3 = VirtIO, VirtIO_SCSI, 
SPAPR_VSCSI
 os.other_ppc64.devices.diskInterfaces.value.3.4 = VirtIO, VirtIO_SCSI, 
SPAPR_VSCSI
 os.other_ppc64.devices.disk.hotpluggableInterfaces.value.3.3 = VirtIO_SCSI, 
SPAPR_VSCSI


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I07c39fc23ea9ffcd0e134362b225fdf3770bdeb3
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Roy Golan <rgo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to