[Users] How to change number of cpu cores in Ovirt 3.1 with the python sdk.

I am using Ovirt 3.1 with the ovirt-engine-sdk. I have written a python script using this sdk but I can't seem to get the parameters right to change the cpu cores when creating the vm. All the other parameters I want to change works just fine. Does anyone have an example on how to do this. Thanks Don

On 09/24/2012 09:56 PM, Don Dupuis wrote:
I am using Ovirt 3.1 with the ovirt-engine-sdk. I have written a python script using this sdk but I can't seem to get the parameters right to change the cpu cores when creating the vm. All the other parameters I want to change works just fine. Does anyone have an example on how to do this.
any reason you are trying to change number of cores per socket and not just the number of sockets? the API has: <cpu> <topology cores="1" sockets="1"/> </cpu>

I know the layout of the xml stuff, but I am trying to use the python sdk code such as an example vm_os = params.OperatingSystems(boot=[params.Boot(dev="hd")]) Don On Mon, Sep 24, 2012 at 4:40 PM, Itamar Heim <iheim@redhat.com> wrote:
On 09/24/2012 09:56 PM, Don Dupuis wrote:
I am using Ovirt 3.1 with the ovirt-engine-sdk. I have written a python script using this sdk but I can't seem to get the parameters right to change the cpu cores when creating the vm. All the other parameters I want to change works just fine. Does anyone have an example on how to do this.
any reason you are trying to change number of cores per socket and not just the number of sockets?
the API has: <cpu> <topology cores="1" sockets="1"/> </cpu>

----- Original Message -----
From: "Don Dupuis" <dondster@gmail.com> To: "Itamar Heim" <iheim@redhat.com> Cc: users@ovirt.org Sent: Monday, September 24, 2012 8:08:40 PM Subject: Re: [Users] How to change number of cpu cores in Ovirt 3.1 with the python sdk.
I know the layout of the xml stuff, but I am trying to use the python sdk code such as an example
vm_os = params.OperatingSystems(boot=[params.Boot(dev="hd")])
Don
I think you want params.CpuTopology. I can't work out how to actually add that to the VM creation request though, I assigned it to the cpu parameter and didn't get an error but I also didn't get a VM with the assigned number of cores/sockets. Steve

Steve That is exactly the same outcome that I was getting. Don On Tue, Sep 25, 2012 at 9:44 AM, Steve Gordon <sgordon@redhat.com> wrote:
----- Original Message -----
From: "Don Dupuis" <dondster@gmail.com> To: "Itamar Heim" <iheim@redhat.com> Cc: users@ovirt.org Sent: Monday, September 24, 2012 8:08:40 PM Subject: Re: [Users] How to change number of cpu cores in Ovirt 3.1 with the python sdk.
I know the layout of the xml stuff, but I am trying to use the python sdk code such as an example
vm_os = params.OperatingSystems(boot=[params.Boot(dev="hd")])
Don
I think you want params.CpuTopology. I can't work out how to actually add that to the VM creation request though, I assigned it to the cpu parameter and didn't get an error but I also didn't get a VM with the assigned number of cores/sockets.
Steve

----- Original Message -----
From: "Steve Gordon" <sgordon@redhat.com> To: "Don Dupuis" <dondster@gmail.com> Cc: users@ovirt.org Sent: Tuesday, September 25, 2012 10:44:31 AM Subject: Re: [Users] How to change number of cpu cores in Ovirt 3.1 with the python sdk.
----- Original Message -----
From: "Don Dupuis" <dondster@gmail.com> To: "Itamar Heim" <iheim@redhat.com> Cc: users@ovirt.org Sent: Monday, September 24, 2012 8:08:40 PM Subject: Re: [Users] How to change number of cpu cores in Ovirt 3.1 with the python sdk.
I know the layout of the xml stuff, but I am trying to use the python sdk code such as an example
vm_os = params.OperatingSystems(boot=[params.Boot(dev="hd")])
Don
I think you want params.CpuTopology. I can't work out how to actually add that to the VM creation request though, I assigned it to the cpu parameter and didn't get an error but I also didn't get a VM with the assigned number of cores/sockets.
Steve
Worked it out. You need to define the CPU topology parameters: vm_cpu_top = params.CpuTopology(cores=2, sockets=2) Then use that to define the CPU parameters: vm_cpu = params.CPU(topology=vm_cpu_top) Finally you pass that in your VM creation request (assume here that I have set the other vm_* variables referenced earlier): vm_request = params.VM(name=vm_name, memory=vm_memory, cluster=vm_cluster, template=vm_template, os=vm_os, cpu=vm_cpu) vm = api.vms.add(vm_request) Steve

Steve THANKS!!! That did the trick. I was originally trying it like this vm_cpu = params.CPU(topology=[params.CpuTopology(cores=4, sockets=1)]) Don On Tue, Sep 25, 2012 at 9:50 AM, Steve Gordon <sgordon@redhat.com> wrote:
----- Original Message -----
From: "Steve Gordon" <sgordon@redhat.com> To: "Don Dupuis" <dondster@gmail.com> Cc: users@ovirt.org Sent: Tuesday, September 25, 2012 10:44:31 AM Subject: Re: [Users] How to change number of cpu cores in Ovirt 3.1 with the python sdk.
----- Original Message -----
From: "Don Dupuis" <dondster@gmail.com> To: "Itamar Heim" <iheim@redhat.com> Cc: users@ovirt.org Sent: Monday, September 24, 2012 8:08:40 PM Subject: Re: [Users] How to change number of cpu cores in Ovirt 3.1 with the python sdk.
I know the layout of the xml stuff, but I am trying to use the python sdk code such as an example
vm_os = params.OperatingSystems(boot=[params.Boot(dev="hd")])
Don
I think you want params.CpuTopology. I can't work out how to actually add that to the VM creation request though, I assigned it to the cpu parameter and didn't get an error but I also didn't get a VM with the assigned number of cores/sockets.
Steve
Worked it out. You need to define the CPU topology parameters:
vm_cpu_top = params.CpuTopology(cores=2, sockets=2)
Then use that to define the CPU parameters:
vm_cpu = params.CPU(topology=vm_cpu_top)
Finally you pass that in your VM creation request (assume here that I have set the other vm_* variables referenced earlier):
vm_request = params.VM(name=vm_name, memory=vm_memory, cluster=vm_cluster, template=vm_template, os=vm_os, cpu=vm_cpu) vm = api.vms.add(vm_request)
Steve

----- Original Message -----
From: "Don Dupuis" <dondster@gmail.com> To: "Steve Gordon" <sgordon@redhat.com> Cc: users@ovirt.org Sent: Tuesday, September 25, 2012 11:03:44 AM Subject: Re: [Users] How to change number of cpu cores in Ovirt 3.1 with the python sdk.
Steve
THANKS!!! That did the trick.
I was originally trying it like this
vm_cpu = params.CPU(topology=[params.CpuTopology(cores=4, sockets=1)])
Don
In the params.OperatingSystem(boot=[params.Boot(dev="hd")]) example the reason you pass a list (denoted by the square brackets) is that the VM can have a number of boot devices which will be tried in order. A VM can only have one CPU topology though which is why the topology argument shouldn't be a list. That is my understanding anyway ;). Steve

Steve Thanks for explaining it. I am still new to python. Don On Tue, Sep 25, 2012 at 10:32 AM, Steve Gordon <sgordon@redhat.com> wrote:
----- Original Message -----
From: "Don Dupuis" <dondster@gmail.com> To: "Steve Gordon" <sgordon@redhat.com> Cc: users@ovirt.org Sent: Tuesday, September 25, 2012 11:03:44 AM Subject: Re: [Users] How to change number of cpu cores in Ovirt 3.1 with the python sdk.
Steve
THANKS!!! That did the trick.
I was originally trying it like this
vm_cpu = params.CPU(topology=[params.CpuTopology(cores=4, sockets=1)])
Don
In the params.OperatingSystem(boot=[params.Boot(dev="hd")]) example the reason you pass a list (denoted by the square brackets) is that the VM can have a number of boot devices which will be tried in order. A VM can only have one CPU topology though which is why the topology argument shouldn't be a list. That is my understanding anyway ;).
Steve

Well done Steve!, Don, Use method/s __doc__, you'll find there how to build parameters holder, vm.add() for instance, looks like this: ... [@param vm.os.boot: collection] { [@ivar boot.dev: string] } ... [@param vm.cpu.topology.cores: int] ... as you can see, vm.os.boot is collection of boot.dev, while vm.cpu.topology is a type. On 09/25/2012 05:32 PM, Steve Gordon wrote:
----- Original Message -----
From: "Don Dupuis" <dondster@gmail.com> To: "Steve Gordon" <sgordon@redhat.com> Cc: users@ovirt.org Sent: Tuesday, September 25, 2012 11:03:44 AM Subject: Re: [Users] How to change number of cpu cores in Ovirt 3.1 with the python sdk.
Steve
THANKS!!! That did the trick.
I was originally trying it like this
vm_cpu = params.CPU(topology=[params.CpuTopology(cores=4, sockets=1)])
Don
In the params.OperatingSystem(boot=[params.Boot(dev="hd")]) example the reason you pass a list (denoted by the square brackets) is that the VM can have a number of boot devices which will be tried in order. A VM can only have one CPU topology though which is why the topology argument shouldn't be a list. That is my understanding anyway ;).
Steve _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
-- Michael Pasternak RedHat, ENG-Virtualization R&D

Thanks I did find that information yesterday. Thanks for explaining the detail. Also thanks for the quick response on the mailing list. Don On Thu, Sep 27, 2012 at 5:23 AM, Michael Pasternak <mpastern@redhat.com> wrote:
Well done Steve!,
Don,
Use method/s __doc__, you'll find there how to build parameters holder, vm.add() for instance, looks like this:
... [@param vm.os.boot: collection] { [@ivar boot.dev: string] } ... [@param vm.cpu.topology.cores: int] ...
as you can see, vm.os.boot is collection of boot.dev, while vm.cpu.topology is a type.
On 09/25/2012 05:32 PM, Steve Gordon wrote:
----- Original Message -----
From: "Don Dupuis" <dondster@gmail.com> To: "Steve Gordon" <sgordon@redhat.com> Cc: users@ovirt.org Sent: Tuesday, September 25, 2012 11:03:44 AM Subject: Re: [Users] How to change number of cpu cores in Ovirt 3.1 with the python sdk.
Steve
THANKS!!! That did the trick.
I was originally trying it like this
vm_cpu = params.CPU(topology=[params.CpuTopology(cores=4, sockets=1)])
Don
In the params.OperatingSystem(boot=[params.Boot(dev="hd")]) example the reason you pass a list (denoted by the square brackets) is that the VM can have a number of boot devices which will be tried in order. A VM can only have one CPU topology though which is why the topology argument shouldn't be a list. That is my understanding anyway ;).
Steve _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
--
Michael Pasternak RedHat, ENG-Virtualization R&D
participants (4)
-
Don Dupuis
-
Itamar Heim
-
Michael Pasternak
-
Steve Gordon