ipspace / netlab

Making virtual networking labs suck less
https://netlab.tools
Other
437 stars 65 forks source link

Proposal for links as dict (still allowing list) #1250

Closed ssasso closed 2 months ago

ssasso commented 2 months ago

If I am not wrong, currently the top-level-attribute links is (the only one?) defined as a list.

That means it is not possible to use the construct _include in it, thus not allowing code reuse.

My proposal is to accept as links value both dict and list.

This will allow to have sth like:

links:
  _include:
    - include/links_part_1.yaml
    - include/links_part_2.yaml

which is converted into sth like:

links:
  links_part_1:
  - node1:
    node2:
  links_part_2:
  - node2:
    node3:

which, at the end, behaves like:

links:
  - node1:
    node2:
  - node2:
    node3:

If we do not want to modify the "core code", I guess this can be performed as pre-transformation step in a dedicated plugin?

ipspace commented 2 months ago

I'm guessing you'd like to have reusable topology. Would components do what you'd like to do?

https://netlab.tools/components/

There's also link groups: https://netlab.tools/links/#link-groups but that would require _include within a list, and I don't think we do that.

Other than that, I have no problem if we structure links as a dictionary of lists, and then use the dictionary keys to name the links while flattening the data structure very early in the transformation process.

ssasso commented 2 months ago

Will look at the compontents, thanks for pointing that out! I always forget all the capabilities we have ;)

Will let you know

ipspace commented 2 months ago

Hey @ssasso, could you get what you needed with components, or should we go and implement this one?

ssasso commented 2 months ago

Not able with components. I started trying to develop a plugin for doing that without touching the core code, but gave up for lack of time at the moment :(