[ovirt-users] Python API question
Karli Sjöberg
karli.sjoberg at slu.se
Fri Jan 15 01:19:49 EST 2016
fre 2016-01-15 klockan 12:23 +0800 skrev Colin Coe:
> Hi all
>
>
> I've written a Python script to take nightly snapshots of VMs which
> are kept for x days. After x days the snapshot is deleted.
>
>
> I can't work out how to wait for the snapshot deletion to complete. I
> know how to do it for creating the snapshot but I've not been able to
> get it right for the deletion.
>
>
>
> api.vms.get(VM_NAME).snapshots.add(params.Snapshot(description=SNAPSHOT_NAME, vm=api.vms.get(VM_NAME), persist_memorystate=True))
> while api.vms.get(VM_NAME).status.state == 'image_locked':
> sleep(1)
>
>
> Any ideas?
We take a snapshot just after a VM creation, just to have a point of
origin to roll back to in case of total f-up:) Looks like this:
while api.vms.get(VM_NAME).snapshots.list()[1].get_snapshot_status() ==
'locked':
In our case, we only have one snapshot at that time though, since the VM
has just been created. Your code would have to be more complex to find
the most recent one, I´d think.
HTH
/K
>
>
> Thanks
>
>
> CC
> _______________________________________________
> Users mailing list
> Users at ovirt.org
> http://lists.ovirt.org/mailman/listinfo/users
More information about the Users
mailing list