-
-
Save vleijon/8aba33485ab353ceb24203bd5fab410a to your computer and use it in GitHub Desktop.
tmpl-template for ios devices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<config-template xmlns="http://tail-f.com/ns/config/1.0" | |
servicepoint="tmpl"> | |
<resource-pools xmlns="http://cisco.com/yang/nso/resource-allocator"> | |
<!-- This part does the allocation, the pool name is fixed, but the allocation is set to the current name | |
of the service --> | |
<id-pool> | |
<name>pool1</name> | |
<allocation> | |
<id>{./name}</id> | |
<allocating-service xmlns:tmpl="http://com/example/tmpl">/tmpl:tmpl[tmpl:name='{./name}']</allocating-service> | |
</allocation> | |
</id-pool> | |
</resource-pools> | |
<!-- We want to do our change only if the allocation is ready --> | |
<devices xmlns="http://tail-f.com/ns/ncs"> | |
<!-- This is a little bit of a hack to find our allocation, if it exists. | |
We should really look at /ralloc:resource-pools/ralloc:id-pool[ralloc:name='pool1']/allocation[id='t1']/response, but I couldn't make that work the way I wanted. --> | |
<?set-root-node {/}?> | |
<?set myref = {concat('/tmpl:tmpl\{',./name,'\}')}?> | |
<?set val = {/id-allocator/pool[name='pool1']/allocation[owner=$myref]}?> | |
<!-- Then we make a conditional based on if the value is there yet or not --> | |
<?if {$val}?> | |
<device> | |
<name>{./device}</name> | |
<config> | |
<interface xmlns="urn:ios"> | |
<GigabitEthernet> | |
<name>0/{$val}</name> | |
<description>Interface {$val}</description> | |
</GigabitEthernet> | |
</interface> | |
</config> | |
</device> | |
<?end?> | |
</devices> | |
</config-template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment