12-12-2016 09:21 AM
Hi,
Can anyone provide a sample Cisco Prime CliTemplate making use of split?
I'm looking 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 I'd like to take '2001:DB8::/48' split on say '::'
Giving me '2001:DB8' in a variable which I can append '::/64' to use on an interface.
I've 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]
Thanks,
Carl
Solved! Go to Solution.
12-12-2016 12:53 PM
Carl,
Based on what you're after, I think 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
I've 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>
12-12-2016 12:53 PM
Carl,
Based on what you're after, I think 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
I've 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>
12-13-2016 02:24 AM
Hi Spencer,
That works for me, thanks very much.
Carl
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: