diskimage_builder.block_device.level1 package¶
Submodules¶
diskimage_builder.block_device.level1.lvm module¶
- class diskimage_builder.block_device.level1.lvm.LVMNode(name, state, pvs, lvs, vgs)¶
Bases:
NodeBase
- cleanup()¶
Cleanup actions
Actions to taken when
dib-block-device cleanup
is called. This is the cleanup path in the success case. The nodes are called in the reverse order tocreate()
- Returns:
None
- create()¶
Main creation driver
This is the main driver function. After the graph is linearised, each node has it’s
create()
function called.- Raises:
Exception – A failure should raise an exception. This will initiate a rollback. See
Nodebase.add_rollback()
.- Returns:
None
- get_edges()¶
Return the dependencies/edges for this node
This function will be called after all nodes are created (this is because some plugins need to know the global state of all nodes to decide their dependencies).
This function returns a tuple with two lists
edges_from
: a list of node names that point to usedges_to
: a list of node names we point to
In most cases, node creation will have saved a single parent that was given in the
base
parameter of the configuration. A usual return might look like:def get_edges(self): return ( [self.base], [] )
Some nodes (
level0
) don’t have a base, however
- class diskimage_builder.block_device.level1.lvm.LVMPlugin(config, defaults, state)¶
Bases:
PluginBase
- class diskimage_builder.block_device.level1.lvm.LvsNode(name, state, base, options, size, extents, segtype, thin_pool)¶
Bases:
NodeBase
- create()¶
Main creation driver
This is the main driver function. After the graph is linearised, each node has it’s
create()
function called.- Raises:
Exception – A failure should raise an exception. This will initiate a rollback. See
Nodebase.add_rollback()
.- Returns:
None
- get_edges()¶
Return the dependencies/edges for this node
This function will be called after all nodes are created (this is because some plugins need to know the global state of all nodes to decide their dependencies).
This function returns a tuple with two lists
edges_from
: a list of node names that point to usedges_to
: a list of node names we point to
In most cases, node creation will have saved a single parent that was given in the
base
parameter of the configuration. A usual return might look like:def get_edges(self): return ( [self.base], [] )
Some nodes (
level0
) don’t have a base, however
- class diskimage_builder.block_device.level1.lvm.PvsNode(name, state, base, options)¶
Bases:
NodeBase
- create()¶
Main creation driver
This is the main driver function. After the graph is linearised, each node has it’s
create()
function called.- Raises:
Exception – A failure should raise an exception. This will initiate a rollback. See
Nodebase.add_rollback()
.- Returns:
None
- get_edges()¶
Return the dependencies/edges for this node
This function will be called after all nodes are created (this is because some plugins need to know the global state of all nodes to decide their dependencies).
This function returns a tuple with two lists
edges_from
: a list of node names that point to usedges_to
: a list of node names we point to
In most cases, node creation will have saved a single parent that was given in the
base
parameter of the configuration. A usual return might look like:def get_edges(self): return ( [self.base], [] )
Some nodes (
level0
) don’t have a base, however
- class diskimage_builder.block_device.level1.lvm.VgsNode(name, state, base, options)¶
Bases:
NodeBase
- create()¶
Main creation driver
This is the main driver function. After the graph is linearised, each node has it’s
create()
function called.- Raises:
Exception – A failure should raise an exception. This will initiate a rollback. See
Nodebase.add_rollback()
.- Returns:
None
- get_edges()¶
Return the dependencies/edges for this node
This function will be called after all nodes are created (this is because some plugins need to know the global state of all nodes to decide their dependencies).
This function returns a tuple with two lists
edges_from
: a list of node names that point to usedges_to
: a list of node names we point to
In most cases, node creation will have saved a single parent that was given in the
base
parameter of the configuration. A usual return might look like:def get_edges(self): return ( [self.base], [] )
Some nodes (
level0
) don’t have a base, however
- diskimage_builder.block_device.level1.lvm.lvremove(device_name)¶
- diskimage_builder.block_device.level1.lvm.vgremove(vg_name)¶
diskimage_builder.block_device.level1.mbr module¶
- class diskimage_builder.block_device.level1.mbr.MBR(name, disk_size, alignment)¶
Bases:
object
MBR Disk / Partition Table Layout
Primary partitions are created first - and must also be passed in first.
The extended partition layout is done in the way, that there is one entry in the MBR (the last) that uses the whole disk. EBR (extended boot records) are used to describe the partitions themselves. This has the advantage, that the same procedure can be used for all partitions and arbitrarily many partitions can be created in the same way (the EBR is placed as block 0 in each partition itself).
In conjunction with a fixed and ‘fits all’ partition alignment the major design focus is maximum performance for the installed image (vs. minimal size).
Because of the chosen default alignment of 1MiB there will be (1MiB - 512B) unused disk space for the MBR and also the same size unused in every partition.
Assuming that 512 byte blocks are used, the resulting layout for extended partitions looks like (blocks offset in extended partition given):
Offset
Description
0
MBR - 2047 blocks unused
2048
EBR for partition 1 - 2047 blocks unused
4096
Start of data for partition 1
…
…
X
EBR for partition N - 2047 blocks unused
X+2048
Start of data for partition N
Direct (native) writing of MBR, EBR (partition table) is implemented - no other partitioning library or tools is used - to be sure to get the correct CHS and alignment for a wide range of host systems.
- MBR_offset_disk_id = 440¶
- MBR_offset_first_partition_table_entry = 446¶
- MBR_offset_signature = 510¶
- MBR_partition_type_extended_chs = 5¶
- MBR_partition_type_extended_lba = 15¶
- MBR_signature = 43605¶
- add_extended_partition(bootflag, size, ptype)¶
- add_partition(primaryflag, bootflag, size, ptype)¶
Adds a partition with the given type and size
- add_primary_partition(bootflag, size, ptype)¶
- align(blockno)¶
Align the blockno to next alignment count
- bytes_per_sector = 512¶
- compute_partition_lbas(abs_start, size)¶
- encode_chs(cylinders, heads, sectors)¶
Encodes a CHS triple into disk format
- free()¶
Returns the free (not yet partitioned) size
- heads_per_cylinder = 254¶
- lba2chs(lba)¶
Converts a LBA block number to CHS
If the LBA block number is bigger than the max (1023, 63, 254) the maximum is returned.
- max_cylinders = 1023¶
- sectors_per_track = 63¶
- write_mbr()¶
Write MBR
This method writes the MBR to disk. It creates a random disk id as well that it creates the extended partition (as first partition) which uses the whole disk.
- write_mbr_signature(blockno)¶
Writes the MBR/EBR signature to a block
The signature consists of a 0xAA55 in the last two bytes of the block.
- write_partition_entry(bootflag, blockno, entry, ptype, lba_start, lba_length)¶
Writes a partition entry
The entries are always the same and contain 16 bytes. The MBR and also the EBR use the same format.
diskimage_builder.block_device.level1.partition module¶
- class diskimage_builder.block_device.level1.partition.PartitionNode(config, state, parent, prev_partition)¶
Bases:
NodeBase
- cleanup()¶
Cleanup actions
Actions to taken when
dib-block-device cleanup
is called. This is the cleanup path in the success case. The nodes are called in the reverse order tocreate()
- Returns:
None
- create()¶
Main creation driver
This is the main driver function. After the graph is linearised, each node has it’s
create()
function called.- Raises:
Exception – A failure should raise an exception. This will initiate a rollback. See
Nodebase.add_rollback()
.- Returns:
None
- flag_boot = 1¶
- flag_primary = 2¶
- get_edges()¶
Return the dependencies/edges for this node
This function will be called after all nodes are created (this is because some plugins need to know the global state of all nodes to decide their dependencies).
This function returns a tuple with two lists
edges_from
: a list of node names that point to usedges_to
: a list of node names we point to
In most cases, node creation will have saved a single parent that was given in the
base
parameter of the configuration. A usual return might look like:def get_edges(self): return ( [self.base], [] )
Some nodes (
level0
) don’t have a base, however
- get_flags()¶
- get_size()¶
- get_type()¶