On Thu, Jun 21, 2018 at 2:00 PM, Benny Zlotnik <bzlot...@redhat.com> wrote:
> You could something like this (IIUC): > dead_snap1_params = types.Snapshot( > description=SNAPSHOT_DESC_1, > persist_memorystate=False, > disk_attachments=[ > types.DiskAttachment( > disk=types.Disk( > id=disk.id > ) > ) > ] > ) > > Taken from ovirt-system-tests[1] > > [1] - https://github.com/oVirt/ovirt-system-tests/blob/ > master/basic-suite-master/test-scenarios/004_basic_sanity.py#L340 > > > Hi, thanks for your input! It seems I was able to reach my target What I've done # Locate the service that manages the disk attachments of the virtual # machine: disk_attachments_service = vm_service.disk_attachments_service() # Retrieve the list of disk attachments and then the bootable disk disk_attachments = disk_attachments_service.list() bootdisk = None for disk_attachment in disk_attachments: disk = connection.follow_link(disk_attachment.disk) if disk_attachment.bootable == True: bootdisk = connection.follow_link(disk_attachment.disk) break snaps_service = vm_service.snapshots_service() snap = snaps_service.add( snapshot=types.Snapshot( description=snap_description, persist_memorystate=False, disk_attachments=[ types.DiskAttachment( disk=types.Disk( id=bootdisk.id ) ) ] ), ) logging.info( 'Sent request to create snapshot \'%s\', the id is \'%s\'.', snap.description, snap.id, ) It seems also the monitor function already present in backup.py of the sdk examples linked in my previous message is working ok, # Poll and wait till the status of the snapshot is 'ok', which means # that it is completely created: snap_service = snaps_service.snapshot_service(snap.id) while snap.snapshot_status != types.SnapshotStatus.OK: logging.info( 'Waiting till the snapshot is created, the status is now \'%s\'.', snap.snapshot_status, ) time.sleep(1) snap = snap_service.get() logging.info('The snapshot is now complete.') In fact in the log file I have INFO:root:Sent request to create snapshot 'padnpro_imp-backup-0e0c7064-bec5-429b-9ad7-cd8d1e5b25be', the id is '4135e8cb-87e8-4f09-82f5-b9ad0ed2f5be'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:Waiting till the snapshot is created, the status is now 'locked'. INFO:root:The snapshot is now complete. What if I would like to emit an event if for any reason the creation of the snapshot doesn't complete in a predefined elapsed time and manage it? I think I have also to manage the case when for any reason no disk is marked as bootable inside the VM I'm backing up... Gianluca
_______________________________________________ Users mailing list -- users@ovirt.org To unsubscribe send an email to users-le...@ovirt.org Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/users@ovirt.org/message/EP4VY26DH3GTWHC3ILKFTABSD7TP3O7T/