Greg Padgett has uploaded a new change for review.

Change subject: WIP restapi: Add fields for CPU Overcommit (4/5)
......................................................................

WIP restapi: Add fields for CPU Overcommit (4/5)

This patch series adds support for CPU Overcommitment based on counting
host threads as cores for the purpose of VM startup/shutdown/migration.

Patch 4: Allow reporting and setting of new fields for overcommitment
from the REST API:

 vds_dynamic.cpu_ht_enabled - boolean, host supports hyperthreading
 vds_dynamic.vdsm_count_threads_as_cores - boolean, corresponds to
     vdsm.conf option report_host_threads_as_cores
 vds_groups.count_threads_as_cores - boolean, whether overcommitment
     option is enabled by user

Change-Id: Iee8eebee7db2611276f58169aef196053542c7a5
Signed-off-by: Greg Padgett <gpadg...@redhat.com>
---
M 
backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
M 
backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/ClusterMapper.java
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
M 
backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java
5 files changed, 31 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/69/10169/1

diff --git 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
index 6a9d2e7..dbc4a7f 100644
--- 
a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
+++ 
b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd
@@ -401,6 +401,20 @@
           </xs:appinfo>
         </xs:annotation>
     </xs:attribute>
+    <xs:attribute name="ht_enabled" type="xs:boolean" use="optional">
+        <xs:annotation>
+          <xs:appinfo>
+            <jaxb:property generateIsSetMethod="false"/>
+          </xs:appinfo>
+        </xs:annotation>
+    </xs:attribute>
+    <xs:attribute name="vdsm_count_threads_as_cores" type="xs:boolean" 
use="optional">
+        <xs:annotation>
+          <xs:appinfo>
+            <jaxb:property generateIsSetMethod="false"/>
+          </xs:appinfo>
+        </xs:annotation>
+    </xs:attribute>
   </xs:complexType>
 
   <xs:element name="vcpu_pin" type="VCpuPin"/>
@@ -1031,6 +1045,7 @@
           <xs:element name="error_handling" type="ErrorHandling" minOccurs="0" 
maxOccurs="1"/>          
           <xs:element name="virt_service" type="xs:boolean" minOccurs="0" 
maxOccurs="1"/>
           <xs:element name="gluster_service" type="xs:boolean" minOccurs="0" 
maxOccurs="1"/>
+          <xs:element name="count_threads_as_cores" type="xs:boolean" 
minOccurs="0" maxOccurs="1"/>
           <!-- Also a rel="networks" link -->
         </xs:sequence>
       </xs:extension>
diff --git 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java
 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java
index 0edaaa8..d3794b9 100644
--- 
a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java
+++ 
b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/utils/FeaturesHelper.java
@@ -176,6 +176,8 @@
         feature.getHost().setCpu(new CPU());
         feature.getHost().getCpu().setTopology(new CpuTopology());
         feature.getHost().getCpu().getTopology().setSockets(4);
+        feature.getHost().getCpu().getTopology().setHtEnabled(true);
+        
feature.getHost().getCpu().getTopology().setVdsmCountThreadsAsCores(false);
         features.getFeature().add(feature);
     }
 
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/ClusterMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/ClusterMapper.java
index 85d818f..eee5969 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/ClusterMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/ClusterMapper.java
@@ -64,6 +64,9 @@
         if(model.isSetGlusterService()) {
             entity.setGlusterService(model.isGlusterService());
         }
+        if (model.isSetCountThreadsAsCores()) {
+            entity.setcount_threads_as_cores(model.isCountThreadsAsCores());
+        }
         return entity;
     }
 
@@ -93,6 +96,7 @@
         model.setErrorHandling(map(entity.getMigrateOnError(), 
(ErrorHandling)null));
         model.setVirtService(entity.supportsVirtService());
         model.setGlusterService(entity.supportsGlusterService());
+        model.setCountThreadsAsCores(entity.getcount_threads_as_cores());
         return model;
     }
 
diff --git 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
index c853238..71b3ce4 100644
--- 
a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
+++ 
b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/HostMapper.java
@@ -168,6 +168,12 @@
                 
cpuTopology.setCores(entity.getcpu_cores()/entity.getcpu_sockets());
             }
         }
+        if (entity.getcpu_ht_enabled() != null) {
+            cpuTopology.setHtEnabled(entity.getcpu_ht_enabled());
+        }
+        if (entity.getvdsm_count_threads_as_cores() != null) {
+            
cpuTopology.setVdsmCountThreadsAsCores(entity.getvdsm_count_threads_as_cores());
+        }
         cpu.setTopology(cpuTopology);
         cpu.setName(entity.getcpu_model());
         if (entity.getcpu_speed_mh()!=null) {
diff --git 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java
 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java
index 9d9f7a5..76cd0f3 100644
--- 
a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java
+++ 
b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/HostMapperTest.java
@@ -54,12 +54,16 @@
         vds.setId(Guid.Empty);
         vds.setcpu_cores(6);
         vds.setcpu_sockets(3);
+        vds.setcpu_ht_enabled(true);
+        vds.setvdsm_count_threads_as_cores(false);
         vds.setcpu_model("some cpu model");
         vds.setcpu_speed_mh(5.5);
         Host host = HostMapper.map(vds, (Host) null);
         assertNotNull(host.getCpu());
         assertEquals(new Integer(host.getCpu().getTopology().getCores()), new 
Integer(2));
         assertEquals(new Integer(host.getCpu().getTopology().getSockets()), 
new Integer(3));
+        assertEquals(new Boolean(host.getCpu().getTopology().isHtEnabled()), 
new Boolean(true));
+        assertEquals(new 
Boolean(host.getCpu().getTopology().isVdsmCountThreadsAsCores()), new 
Boolean(false));
         assertEquals(host.getCpu().getName(), "some cpu model");
         assertEquals(host.getCpu().getSpeed(), new BigDecimal(5.5));
     }


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

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

Reply via email to