ofri masad has uploaded a new change for review.

Change subject: core: Change Network QoS units in the VmInfoBuilder
......................................................................

core: Change Network QoS units in the VmInfoBuilder

Since engine is using Mb and vdsm uses Kb for Network QoS, the values in
the VmInfoBuilder should have been multiplied by 1024.

Change-Id: Ieb78b8eeb8e5ae0a7c964773a4eb8fa98da4d3a5
Signed-off-by: Ofri Masad <oma...@redhat.com>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
1 file changed, 17 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/30/18030/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
index 26b6c11..de65f47 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
@@ -44,6 +44,7 @@
     private static final String USB_BUS = "usb";
     private final static String FIRST_MASTER_MODEL = "ich9-ehci1";
     private static final String CLOUD_INIT_VOL_ID = "config-2";
+    private static final int TO_KILOBITS = 1024;
 
     private final List<Map<String, Object>> devices = new 
ArrayList<Map<String, Object>>();
     private List<VmDevice> managedDevices = null;
@@ -574,28 +575,26 @@
                 if (specParams == null) {
                     specParams = new HashMap<>();
                 }
-                if (networkQoS.getInboundAverage() > 0) {
-                    Map<String, String> inbound = 
generateQoSData(networkQoS.getInboundAverage(),
-                            networkQoS.getInboundPeak(),
-                            networkQoS.getInboundBurst());
-                    specParams.put(VdsProperties.QOS_INBOUND, inbound);
-                }
-                if (networkQoS.getOutboundAverage() > 0) {
-                    Map<String, String> outbound = 
generateQoSData(networkQoS.getOutboundAverage(),
-                            networkQoS.getOutboundPeak(),
-                            networkQoS.getOutboundBurst());
-                    specParams.put(VdsProperties.QOS_OUTBOUND, outbound);
-                }
+                addQoSData(specParams, VdsProperties.QOS_INBOUND,
+                        networkQoS.getInboundAverage(),
+                        networkQoS.getInboundPeak(),
+                        networkQoS.getInboundBurst());
+                addQoSData(specParams, VdsProperties.QOS_OUTBOUND,
+                        networkQoS.getOutboundAverage(),
+                        networkQoS.getOutboundPeak(),
+                        networkQoS.getOutboundBurst());
             }
         }
     }
 
-    private static Map<String, String> generateQoSData(int average, int peak, 
int burst){
-        Map<String, String> qosData = new HashMap<>();
-        qosData.put(VdsProperties.QOS_AVERAGE, String.valueOf(average));
-        qosData.put(VdsProperties.QOS_PEAK, String.valueOf(peak));
-        qosData.put(VdsProperties.QOS_BURST, String.valueOf(burst));
-        return qosData;
+    private static void addQoSData(Map<String, Object> specParams, String 
containerName, int average, int peak, int burst){
+        if (average > 0) {
+            Map<String, String> qosData = new HashMap<>();
+            qosData.put(VdsProperties.QOS_AVERAGE, String.valueOf(average * 
TO_KILOBITS));
+            qosData.put(VdsProperties.QOS_PEAK, String.valueOf(peak * 
TO_KILOBITS));
+            qosData.put(VdsProperties.QOS_BURST, String.valueOf(burst * 
TO_KILOBITS));
+            specParams.put(containerName, qosData);
+        }
     }
 
     public static Map<String, String> getVnicCustomProperties(VnicProfile 
vnicProfile) {


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

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

Reply via email to