diff --git a/diskimage_builder/block_device/blockdevice.py b/diskimage_builder/block_device/blockdevice.py index 97e014346..c34ca1d78 100644 --- a/diskimage_builder/block_device/blockdevice.py +++ b/diskimage_builder/block_device/blockdevice.py @@ -34,13 +34,13 @@ class BlockDevice(object): # Default configuration: # one image, one partition, mounted under '/' DefaultConfig = """ -local_loop: - name: image0 +- local_loop: + name: image0 """ # This is an example of the next level config # mkfs: -# base: root_p1 +# base: root # type: ext4 # mount_point: / @@ -85,7 +85,16 @@ local_loop: # add the appropriate nodes and edges. 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 # (if it exists) if cfg_obj_name not in BlockDevice.cfg_type_map: @@ -132,8 +141,8 @@ local_loop: # result to stdout. # If there is no partition needed, pass back directly the # image. - if 'root_p1' in result: - print("%s" % result['root_p1']['device']) + if 'root' in result: + print("%s" % result['root']['device']) else: print("%s" % result['image0']['device']) diff --git a/diskimage_builder/elements/vm/environment.d/10-partitioning b/diskimage_builder/elements/vm/environment.d/10-partitioning index c7cb608c1..186ea6a1d 100644 --- a/diskimage_builder/elements/vm/environment.d/10-partitioning +++ b/diskimage_builder/elements/vm/environment.d/10-partitioning @@ -1,14 +1,14 @@ export DIB_BLOCK_DEVICE_DEFAULT_CONFIG=" -local_loop: - name: image0 +- local_loop: + name: image0 -partitioning: - base: image0 - label: mbr - partitions: - - name: root_p1 - flags: [ boot, primary ] - size: 100% +- partitioning: + base: image0 + label: mbr + partitions: + - name: root + flags: [ boot, primary ] + size: 100% " DIB_BLOCK_DEVICE_CONFIG=${DIB_BLOCK_DEVICE_CONFIG:-${DIB_BLOCK_DEVICE_DEFAULT_CONFIG}} diff --git a/doc/source/user_guide/building_an_image.rst b/doc/source/user_guide/building_an_image.rst index 4b0c436ad..2c8867346 100644 --- a/doc/source/user_guide/building_an_image.rst +++ b/doc/source/user_guide/building_an_image.rst @@ -60,7 +60,7 @@ formats are: 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. The configuration is done by means of the environment variable @@ -72,16 +72,16 @@ The default is: :: DIB_BLOCK_DEVICE_CONFIG=' - local_loop: - name: image0 + - local_loop: + name: image0 - partitioning: - base: image0 - label: mbr - partitions: - - name: root_p1 - flags: [ boot, primary ] - size: 100%' + - partitioning: + base: image0 + label: mbr + partitions: + - name: root + flags: [ boot, primary ] + size: 100%' In general each module that depends on another module has a `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). 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. Level 0 @@ -239,26 +239,26 @@ size Example: :: - partitioning: - base: image0 - label: mbr - partitions: - - name: part-01 - flags: [ boot ] - size: 1GiB - - name: part-02 - size: 100% + - partitioning: + base: image0 + label: mbr + partitions: + - name: part-01 + flags: [ boot ] + size: 1GiB + - name: part-02 + size: 100% - partitioning: - base: data_image - label: mbr - partitions: - - name: data0 - size: 33% - - name: data1 - size: 50% - - name: data2 - size: 100% + - partitioning: + base: data_image + label: mbr + partitions: + - name: data0 + size: 33% + - name: data1 + size: 50% + - name: data2 + size: 100% 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`