Configuration for the very cool Faucet software defined networking stack is complex.
Nyko is a design playground for a compiler to abstract and automate development with Faucet.
- Parser: Nyko uses pyparsing, a PEG parser used in the TranQL grammar.
- Abstract Syntax Tree (AST): The design of the abstract syntax tree will be impacted by the parser, and is also coupled to the structure of the model of the configuration. So the effort to create the AST will likely be a gating factor. This argues
- for experimenting with different parsers with a tiny grammar and AST to make choices about tradeoffs and
- that automated reverse engineering of the structure of the config to generate parts of the lexical analysis phase.
- Code Emitter or Interpreter: Nyko loads an existing config and supports a tiny language able to 1) add an include 2) update vlan id and 3) update a vlan description. The resulting config is then written. So do users expect this to be a compiler or an interpreter? If it's interpreting, it would be ideal to have a granular API to each component for making incremental chnages. If it's a true compiler, we'd most likely use a template language for code generation as in Tycho and SmartBag.
- Heterogeneous Target: Generalizing to other environment components will reduce wasted developer time and frustration.
- The setup calls for manually configuring a number of things in Grafana.
- FAUCET_PREFIX ends up being an environment specific absolute path in docker-compose's .env file.
- Copying default configs into a location associated with the docker-compose.
- Packaging and deploying to Kubernetes with Helm may also benefit from the toolchain.
The prototype is intentionally wide and narrow. That is, it goes end to end from parsing a language, developing the AST, and emitting code dynamically reloaded by the environment. But it avoids developing numerous AST elements because we want to give ourselves time to try different parsers and other components before committing. We also want to get the maximum benefit of modular layers to minimize the impact of changing our minds.
Follow the instructions on running Faucet with Docker and docker-compose.
Faucet reads configs and initializes with values from the default config. Note VLAN office has a vid of 100.
Ru Nyko on the sample program which, among other things, sets VLAN office's vid to 1006.
With log level set to DEBUG
, we get:
So Nyko has rewritten the config, triggering reload. To get to this point, I (1) copied the default configs from the Faucet GitHub repo (2) put them in a standard directory (3) mounted directories in that hierarchy to several containers via the docker-compose and (4) wrote the output of Nyko to that hierarchy. All of this should be coordinated by the tooling as it's time consuming and error prone to do manually.