02-19-2018 03:58 AM - edited 03-01-2019 06:24 PM
Hello,
I'm on a new job and here they use Prime Infrastructure (3.2) which I didn't use before. Till now I mostly used ansible for configuration management.
I tried to use wildcards in CLI templates but failed. also I couldn't find any info on apache VLT and wildcards.
The following template works:
#foreach ($interfaceName in $interfaceNameList) #if($interfaceName == "GigabitEthernet1/0/1") interface $interfaceName description "Hey, my name is: $interfaceName" #end #end
but using wildcards like in the following fails / no data gets generated:
#foreach ($interfaceName in $interfaceNameList) #if($interfaceName == "GigabitEthernet1/0/*") interface $interfaceName description "Hey, my name is: $interfaceName" #end #end
Any ideas howto use wildcards?
Further on, I'd like to know how to get the contents of variables for debugging. Till now I generate the config and look at the output. Is there a way to list the inventory with the according variables I can access in Prime Infrastructure?
E. g. I'd like to make a template for radius authentication with a IF ELSE condition which generates the radius config depending on the networking software (e. g. IOS, IOS-XE...). How could I do that?
02-20-2018 06:28 AM
I believe it is because your statement is looking for the literal string "GigabitEthernet1/0/*" because of '==' which stands for equals
You'll have to use a regular expression/search term like in the below example:
https://stackoverflow.com/questions/6103021/velocity-template-regular-expressions
Offical VTL Docs: http://velocity.apache.org/engine/1.7/user-guide.html
VTL Reference Sheet: http://velocity.apache.org/engine/2.0/vtl-reference.html
02-21-2018 05:40 AM
Dear Dough,
thanks for your reply. Should have thought of that myself :)
But unfortunately it doesn't help. I still get "command are not generated due to insufficient information. Invalid var values for given template's variables.
I did an spaghetti on wall approach and tried all of the following, without success.
#if($interfaceName = "GigabitEthernet1/0/*")
#if($interfaceName = "GigabitEthernet*")
#if($interfaceName = "GigabitEthernet1/0/.*")
#if($interfaceName = "GigabitEthernet1/0/?")
#if($interfaceName = "GigabitEthernet1/0/(1-3)")
#if($interfaceName = "GigabitEthernet1/0/[1-3]")
#if($interfaceName = "GigabitEthernet1/0/[1..3]")
07-29-2018 03:47 PM
Might be a little late, but I use #if($interfaceName.toString().contains("GigabitEthernet"))
08-01-2018 10:56 AM - edited 08-01-2018 10:57 AM
Hi jane1
Assuming that $interfaceNameList is a database variable, that actually would be an ArrayList containing all required interfaces, you could use the String API method startsWith to achieve the expected outcome:
#foreach( $interfaceName in $interfaceNameList ) #if( $interfaceName.startsWith("GigabitEthernet1/0/") ) interface $interfaceName description "Hey, my name is: $interfaceName" #end #end
To identify the software type you can also take the advantage of database variables into your decision-making code.
I hope this help you.
Regards
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