srl-labs / containerlab

container-based networking labs
https://containerlab.dev
BSD 3-Clause "New" or "Revised" License
1.54k stars 263 forks source link

add json output for `exec` command #463

Closed steiler closed 3 years ago

steiler commented 3 years ago

Let's implement the --json / -j switch for the exec command. Right now I't all just thrown into a logger, which is not very handy if containerlab is integrated into a broader automated ecosystem.

All output is thereby taken as is and thrown into a dict indexed by the container name.

We try to load the received output as json and insert it as json or insert it as a plain string, such that you can still determin the output per container.

Loading the json would for instance make sense for e.g. ip -j address show.

hellt commented 3 years ago

done in #465