Hi!
Thought I share this here as I thought it was pretty cool. Its an ID allocator done in a template only service.
Ive got a list of ID:s and my service should just pick the next available one.
admin@ncs% show evi
evi 100;
evi 101;
evi 105;
[ok][2020-06-11 12:21:26]
[edit]
Create my service instance
admin@ncs% show | compare
+evpn sadf {
+ service-type odn-igp;
+ a-side {
+ device [ xr0 ];
+ Bundle-Ether 1;
+ vlan 12;
+ }
+}
[ok][2020-06-11 12:21:38]
[edit]
admin@ncs% commit dry-run
cli {
local-node {
data devices {
device xr0 {
config {
+ evpn {
+ evi 106 {
+ bgp {
+ route-policy {
+ export odn-igp;
+ }
+ }
+ }
+ }
+ l2vpn {
+ xconnect {
+ group evpn_vpws {
+ p2p sadf {
+ neighbor-evpn {
+ neighbor {
+ evpn 106 1 1;
+ }
+ }
+ }
+ }
+ }
+ }
}
}
}
+evi 106 {
+}
+evpn sadf {
+ service-type odn-igp;
+ a-side {
+ device [ xr0 ];
+ Bundle-Ether 1;
+ vlan 12;
+ }
+}
}
}
admin@ncs% commit
admin@ncs% show evi | display service-meta-data
evi 100;
evi 101;
evi 105;
/* Refcount: 1 */
/* Backpointer: [ /evpn:evpn[evpn:name='sadf'] ] */
evi 106;
And in the service template i have this
<evpn xmlns="http://tail-f.com/ned/cisco-ios-xr">
<?save-context service?>
<?set-root-node {/}?>
<evi>
<id>{/evi[not(../evi/id > id)]/id + 1}</id>
<bgp>
<?switch-context service?>
<route-policy>
<export>{/service-type}</export>
</route-policy>
</bgp>
</evi>
</evpn>
</config>
</device>
</devices>
<?set-root-node {/}?>
<id>{/evi[not(../evi/id > id)]/id + 1}</id>
</evi>
</config-template>
Example service is attached, sorry about the zip file this discussion board does not accept tar.gz.