diskimage-builder/diskimage_builder/block_device
Ian Wienand 1d1e4ccb3e Move rollback into NodeBase object
Currently we pass a reference to a global "rollback" list to create()
to keep rollback functions.  Other nodes don't need to know about
global rollback state, and by passing by reference we're giving them
the chance to mess it up for everyone else.

Add a "add_rollback()" function in NodeBase for create() calls to
register rollback calls within themselves.  As they hit rollback
points they can add a new entry.  lambda v arguments is much of a
muchness -- but this is similar to the standard atexit() call so with
go with that pattern.  A new "rollback()" call is added that the
driver will invoke on each node as it works its way backwards in case
of failure.

On error, nodes will have rollback() called in reverse order (which
then calls registered rollbacks in reverse order).

A unit test is added to test rollback behaviour

Change-Id: I65214e72c7ef607dd08f750a6d32a0b10fe97ac3
2017-06-08 17:14:20 +10:00
..
level0 Move rollback into NodeBase object 2017-06-08 17:14:20 +10:00
level1 Move rollback into NodeBase object 2017-06-08 17:14:20 +10:00
level2 Move rollback into NodeBase object 2017-06-08 17:14:20 +10:00
level3 Move rollback into NodeBase object 2017-06-08 17:14:20 +10:00
level4 Move rollback into NodeBase object 2017-06-08 17:14:20 +10:00
tests Move rollback into NodeBase object 2017-06-08 17:14:20 +10:00
__init__.py Clear __init__.py from cmd move 2017-05-11 18:52:14 +10:00
blockdevice.py Move rollback into NodeBase object 2017-06-08 17:14:20 +10:00
cmd.py Refactor: use lazy logging 2017-05-30 14:39:58 +10:00
config.py Add state to NodeBase class 2017-06-08 17:13:26 +10:00
exception.py Move exception to it's own file (again) 2017-05-20 06:44:39 +00:00
plugin.py Move rollback into NodeBase object 2017-06-08 17:14:20 +10:00
utils.py Refactor mount-point sorting 2017-05-31 11:05:50 +10:00