containerlab icon indicating copy to clipboard operation
containerlab copied to clipboard

Node name magic variable

Open hellt opened this issue 2 years ago • 0 comments

Add a new magic variable __clabNodeName__ that would be possible to use in the node definition section to turn this:

    dcgw1_dc1:
      kind: nokia_sros
      startup-config: configs/dcgw1_dc1.partial.cfg

    dcgw2_dc1:
      kind: nokia_sros
      startup-config: configs/dcgw2_dc1.partial.cfg

into this

    dcgw1_dc1:
      kind: nokia_sros
      startup-config: configs/__clabNodeName__.partial.cfg

    dcgw2_dc1:
      kind: nokia_sros
      startup-config: configs/__clabNodeName__.partial.cfg

Bonus points if that would also work in kinds/defaults:

  kinds:
    nokia_sros:
      startup-config: configs/__clabNodeName__.partial.cfg

    dcgw1_dc1:
      kind: nokia_sros

    dcgw2_dc1:
      kind: nokia_sros

see __clabNodeDir__ variable in the code base and how replacers are used to make it so

hellt avatar Mar 07 '24 13:03 hellt