[ovirt-users] ovirt python sdk and starting stateless vm

Ondra Machacek omachace at redhat.com
Mon Sep 26 10:10:30 UTC 2016

On 09/26/2016 11:41 AM, Jiří Sléžka wrote:
> Hello,
> I am testing some from scratch deployment so I created a stateless vm
> and wrote small python script to shutdown and start the vm again (to
> revert vm state to starting point).
> http://pastebin.com/b5yTFEkN
> problem is that after stopping the vm there is a running operation of
> snapshot removal and when script try to start the vm it fails with
> Failed to Start VM:
> status: 409
> reason: Conflict
> detail: Cannot run VM. Related operation is currently in progress.
> Please try again later.
> Is there a cleaner way than checking status and looping or waiting some
> time to end of this operation? (desclaimer: I am new to python so please
> don't hit me :-)

Unfortunatelly, no. You always have to poll the API to check the status
of the operation.

Just for info, we have new Python SDK version 4[1]. Python SDK version
3 will be removed someday in future. So you would have to migrate your
scripts, so maybe better to write it in version 4 now, then rewrite it

And also, if you don't know Python, but you know Ansible, you can use 
Ansible VMs module[2].

[1] - https://github.com/oVirt/ovirt-engine-sdk/tree/master/sdk
[2] - http://docs.ansible.com/ansible/ovirt_vms_module.html

> Cheers, Jiri
> _______________________________________________
> Users mailing list
> Users at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users

More information about the Users mailing list