05-16-2023 11:30 AM
Hi,
I stumbled into a situation I can't explain to myself:
<?foreach {/ce-pe-port/static/customer-routes}?>
<ip-route-forwarding-list>
<prefix>{customer-prefix}</prefix>
<mask>{customer-prefix-mask}</mask>
<forwarding-address>{customer-prefix-nh}</forwarding-address>
</ip-route-forwarding-list>
<?end?>
This fails on packages reload with `Invalid parameters for processing instruction foreach`.
This on the other hand:
<ip-route-forwarding-list foreach="{/ce-pe-port/static/customer-routes}">
<prefix>{customer-prefix}</prefix>
<mask>{customer-prefix-mask}</mask>
<forwarding-address>{customer-prefix-nh}</forwarding-address>
</ip-route-forwarding-list>
Works just fine.
Model in question is `/container/container/list`. Between the two containers there is a choice and case and the list has a 3 part combined key of "customer-prefix*" nodes seen in the example.
I'm really curious what is going on here. NSO version is 5.8.7.
Thanks
05-22-2023 12:16 AM
What does your yang models look like? I don't get the error when I use the following template:
<config-template xmlns="http://tail-f.com/ns/config/1.0" servicepoint="template-service-servicepoint">
<test xmlns="http://com/example/templateservice">
<?foreach {/ce-pe-port/static/customer-routes}?>
<ip-route-forwarding-list>
<prefix>{customer-prefix}</prefix>
<mask>{customer-prefix-mask}</mask>
<forwarding-address>{customer-prefix-nh}</forwarding-address>
</ip-route-forwarding-list>
<?end?>
</test>
</config-template>
And the following yang:
container test {
list ip-route-forwarding-list {
key "prefix mask forwarding-address";
leaf prefix {
type string;
}
leaf mask {
type string;
}
leaf forwarding-address {
type string;
}
}
}
list template-service {
key name;
leaf name {
type string;
}
container ce-pe-port {
container static {
list customer-routes {
key "customer-prefix customer-prefix-mask customer-prefix-nh";
leaf customer-prefix {
type string;
}
leaf customer-prefix-mask {
type string;
}
leaf customer-prefix-nh {
type string;
}
}
}
}
uses ncs:service-data;
ncs:servicepoint template-service-servicepoint;
}
The template works as expected:
admin@ncs% commit dry-run
cli {
local-node {
data test {
+ ip-route-forwarding-list a b c {
+ }
+ ip-route-forwarding-list d e f {
+ }
}
+template-service test {
+ ce-pe-port {
+ static {
+ customer-routes a b c;
+ customer-routes d e f;
+ }
+ }
+}
}
}
05-24-2023 03:15 AM
Hey,
thanks for trying to look into this.
A string of things happened in an interesting way:
Unfortunately there was a typo in the templates; it is not ce-pe-port but ce-pe-prot in the actual model.
Why stuff above works partially is interesting though. The stand-alone foreach is evaluated by the NSO while the in-tag foreach isn't. The xpath was wrong in both cases but packages reload failed only in first case.
Now, the reason I didn't spot the prot/port typo initially is due to the fact that the NSO actually loops without the need for the foreach in this case. So it went like this:
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