Martin Sivák has uploaded a new change for review. Change subject: [WIP] restapi: Add VM.cpuShares attribute to the API ......................................................................
[WIP] restapi: Add VM.cpuShares attribute to the API This patch adds a new argument to the calls related to VM. It is used to set the cpu allocation priority for the given VM. Change-Id: Ieb42d5b132bcf7718f4c8e6162bbbc916ac24b99 Signed-off-by: Martin Sivak <[email protected]> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java M backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd M backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java 5 files changed, 29 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/62/17462/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java index 7e7c93b..16f3257 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/RunVmParams.java @@ -28,6 +28,7 @@ private String kernel_params; private VmPayload payload; private boolean balloonEnabled; + private int cpuShares; public RunVmParams() { } @@ -214,4 +215,11 @@ public void setBalloonEnabled(boolean isBalloonEnabled) { this.balloonEnabled = isBalloonEnabled; } + public int getCpuShares() { + return cpuShares; + } + + public void setCpuShares(int cpuShares) { + this.cpuShares = cpuShares; + } } 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 2a1c526..948f8c2 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 @@ -2031,6 +2031,7 @@ <xs:element ref="status" minOccurs="0" maxOccurs="1"/> <xs:element name="memory" type="xs:long" minOccurs="0"/> <xs:element name="cpu" type="CPU" minOccurs="0"/> + <xs:element name="cpu_shares" type="xs:int" minOccurs="0" maxOccurs="1"/> <xs:element name="os" type="OperatingSystem" minOccurs="0"/> <xs:element ref="cluster" minOccurs="0" maxOccurs="1"/> <xs:element ref="storage_domain" minOccurs="0" maxOccurs="1"/> @@ -2223,6 +2224,7 @@ <xs:element ref="status" minOccurs="0" maxOccurs="1"/> <xs:element name="memory" type="xs:long" minOccurs="0"/> <xs:element name="cpu" type="CPU" minOccurs="0"/> + <xs:element name="cpu_shares" type="xs:int" minOccurs="0" maxOccurs="1"/> <xs:element name="os" type="OperatingSystem" minOccurs="0"/> <xs:element name="high_availability" type="HighAvailability" minOccurs="0"/> <xs:element name="display" type="Display" minOccurs="0" maxOccurs="1"/> diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml index ed9529a..0f5ea07 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml @@ -60,6 +60,7 @@ vm.os.cmdline: xs:string vm.cpu.mode: xs:string vm.cpu.topology.cores: xs:int + vm.cpu_shares: xs:int vm.memory: xs:long vm.high_availability.priority: xs:int vm.high_availability.enabled: xs:boolean @@ -131,6 +132,7 @@ vm.delete_protected: xs:boolean vm.cpu.mode: xs:string vm.cpu.topology.sockets: xs:int + vm.cpu_shares: xs:int vm.placement_policy.affinity: xs:string vm.placement_policy.host.id|name: xs:string vm.origin: xs:string @@ -159,6 +161,7 @@ vm.display.keyboard_layout: xs:string vm.os.cmdline: xs:string vm.cpu.topology.cores: xs:int + vm.cpu_shares: xs:int vm.memory: xs:long vm.memory_policy.guaranteed: xs:long vm.high_availability.priority: xs:int @@ -2467,6 +2470,7 @@ template.os.type: xs:string template.os.boot--COLLECTION: {boot.dev: 'xs:string'} template.cpu.topology.sockets: xs:int + template.cpu_shares: xs:int template.os.kernel: xs:string template.display.type: xs:string template.display.monitors: xs:int @@ -2506,6 +2510,7 @@ template.os.type: xs:string template.os.boot--COLLECTION: {boot.dev: 'xs:string'} template.cpu.topology.sockets: xs:int + template.cpu_shares: xs:int template.os.kernel: xs:string template.display.type: xs:string template.display.monitors: xs:int diff --git a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java index 5509a16..15a3fab 100644 --- a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java +++ b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/TemplateMapper.java @@ -79,6 +79,9 @@ entity.setNumOfSockets(model.getCpu().getTopology().getSockets()); } } + if (model.isSetCpuShares()) { + entity.setCpuShares(model.getCpuShares()); + } if (model.isSetOs()) { if (model.getOs().isSetType()) { OsType osType = OsType.fromValue(model.getOs().getType()); @@ -186,6 +189,9 @@ if (model.getCpu().getTopology().getSockets()!=null) { staticVm.setNumOfSockets(model.getCpu().getTopology().getSockets()); } + } + if (model.isSetCpuShares()) { + staticVm.setCpuShares(model.getCpuShares()); } if (model.isSetOs()) { if (model.getOs().isSetType()) { @@ -295,6 +301,7 @@ topology.setCores(entity.getNumOfCpus() / entity.getNumOfSockets()); model.setCpu(new CPU()); model.getCpu().setTopology(topology); + model.setCpuShares(entity.getCpuShares()); if (entity.getDefaultDisplayType() != null) { model.setDisplay(new Display()); model.getDisplay().setType(VmMapper.map(entity.getDefaultDisplayType(), null)); diff --git a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java index cc5f463..7c8fb44 100644 --- a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java +++ b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java @@ -149,6 +149,9 @@ staticVm.setCpuPinning(cpuTuneToString(vm.getCpu().getCpuTune())); } } + if (vm.isSetCpuShares()) { + staticVm.setCpuShares(vm.getCpuShares()); + } if (vm.isSetOs()) { if (vm.getOs().isSetType()) { OsType osType = OsType.fromValue(vm.getOs().getType()); @@ -330,6 +333,7 @@ } cpu.setCpuTune(stringToCpuTune(entity.getCpuPinning())); cpu.setTopology(topology); + model.setCpuShares(entity.getCpuShares()); if (entity.getVmPoolId() != null) { VmPool pool = new VmPool(); pool.setId(entity.getVmPoolId().toString()); @@ -492,6 +496,9 @@ } } } + if (vm.isSetCpuShares()) { + params.setCpuShares(vm.getCpuShares()); + } return params; } -- To view, visit http://gerrit.ovirt.org/17462 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ieb42d5b132bcf7718f4c8e6162bbbc916ac24b99 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Sivák <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
