Migrate oVirtBackup to sdk v4: How to create a snapshot

Hi, I'm started the migration of my backup tool [1] from sdk v3 to v4. Whats the correct REST URI to create a snapshost from a given VM and how can this be done with the SnapshotsService.add(...) method? This method needs a "snapshot" object, but currently I don't know how to obtain one from a given VM or initialize one which works with the SnapshotsService class. A REST way will also be interesting because the Python SDK is horrible documented and I plan to move to basic REST. Also the Python SDK has lots of bug's which consumes many of the migration time. For example a obtained VmService object get by the VmsService.list(with filter) method has no information about the ID but iterating over all objects from list() without filter result in usable VmService objects. This will later be documented, meanwhile I wrote a workaround. cheers gregor [1] https://github.com/wefixit-AT/oVirtBackup

On 11/04/2016 09:42 PM, gregor wrote:
Hi,
I'm started the migration of my backup tool [1] from sdk v3 to v4. Whats the correct REST URI to create a snapshost from a given VM and how can this be done with the SnapshotsService.add(...) method?
Please take a look at following example: https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/add_vm_sn...
This method needs a "snapshot" object, but currently I don't know how to obtain one from a given VM or initialize one which works with the SnapshotsService class.
A REST way will also be interesting because the Python SDK is horrible documented and I plan to move to basic REST. Also the Python SDK has lots of bug's which consumes many of the migration time. For example a obtained VmService object get by the VmsService.list(with filter) method has no information about the ID but iterating over all objects from list() without filter result in usable VmService objects. This will later be documented, meanwhile I wrote a workaround.
VmsService.list doesn't return list of VmService objects, but list of types.Vm object. So what you will see in above add_vm_snapshot example is follwoing: # Obtain types.Vm object which is actually a Python representation of # XML, which oVirt API returns, when you send request like this: # ovirt-engine/api/vms?search=name=myvm vm = vms_service.list(search='name=myvm')[0] # Locate the service that manages the snapshots of the virtual machine, # which we have found in previous step: snapshots_service = vms_service.vm_service(vm.id).snapshots_service() # Add the new snapshot to that VM: snapshots_service.add( types.Snapshot( description='My snapshot', ), ) Everything works here as expected. Can you please tell us what is confusing and what should be better documented? The documentation of SnapshotsService class is here: https://machacekondra.github.io/ovirt-engine-sdk/v4.0/latest/services.m.html... We want to improve, so the pages will contain also Python examples and maybe some tutorial. https://machacekondra.github.io/ovirt-engine-sdk/
cheers gregor
[1] https://github.com/wefixit-AT/oVirtBackup _______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users
participants (2)
-
gregor
-
Ondra Machacek