block-device: change top level config from dict to list
With the old configuration structure it was only possible to use one image and one partition layout. The new block-device configuration uses a list at top level; therefore it is possible to use multiple instances of each element type. Change-Id: I9db4327486b676887d6ce09609994116dbebfc89 Signed-off-by: Andreas Florath <andreas@florath.net>
This commit is contained in:
parent
3f8800832a
commit
a8953dd277
@ -34,13 +34,13 @@ class BlockDevice(object):
|
|||||||
# Default configuration:
|
# Default configuration:
|
||||||
# one image, one partition, mounted under '/'
|
# one image, one partition, mounted under '/'
|
||||||
DefaultConfig = """
|
DefaultConfig = """
|
||||||
local_loop:
|
- local_loop:
|
||||||
name: image0
|
name: image0
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# This is an example of the next level config
|
# This is an example of the next level config
|
||||||
# mkfs:
|
# mkfs:
|
||||||
# base: root_p1
|
# base: root
|
||||||
# type: ext4
|
# type: ext4
|
||||||
# mount_point: /
|
# mount_point: /
|
||||||
|
|
||||||
@ -85,7 +85,16 @@ local_loop:
|
|||||||
# add the appropriate nodes and edges.
|
# add the appropriate nodes and edges.
|
||||||
dg = Digraph()
|
dg = Digraph()
|
||||||
|
|
||||||
for cfg_obj_name, cfg_obj_val in config.items():
|
for config_entry in config:
|
||||||
|
if len(config_entry) != 1:
|
||||||
|
logger.error("Invalid config entry: more than one key "
|
||||||
|
"on top level [%s]" % config_entry)
|
||||||
|
raise BlockDeviceSetupException(
|
||||||
|
"Top level config must contain exactly one key per entry")
|
||||||
|
logger.debug("Config entry [%s]" % config_entry)
|
||||||
|
cfg_obj_name = config_entry.keys()[0]
|
||||||
|
cfg_obj_val = config_entry[cfg_obj_name]
|
||||||
|
|
||||||
# As the first step the configured objects are created
|
# As the first step the configured objects are created
|
||||||
# (if it exists)
|
# (if it exists)
|
||||||
if cfg_obj_name not in BlockDevice.cfg_type_map:
|
if cfg_obj_name not in BlockDevice.cfg_type_map:
|
||||||
@ -132,8 +141,8 @@ local_loop:
|
|||||||
# result to stdout.
|
# result to stdout.
|
||||||
# If there is no partition needed, pass back directly the
|
# If there is no partition needed, pass back directly the
|
||||||
# image.
|
# image.
|
||||||
if 'root_p1' in result:
|
if 'root' in result:
|
||||||
print("%s" % result['root_p1']['device'])
|
print("%s" % result['root']['device'])
|
||||||
else:
|
else:
|
||||||
print("%s" % result['image0']['device'])
|
print("%s" % result['image0']['device'])
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
export DIB_BLOCK_DEVICE_DEFAULT_CONFIG="
|
export DIB_BLOCK_DEVICE_DEFAULT_CONFIG="
|
||||||
local_loop:
|
- local_loop:
|
||||||
name: image0
|
name: image0
|
||||||
|
|
||||||
partitioning:
|
- partitioning:
|
||||||
base: image0
|
base: image0
|
||||||
label: mbr
|
label: mbr
|
||||||
partitions:
|
partitions:
|
||||||
- name: root_p1
|
- name: root
|
||||||
flags: [ boot, primary ]
|
flags: [ boot, primary ]
|
||||||
size: 100%
|
size: 100%
|
||||||
"
|
"
|
||||||
|
|
||||||
DIB_BLOCK_DEVICE_CONFIG=${DIB_BLOCK_DEVICE_CONFIG:-${DIB_BLOCK_DEVICE_DEFAULT_CONFIG}}
|
DIB_BLOCK_DEVICE_CONFIG=${DIB_BLOCK_DEVICE_CONFIG:-${DIB_BLOCK_DEVICE_DEFAULT_CONFIG}}
|
||||||
|
@ -60,7 +60,7 @@ formats are:
|
|||||||
Disk Image Layout
|
Disk Image Layout
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
When generating a block image (e.g. qcow2 or raw), by default one
|
When generating a vm block image (e.g. qcow2 or raw), by default one
|
||||||
image with one partition holding all files is created.
|
image with one partition holding all files is created.
|
||||||
|
|
||||||
The configuration is done by means of the environment variable
|
The configuration is done by means of the environment variable
|
||||||
@ -72,16 +72,16 @@ The default is:
|
|||||||
::
|
::
|
||||||
|
|
||||||
DIB_BLOCK_DEVICE_CONFIG='
|
DIB_BLOCK_DEVICE_CONFIG='
|
||||||
local_loop:
|
- local_loop:
|
||||||
name: image0
|
name: image0
|
||||||
|
|
||||||
partitioning:
|
- partitioning:
|
||||||
base: image0
|
base: image0
|
||||||
label: mbr
|
label: mbr
|
||||||
partitions:
|
partitions:
|
||||||
- name: root_p1
|
- name: root
|
||||||
flags: [ boot, primary ]
|
flags: [ boot, primary ]
|
||||||
size: 100%'
|
size: 100%'
|
||||||
|
|
||||||
In general each module that depends on another module has a `base`
|
In general each module that depends on another module has a `base`
|
||||||
element that points to the depending base.
|
element that points to the depending base.
|
||||||
@ -103,7 +103,7 @@ all but the `image0` will be not useable (are deleted during the
|
|||||||
build process).
|
build process).
|
||||||
|
|
||||||
Currently only one partitions is used for the image. The name of this
|
Currently only one partitions is used for the image. The name of this
|
||||||
partition must be `root_p1`. Other partitions are created but not
|
partition must be `root`. Other partitions are created but not
|
||||||
used.
|
used.
|
||||||
|
|
||||||
Level 0
|
Level 0
|
||||||
@ -239,26 +239,26 @@ size
|
|||||||
Example:
|
Example:
|
||||||
|
|
||||||
::
|
::
|
||||||
partitioning:
|
- partitioning:
|
||||||
base: image0
|
base: image0
|
||||||
label: mbr
|
label: mbr
|
||||||
partitions:
|
partitions:
|
||||||
- name: part-01
|
- name: part-01
|
||||||
flags: [ boot ]
|
flags: [ boot ]
|
||||||
size: 1GiB
|
size: 1GiB
|
||||||
- name: part-02
|
- name: part-02
|
||||||
size: 100%
|
size: 100%
|
||||||
|
|
||||||
partitioning:
|
- partitioning:
|
||||||
base: data_image
|
base: data_image
|
||||||
label: mbr
|
label: mbr
|
||||||
partitions:
|
partitions:
|
||||||
- name: data0
|
- name: data0
|
||||||
size: 33%
|
size: 33%
|
||||||
- name: data1
|
- name: data1
|
||||||
size: 50%
|
size: 50%
|
||||||
- name: data2
|
- name: data2
|
||||||
size: 100%
|
size: 100%
|
||||||
|
|
||||||
On the `image0` two partitions are created. The size of the first is
|
On the `image0` two partitions are created. The size of the first is
|
||||||
1GiB, the second uses the remaining free space. On the `data_image`
|
1GiB, the second uses the remaining free space. On the `data_image`
|
||||||
|
Loading…
Reference in New Issue
Block a user