@@ -0,0 +1,2089 @@
+import os%0A%0Aimport blivet%0Afrom blivet.size import Size%0Afrom blivet.util import set_up_logging, create_sparse_tempfile%0Afrom blivet.devices import PartitionDevice%0A%0Aset_up_logging()%0Ab = blivet.Blivet()   # create an instance of Blivet (don't add system devices)%0A%0A# create two disk image files on which to create new devices%0Adisk1_file = create_sparse_tempfile(%22disk1%22, Size(%22100GiB%22))%0Ab.disk_images%5B%22disk1%22%5D = disk1_file%0A%0Ab.reset()%0A%0Atry:%0A    disk1 = b.devicetree.get_device_by_name(%22disk1%22)%0A%0A    fmt = blivet.formats.get_format(%22disklabel%22, device=disk1.path,%0A                                    label_type=%22msdos%22)%0A    ac = blivet.deviceaction.ActionCreateFormat(device=disk1, fmt=fmt)%0A    b.devicetree.actions.add(ac)%0A%0A    # new 5 GiB partition on disk1%0A    dev = PartitionDevice(name=%22req%25d%22 %25 b.next_id,%0A                          size=Size(%225 GiB%22), parents=%5Bdisk1%5D)%0A%0A    # low level actions API is usually hidden when using create_device() and format_device()%0A    # helper functions, working with actions is useful when offering undo/redo functionality%0A    ac = blivet.deviceaction.ActionCreateDevice(device=dev)%0A    b.devicetree.actions.add(ac)%0A%0A    fmt = blivet.formats.get_format(%22ext4%22, device=dev.path)%0A    ac = blivet.deviceaction.ActionCreateFormat(device=dev, fmt=fmt)%0A    b.devicetree.actions.add(ac)%0A%0A    # remove last action and format the partition to XFS instead%0A    b.devicetree.actions.remove(ac)%0A%0A    fmt = blivet.formats.get_format(%22xfs%22, device=dev.path)%0A    ac = blivet.deviceaction.ActionCreateFormat(device=dev, fmt=fmt)%0A    b.devicetree.actions.add(ac)%0A%0A    # now remove the format completely%0A    ac = blivet.deviceaction.ActionDestroyFormat(device=dev)%0A    b.devicetree.actions.add(ac)%0A%0A    # remove redundant/obsolete actions, this will remove the last two actions:%0A    # we don't really need to create and immediately remove the filesystem%0A    b.devicetree.actions.prune()%0A%0A    # print all currently scheduled actions%0A    for action in b.devicetree.actions.find():%0A        print(action)%0A%0Afinally:%0A    b.devicetree.teardown_disk_images()%0A    os.unlink(disk1_file)%0A

Add example for working with actions