containerlab icon indicating copy to clipboard operation
containerlab copied to clipboard

User-defined kinds

Open networkop opened this issue 5 years ago • 6 comments

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

networkop avatar Apr 20 '21 09:04 networkop

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?

hellt avatar Apr 20 '21 09:04 hellt

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

networkop avatar Apr 20 '21 09:04 networkop

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

hellt avatar Apr 20 '21 11:04 hellt

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.

perimore avatar Aug 12 '22 14:08 perimore

@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 

hellt avatar Aug 15 '22 09:08 hellt

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.

user318 avatar Aug 15 '22 09:08 user318