oVirt / ovirt-engine-sdk

oVirt Python SDK
90 stars 77 forks source link

ovirtSDK4.x edit memory and CPU ? #9

Closed Michael754267513 closed 6 years ago

Michael754267513 commented 6 years ago

ovirt3.x: update memory: vm.memory = 32 * 2 *30 vm.update() ovirt4.x: update memory: vm.memory = 32 2 **30 vm.update() # not found

mykaul commented 6 years ago

Please open issues in Bugzilla - this is a read-only mirror of our Gerrit repository. Have you looked at the APIv4 examples?

Michael754267513 commented 6 years ago

@mykaul I can`t find about editCPU and edit memory in sdk4.x, and search keywords cpu or memory the results "sdk/examples/add_instance_type.py", this example is create Resource package, for example: the VM is running to edit memory and cpu。

machacekondra commented 6 years ago

If you look for here, it's example how to update datacenter:

https://github.com/oVirt/ovirt-engine-sdk/blob/69610949da7f4ae02c7e87493fc3e48dc8b026d2/sdk/examples/update_data_center.py#L40-L54

The same way you go with VMs, but using vms_service.

vms_service = connection.system_service().vms_service()
vms = vms_service.list(search='name=myvm')[0]
vm_service = vms_service.vm_service(vm.id)
vm = vm_service.update(
    types.Vm(
        memory=32 * 2 **30,
    ),
)
Michael754267513 commented 6 years ago

TKS