05-14-2024 04:33 AM
Example1 : Supposed your input payload is given below { "l3-device-list" :{ "interface-list":{ "s-existing-trunk-vlan":[444, 454,222], } } } Step1: Add variable in java inputParams.putQuotedEmptyIfNull( "s-existing-trunk-vlan", interfaceObj.leaf(l3VpnRfs._s_existing_trunk_vlan_).valueAsString() ); Step2: Add variable in yang leaf-list s-existing-trunk-vlan { type uint32 { range "1..4096"; } } #3: Add loop in config template <dot1q> <?foreach {l3-device-list/interface-list/s-existing-trunk-vlan}?> <id>{.}</id> <?end?> <id>{$vlan-id}</id> </dot1q> Example2 : Supposed your input payload is given below { "alc-last-mile-ag2-rfs": { "interface-name1":["0/0/1/7", "0/0/1/8", "0/0/1/9"], } } Step1: Add variable in yang leaf-list interface-name1 { type string; } Step2: Add loop in config template <?foreach{interface-name1}?> <TenGigE> <id>{.}</id> <load-interval>30</load-interval> <bundle> <id> <id-value>{$B-ID}</id-value> <mode>active</mode> </id> </bundle> </TenGigE> <?end?>
05-14-2024 05:15 AM
Example one, use <?loop?> as it is easier to read, then you can remove the <id>{$vlan-id}</id element, as it's not part of the loop.
<dot1q>
<?loop var="vlan" in="l3-device-list/interface-list/s-existing-trunk-vlan"?>
<id>${vlan}</id>
<?end?>
</dot1q>
Example two, same for the update of <?foreach?>, and then in both example the code becomes more readable, maintainable, and efficient.
<?loop var="interface" in="interface-name1"?>
<TenGigE>
<id>${interface}</id>
<load-interval>30</load-interval>
<bundle>
<id>
<id-value>${B-ID}</id-value>
<mode>active</mode>
</id>
</bundle>
</TenGigE>
<?end?>
05-23-2024 01:06 AM
Can you provide more details?
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide