You can do that using something like: snapshot_service = snapshots_service.snapshot_service(snapshot.id) snapshot = snapshot_service.get() if snapshot.snapshot_status == types.SnapshotStatus.OK: ...
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]): correlation_id = uuid.uuid4() vm1_snapshots_service.add(dead_snap1_params, query={'correlation_id': correlation_id}) testlib.assert_true_within_long( lambda: test_utils.all_jobs_finished(engine, correlation_id) ) Where all jobs finished does: try: jobs = engine.jobs_service().list( search='correlation_id=%s' % correlation_id ) except: jobs = engine.jobs_service().list() return all(job.status != types.JobStatus.STARTED for job in jobs) [1] - https://github.com/oVirt/ovirt-system-tests/blob/master/basic-suite-master/test-scenarios/004_basic_sanity.py#L360 On Mon, Apr 9, 2018 at 2:42 PM, <nico...@devels.es> wrote: > Hi, > > 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. > > 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. > > However, I'm unable to find a native way to get the status of a snapshot. > > In [1]: snap = conn.follow_link(vm.snapshots)[3] # This returns one > snapshot > > In [2]: snap.status > > In [3]: snap.status_detail > > So both status-related properties return None. I've managed to find a > "poorman's" way by doing this: > > while True: > try: > snaps_service.service(snap.id).remove() > except Error, e: > if e.code == 409: > sleep(30) > continue > else: > break > > Which works but is quite "tricky". > > Is there a better way to do this? > > Thanks. > _______________________________________________ > Users mailing list > Users@ovirt.org > http://lists.ovirt.org/mailman/listinfo/users >
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users