- Looking for a sample Cisco Prime CliTemplate making use of split. Want to feed in a variable containing a /48 IPv6 prefix and then use parts of it in various sections of the device configuration.
- So for example would like to take '2001:DB8::/48' split on say '::'
- Giving me '2001:DB8' in a variable which can be appended '::/64' to use on an interface.
- Have tried the examples shown here but it breaks the template in Prime: apache - Using velocity split() to split a string into an array doesnt seem to work - Stack Overflow
- Taken from the link about, should something like the below work (Giving me 'This').
#set ($myString = “This|is|my|dummy|text”)
#set ($myArray = $myString.split("\|"))
$myArray[0]
The CLI content that you're looking for is more like this
#set ( $ipv6_64subnet = $ipv6_string.split("::")[0].concat("::/64") )
do_work $ipv6_64subnet
Have put that in an XML payload that you can POST to v1/op/cliTemplateConfiguration/upload. It worked as expected on my 3.1.5 (dev build of the 3.1.5 patch) server when deployed via either the API or GUI.
<?xml version="1.0" ?> <cliTemplate> <content>#set ( $ipv6_64subnet = $ipv6_string.split("::")[0].concat("::/64") ) do_work $ipv6_64subnet</content> <description>carl_test</description> <deviceType>Routers</deviceType> <name>carl_test_api</name> <variables> <variable> <description>IPv6 String</description> <displayLabel>IPv6 String</displayLabel> <name>ipv6_string</name> <required>true</required> <type>String</type> </variable> </variables> </cliTemplate>
Comments
0 comments
Please sign in to leave a comment.