cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2960
Views
0
Helpful
4
Replies

Prime Infrastructure CLI templates and wildcards; values of inventory variables

jane1
Level 1
Level 1

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?

4 Replies 4

Doug Byrd
Level 5
Level 5

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

 

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]")

Wayne_G
Level 1
Level 1

Might be a little late, but I use #if($interfaceName.toString().contains("GigabitEthernet"))

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