From Dan Kenigsberg <danken(a)redhat.com>:
Dan Kenigsberg has submitted this change and it was merged.
Change subject: virt: Added 'prepared' context manager
......................................................................
virt: Added 'prepared' context manager
Added context manager to prepare a group of objects (for example, disk images)
for an operation. Each images must implement prepare() and teardown() methods.
When entering the context, all images are prepared in the order they are
passed. When exiting the context (or upon error) the images are torn
down in reverse order. If an exception was raised inside the context,
that exception will be propagated regardless of any exceptions that may
be thrown by teardown() methods.
Usage example:
with prepared(images):
do_some_operation(images)
Change-Id: Ibe9d04599dfc1700f215a7765775d60cb314ff0a
Signed-off-by: Shmuel Melamud <smelamud(a)redhat.com>
---
M lib/vdsm/virt/utils.py
A tests/virttests/prepared_test.py
2 files changed, 220 insertions(+), 1 deletion(-)
Approvals:
Jenkins CI: Passed CI tests
Shmuel Leib Melamud: Verified
Francesco Romani: Looks good to me, approved
--
To view, visit
https://gerrit.ovirt.org/71358
To unsubscribe, visit
https://gerrit.ovirt.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ibe9d04599dfc1700f215a7765775d60cb314ff0a
Gerrit-PatchSet: 3
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Shmuel Leib Melamud <smelamud(a)redhat.com>
Gerrit-Reviewer: Adam Litke <alitke(a)redhat.com>
Gerrit-Reviewer: Dan Kenigsberg <danken(a)redhat.com>
Gerrit-Reviewer: Francesco Romani <fromani(a)redhat.com>
Gerrit-Reviewer: Jenkins CI
Gerrit-Reviewer: Nir Soffer <nsoffer(a)redhat.com>
Gerrit-Reviewer: Shmuel Leib Melamud <smelamud(a)redhat.com>
Gerrit-Reviewer: gerrit-hooks <automation(a)ovirt.org>