Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support json/yaml config #4

Open
nirs opened this issue Jul 16, 2019 · 0 comments
Open

Support json/yaml config #4

nirs opened this issue Jul 16, 2019 · 0 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@nirs
Copy link
Member

nirs commented Jul 16, 2019

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,
            ),
        ),
    ),
}
@nirs nirs added enhancement New feature or request help wanted Extra attention is needed labels Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant