[ovirt-users] API Snapshot removal ending event
Luca 'remix_tj' Lorenzetto
lorenzetto.luca at gmail.com
Mon Sep 25 08:49:35 UTC 2017
On Mon, Sep 25, 2017 at 8:27 AM, Lionel Caignec <caignec at cines.fr> wrote:
> Hi,
>
> For snap creation i use a loop like this to know when task is finished:
>> snap = snapshots_service.add(types.Snapshot(description=description,
> persist_memorystate=False))
>> snap_service = snapshots_service.snapshot_service(snap.id)
>> while snap.snapshot_status != types.SnapshotStatus.OK:
>
>
> is it possible to do the same think for snap deletion? i did not find anything in api doc.
Hi Lionel,
i wrote this function for deleting all the VM snapshots and waiting
the deletion:
def clean_snap_ovirt(vm_data):
vm, connection = vm_data
vms_service = connection.system_service().vms_service()
vm_service = vms_service.vm_service(vm.id)
snapshots_service = vm_service.snapshots_service()
snapshots = snapshots_service.list()
for snapshot in snapshots:
if snapshot.snapshot_type != types.SnapshotType.REGULAR:
continue
snapshot_service = snapshots_service.snapshot_service(snapshot.id)
snapshot_service.remove()
snapshot = snapshot_service.get()
while snapshot.snapshot_status == types.SnapshotStatus.LOCKED:
try:
snapshot = snapshot_service.get()
except:
break
print("Still removing snapshot of {0} ....".format(vm.name))
time.sleep(10)
vm_data is a tuple containing the connection to ovirt and the output
of a vm lookup by name
If you want to delete only specific snapshot, you have to filter out
by description, or id or something else.
Luca
--
"E' assurdo impiegare gli uomini di intelligenza eccellente per fare
calcoli che potrebbero essere affidati a chiunque se si usassero delle
macchine"
Gottfried Wilhelm von Leibnitz, Filosofo e Matematico (1646-1716)
"Internet è la più grande biblioteca del mondo.
Ma il problema è che i libri sono tutti sparsi sul pavimento"
John Allen Paulos, Matematico (1945-vivente)
Luca 'remix_tj' Lorenzetto, http://www.remixtj.net , <lorenzetto.luca at gmail.com>
More information about the Users
mailing list