srl-labs / containerlab

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

User-defined kinds #391

Open networkop opened 3 years ago

networkop commented 3 years ago

Is this possible? as in take some base kind, e.g. linux and define my custom kind over it. I thought this was what topology.kind is supposed to do, but looks like it's not?

e.g. this is what i want to do

name: user-defined

topology:
  kind:
    my-custom-kind: 
      type: linux
     image: myimage:latest
hellt commented 3 years ago

Custom kinds are not something you can create in the clab file I wonder what would be the use case? To have a special set of variables scoped for this kind specifically?

networkop commented 3 years ago

yes. so instead of listing all those kind params for every node, you define them once and then just reference that custom kind from the nodes section

hellt commented 3 years ago

we will take it as a feature enhancement, and add it in the subsequent release.

perimore commented 2 years ago

This would be very useful as it will allow each custom kind to have a specific version or interface mapping (to emulate different hardware) in the case of cEOS. I.e.:

topology:
  kinds:
    ceos-7050SX3-48YC8:
      startup-config: ../../ceos_lab_template/ceos.cfg.tpl
      image: ceosimage:4.28.1F
      binds:
        - 7050SX3-48YC8.json:/mnt/flash/EosIntfMapping.json:ro 
    ceos-7050CX3-32S:
      startup-config: ../../ceos_lab_template/ceos.cfg.tpl
      image: ceosimage:4.28.0F
      binds:
        - 7050CX3-32S.json:/mnt/flash/EosIntfMapping.json:ro 
    linux:
      image: alpine-host

In the example above the custom kind is denoted by not using a reserved name. Otherwise a "template" could be used.

hellt commented 2 years ago

@perimore do you need a custom kind for that though?

looks like your example can be written as

topology:
  nodes:
    ceos:
      startup-config: ../../ceos_lab_template/ceos.cfg.tpl
      image: ceosimage:4.28.1F
      binds:
        - 7050SX3-48YC8.json:/mnt/flash/EosIntfMapping.json:ro 
    ceos:
      startup-config: ../../ceos_lab_template/ceos.cfg.tpl
      image: ceosimage:4.28.0F
      binds:
        - 7050CX3-32S.json:/mnt/flash/EosIntfMapping.json:ro 
user318 commented 2 years ago

Yes, it can be "unfolded" and written explicitly for each node. But the idea is to define custom node types with predefined options and not to repeat them. Some sort of inheritance.