Mentions légales du service

Skip to content
Snippets Groups Projects
Verified Commit c6fb86ad authored by SIMONIN Matthieu's avatar SIMONIN Matthieu
Browse files

Introduce a configuration object

```
from enoslib.infra.enos_g5k.provider import G5k
from enoslib.infra.enos_g5k.configuration import Configuration

conf = Configuration.from_dictionnary(provider_conf)
provider = G5k(conf)
roles, networks = provider.init()
```
Note: Validation is done in the class method from_dictionnary.

Additionnaly a programmatic way of creating configuration is provided :

```
conf = Configuration()
network = NetworkConfiguration(id="id",
                               roles=["my_network"],
                               type="prod",
                               site="rennes")

conf.add_network_conf(network)\
        .add_machine_conf(MachineConfiguration(roles=["r1"],
                     cluster="paravance",
                     primary_network=network))\
        .add_machine_conf(MachineConfiguration(roles=["r2"],
                     cluster="parapluie",
                     primary_network=network,
                     nodes=10))\
       .finalize()
```

```
conf = Configuration()
network = NetworkConfiguration(id="id",
                               roles=["my_network"],
                               type="prod",
                               site="rennes")

conf.add_network_conf(network)\
        .add_machine(roles=["r1"],
                     cluster="paravance",
                     primary_network=network)\
        .add_machine(roles=["r2"],
                     cluster="parapluie",
                     primary_network=network,
                     nodes=10)\
       .finalize()
```

In this case validation is done when calling finalize.

Refactor each provider code to split the configuration from the Provider
object. This object is then passed to the provider which only read it and
proceed with the deployment of the infrastructure.

In each provider:
- add a `configuration.py` which contains the definition of Configuration
- add a `schema.py` which contains the schema
- add a `constants.py` which contains the constants

- Unit testing has been added as well as
- functionnal tests adapted to the new API (mostly located in `docs/tutorials`)

- Drop py27
- In configuration schema, drop `role` keyword (keep only `roles`)
- update doc
parent 6e2c1ee5
No related branches found
No related tags found
Loading
Showing
with 392 additions and 101 deletions
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment