<div dir="ltr"><div>You can do that using something like:</div><div> snapshot_service = snapshots_service.snapshot_service(<a href="http://snapshot.id">snapshot.id</a>)<br></div><div><div> snapshot = snapshot_service.get()</div><div> if snapshot.snapshot_status == types.SnapshotStatus.OK:</div><div> ...</div></div><div><br></div><div>But counting on the snapshot status is race prone, so in 4.2 a search by correlation id was introduced and you can do something like this (taken from ovirt-system-tests[1]):</div><div><div> correlation_id = uuid.uuid4()</div><div><br></div><div> vm1_snapshots_service.add(dead_snap1_params,</div><div> query={'correlation_id': correlation_id})</div><div><br></div><div> testlib.assert_true_within_long(</div><div> lambda:</div><div> test_utils.all_jobs_finished(engine, correlation_id)</div><div> )</div></div><div><br></div><div>Where all jobs finished does:</div><div><div> try:</div><div> jobs = engine.jobs_service().list(</div><div> search='correlation_id=%s' % correlation_id</div><div> )</div><div> except:</div><div> jobs = engine.jobs_service().list()</div><div> return all(job.status != types.JobStatus.STARTED for job in jobs)</div></div><div><br></div><div><br></div><div>[1] - <a href="https://github.com/oVirt/ovirt-system-tests/blob/master/basic-suite-master/test-scenarios/004_basic_sanity.py#L360">https://github.com/oVirt/ovirt-system-tests/blob/master/basic-suite-master/test-scenarios/004_basic_sanity.py#L360</a></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Apr 9, 2018 at 2:42 PM, <span dir="ltr"><<a href="mailto:nicolas@devels.es" target="_blank">nicolas@devels.es</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm running ovirt-engine-sdk-python 4.2.4 and I'm performing some snapshot-related tasks. I'd like to somehow control the status of the snapshot in order to know when I'll be able to run the next snapshot-related operation.<br>
<br>
For example, I'd like to create a new snapshot and then delete X oldest snapshots. After creating the snapshot I have to make sure the snapshot operation has concluded to run the deletion.<br>
<br>
However, I'm unable to find a native way to get the status of a snapshot.<br>
<br>
In [1]: snap = conn.follow_link(vm.snapshots)<wbr>[3] # This returns one snapshot<br>
<br>
In [2]: snap.status<br>
<br>
In [3]: snap.status_detail<br>
<br>
So both status-related properties return None. I've managed to find a "poorman's" way by doing this:<br>
<br>
while True:<br>
try:<br>
snaps_service.service(<a href="http://snap.id" rel="noreferrer" target="_blank">snap.id</a>)<wbr>.remove()<br>
except Error, e:<br>
if e.code == 409:<br>
sleep(30)<br>
continue<br>
else:<br>
break<br>
<br>
Which works but is quite "tricky".<br>
<br>
Is there a better way to do this?<br>
<br>
Thanks.<br>
______________________________<wbr>_________________<br>
Users mailing list<br>
<a href="mailto:Users@ovirt.org" target="_blank">Users@ovirt.org</a><br>
<a href="http://lists.ovirt.org/mailman/listinfo/users" rel="noreferrer" target="_blank">http://lists.ovirt.org/mailman<wbr>/listinfo/users</a><br>
</blockquote></div><br></div>