Hello ofri masad,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/17975

to review the following change.

Change subject: engine: Add QoS parameters to VmInfoBuilder
......................................................................

engine: Add QoS parameters to VmInfoBuilder

Added the QoS properties to the VmInfoBuilder.

Change-Id: I57bdcc24dfa99b81dc0b89f52e4007da5d6b2412
Signed-off-by: Ofri Masad <[email protected]>
---
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
M 
backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VmInfoBuilder.java
2 files changed, 36 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/75/17975/1

diff --git 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
index 52ce57f..c6da040 100644
--- 
a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
+++ 
b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/VdsProperties.java
@@ -285,6 +285,13 @@
     public static final String time = "time";
     public static final String action = "action";
 
+    // Network QoS
+    public static final String QOS_INBOUND = "inbound";
+    public static final String QOS_OUTBOUND = "outbound";
+    public static final String QOS_AVERAGE = "average";
+    public static final String QOS_PEAK = "peak";
+    public static final String QOS_BURST = "burst";
+
     public static String MigrationMethostoString(MigrationMethod method) {
         if (method == MigrationMethod.OFFLINE) {
             return offline;
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 22046b3..943a86f 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
@@ -25,6 +25,7 @@
 import org.ovirt.engine.core.common.businessentities.VmPayload;
 import org.ovirt.engine.core.common.businessentities.VolumeFormat;
 import org.ovirt.engine.core.common.businessentities.network.Network;
+import org.ovirt.engine.core.common.businessentities.network.NetworkQoS;
 import org.ovirt.engine.core.common.businessentities.network.VmInterfaceType;
 import org.ovirt.engine.core.common.businessentities.network.VmNic;
 import org.ovirt.engine.core.common.businessentities.network.VnicProfile;
@@ -545,6 +546,8 @@
             vnicProfile = 
DbFacade.getInstance().getVnicProfileDao().get(nic.getVnicProfileId());
             if (vnicProfile != null) {
                 network = 
DbFacade.getInstance().getNetworkDao().get(vnicProfile.getNetworkId());
+                addQosForDevice((Map<String, Object>) 
struct.get(VdsProperties.SpecParams),
+                        vnicProfile, vm.getVdsGroupCompatibilityVersion());
             }
         }
 
@@ -563,6 +566,32 @@
 
     }
 
+    private static void addQosForDevice(Map<String, Object> specParams, 
VnicProfile vnicProfile, Version vdsGroupCompatibilityVersion) {
+        if (FeatureSupported.networkQoS(vdsGroupCompatibilityVersion)
+                && vnicProfile.getNetworkQosId() != null) {
+            NetworkQoS networkQoS = 
DbFacade.getInstance().getQosDao().get(vnicProfile.getNetworkQosId());
+            if (networkQoS != null) {
+                if (specParams == null) {
+                    specParams = new HashMap<>();
+                }
+                if (networkQoS.getInboundAverage() > 0) {
+                    Map<String, String> inbound = new HashMap<>();
+                    inbound.put(VdsProperties.QOS_AVERAGE, 
String.valueOf(networkQoS.getInboundAverage()));
+                    inbound.put(VdsProperties.QOS_PEAK, 
String.valueOf(networkQoS.getInboundPeak()));
+                    inbound.put(VdsProperties.QOS_BURST, 
String.valueOf(networkQoS.getInboundBurst()));
+                    specParams.put(VdsProperties.QOS_INBOUND, inbound);
+                }
+                if (networkQoS.getOutboundAverage() > 0) {
+                    Map<String, String> outbound = new HashMap<>();
+                    outbound.put(VdsProperties.QOS_AVERAGE, 
String.valueOf(networkQoS.getOutboundAverage()));
+                    outbound.put(VdsProperties.QOS_PEAK, 
String.valueOf(networkQoS.getOutboundPeak()));
+                    outbound.put(VdsProperties.QOS_BURST, 
String.valueOf(networkQoS.getOutboundBurst()));
+                    specParams.put(VdsProperties.QOS_OUTBOUND, outbound);
+                }
+            }
+        }
+    }
+
     public static Map<String, String> getVnicCustomProperties(VnicProfile 
vnicProfile) {
         Map<String, String> customProperties = null;
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I57bdcc24dfa99b81dc0b89f52e4007da5d6b2412
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Alona Kaplan <[email protected]>
Gerrit-Reviewer: ofri masad <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to