Skip to content

Support json/yaml config #4

@nirs

Description

@nirs

Using python for the configuration file is powerfull but require duplication - for example, here we duplicate the value of BASE_DIR and the name of the backend:

BASE_DIR = "/path/to/base-dir"
BACKENDS = {
    "block-4k": LoopDevice(
        base_dir=BASE_DIR,
        name="block-4k",
        size=GiB,
        sector_size=4096,
    ),
    ...
}

Add option to configure using yaml:

base_dir: /path/to/base-dir
backends:
  block-4k:
    backend: "loop",
    size: 1073741824
    sector_size: 4096
    ...

And json:

{
    "base_dir": "/path/to/base-dir",
    "backends": {
       "block-4k": {
          "backend": "loop",
           "size": 1073741824,
           "sector_size": 4096
        }
    }
}

Internally both formats return the same python dict, so supporting both cost nothing. yaml is shorter, easier to write and can include comments.

Not sure how stacked backeends should be described in yaml/json:

    file-4k:
      backend: file
        mount:
          backend: mount
            backend: loop
              size: 1073741824
              sector_size: 4096
    ...

This should translate to:

{
    "file-4k": File(
         Mount(
             LoopDevice(
                 base_dir=BASE_DIR,
                 name="file-4k",
                 size=1073741824,
                 sector_size=5096,
            ),
        ),
    ),
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions