cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2818
Views
10
Helpful
10
Replies

Cisco Prime Template more strings in same command

Carstenlymann
Level 1
Level 1

Hi

 

Im trying a bit of templating here, but im having my problems. Dont think the guide for prime gives good enough answers when moving to interactive and more advanced stuff. Where can i find something about that ?

 

Also the problem im having right now is following:

My hostname consist of 3 different things:

Location

Wiring closet

Switch number

 

ex. Location: aarhus

wiring closet: x1

Switch  number: 01

The way my switch are named right now its::   aarhus-x1-01

I would like to do that with a template. but for obvius reasons prime cant see when one managed varieble ends and another begin. The reason i like it to be split up is because i use the location when naming vlan later on also.

so is it possible to make template to work: $location-$wiringcloset-$switchnumber ?

Is it is now if i do this i get a hostname that is this:  $location-$wiringcloset-01

1 Accepted Solution

Accepted Solutions

So below is what I did for my hostname cli template.

 

Once you input your desired variables as such here, they still need to be defined so that the form field is used.

 

When you click on the managed variables button here you will get the next window to pop up.

This is a sample of one that I set up, but what you might see here is an "add row" button and from there you set up each of the specs for each section to make the variable work.

HTH,

Brandon

View solution in original post

10 Replies 10

bkennedy97
Level 1
Level 1

Carstenlymann,

In testing this, the variables themselves are not the issue, but in the placement of the hyphens in this case that tends to throw the template.  Depending on how you want to approach this you could still script it into the variables if you don't have a lot of locations.  When I set up a similar template what I left it with is the following:

hostname $hostname

The variable was set up as a text area, although string would work, allowing for the ctysd-wrcl-dev designation.

If you do not have a ton of wire closets/locations the variables could be set up using the drop down variables, and set it your location and wire closet codes to have a '-' set to follow them. 

Or with what you posted above:

hostname $location$wiringcloset$switchnumber

Set those 3 variables to text area, and remember to add the hyphen '-' at the end of each code that you input into the forms.

 

HTH,

Brandon

Hi

Thx for answer. 

I do actually have a lot of locations. (around 350-400 locations)

The wiring closets is X0 and X1 , and in a few instances also X2 - X4 depending on the size of the location. And switch number is anything from 01 to 05.. Usely 01 and 02 will problably cover 85% of them.

Not really sure what you mean with what i could do. :o 

Doing a variable but with text instead of string.  ??  How to get the other stuff in it ?

Again the location im using in naming vlan later on as well

/ Carsten

So below is what I did for my hostname cli template.

 

Once you input your desired variables as such here, they still need to be defined so that the form field is used.

 

When you click on the managed variables button here you will get the next window to pop up.

This is a sample of one that I set up, but what you might see here is an "add row" button and from there you set up each of the specs for each section to make the variable work.

HTH,

Brandon

Thx. I will take a closer look to it tomorrow when im back to work. though it do look like what i have done in first place. Except its text now instead of string. I will get back in here tomorrow :)

 

/ Carsten

If you have it set that way, then my suggestion is remove the hyphens from the body of the cli template and allow the variables to do the work.  So when you input your codes for your hostname, simply add the hyphen at the end of the location and wiringcloset forms.

Hi

This is how it all added up. Got a solution i think will work just fine. :)

This is the template command: 

hostname $Location$Wire_Closet$Switch_nr

And how i set it up:

 

Entered some default values with the hyphen and X and then i manually can add number after that. And same with switch nr.

Has kept it as a string. Think that will work fine.

Thanks for all the help. :)

 

/ Carsten

You might also be able to do the formal notation of the variables and have it work. What I mean by this, is that there are two ways to write out a variable name in Velocity:

$location

${location}

The second one is called a formal notation - the brackets tell Velocity where the variable ends, so you can do things like:

${location}-${wiringcloset}-${switchnumber}

And it should come out how you want it, without having to add the "-" in the form itself.

Thanks Scott.

 

That was exactly what i was looking for :)  Just tried it out and it worked like you said it should.  Really awesome..

Now im looking forward to get back on Work on monday and make my template complete.

Happy easter

 

/ carsten

Aw, I don't think this works anymore. It took away the fields in form view.

The following is a sample, so when you get the handle on it you will start to see more availability.  This template that I built would allow for you to set your hostname all in one variable instead of doing the multiple ones that you are looking to do.  Might take some of the confusion out to do it that way, but the beauty of it is that you have many different possible ways to get the job done that you want.

Getting Started

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: