Network Change & Configuration Management

Reply
Highlighted
Accepted Solution

Using the name of the device to compare to a list in CCS

Posts: 80
4873     0

Hi Guys,

 

I am trying in CCS to write a script that will go through all our devices and update them to the correct syslog destination.  The script (see attached) is working fine for going through a group of devices and correctly added the needed syslog destination.

 

What is missing is the following.  Right now I have to hardcode the list lookup:

 

SET: $datacenter = "123"
SET: $syslog = getListValue(syslog,datacenter,$datacenter,syslogserver,"NOTFOUND")

 

But I would like to instead like to compare the device name, pull out the matching value and then grab the right syslog destination from the list.

 

For example

 

Devicename

abc123

jkl123

123lkm

 

I would like to use the $Name variable, pull out the matching

$Name like /123/ then populate the variable say $datacenter

then

SET: $syslog = getListValue(syslog,datacenter,$datacenter,syslogserver,"NOTFOUND")

 

I am looking for feedback on how to accomplish this.  Thanks.

Re: Using the name of the device to compare to a list in CCS

Adviser
Posts: 411
4874     0

Let me know if this helps Smiley Happy

 

Script-Filter:
$Vendor eq "Cisco"
########################

Action:
Update Location

Action-Commands:
SET: $sif = getListValue(sif_test,name,$name, location,NOTFOUND)

Action-Commands:{$sif ne "NOTFOUND"}
DEBUG: config t
DEBUG: snmp-server location $sif
DEBUG: end
DEBUG: wr mem

 

 

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

Re: Using the name of the device to compare to a list in CCS

Authority
Posts: 32
4874     0

Hi Susan --

 

If I understand correctly, you're saying that what you want to do is to derive the $datacenter value from the current devicename instead of having to hardcode it -- like, if $Name is "SomeRouter527", you want to end up with $datacenter = "527".

 

Is that correct?

 

-Marc-

Re: Using the name of the device to compare to a list in CCS

Posts: 80
4874     0

@MJensen wrote:

Hi Susan --

 

If I understand correctly, you're saying that what you want to do is to derive the $datacenter value from the current devicename instead of having to hardcode it -- like, if $Name is "SomeRouter527", you want to end up with $datacenter = "527".

 

Is that correct?

 

-Marc-


Marc, that is exactly what I want to do.  I couldn't figure out how to derive the name in the initial Action Command section to populate the $datacenter value.  Once the value was populated, each trigger would just evaluate the type of the device and apply the correct configuration gathering the syslog IP from the list.

 

Susan

Re: Using the name of the device to compare to a list in CCS

Posts: 80
4874     0

Sif, this works (and as you can see that is what I sort of have).  The part where I am stuck if deriving the datacenter from the $Name of the device.

Re: Using the name of the device to compare to a list in CCS

[ Edited ]
Adviser
Posts: 411
4874     0

Oooooo Ok Smiley Happy

 

 

Trigger-Commands: {$name like /123/}

SET: $syslog = getListValue(syslog,datacenter,123,syslogserver,"NOTFOUND")

 

Trigger-Commands: {$name like /321/}

SET: $syslog = getListValue(syslog,datacenter,321,syslogserver,"NOTFOUND")

 

Trigger-Commands: {$name like /898/}

SET: $syslog = getListValue(syslog,datacenter,898,syslogserver,"NOTFOUND")

 

Output-Triggers:
Config Device

 

Trigger:

Config Device


Trigger-Filter:
$syslog ne "NOTFOUND"


Trigger-Commands:
config t

logging server $syslog

end wr mem

 

Something like that Smiley Happy

Let me know and I can write a more complete script later today

Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

Re: Using the name of the device to compare to a list in CCS

Posts: 80
4874     0

Sif,

 

So I ended up doing something like this (see below), but I thought it was lengthly.  Your approach combines the list lookup and with the filter but you still have to do it one at a time.  I was trying to figure out a way to streamline it.

 

Action-Commands:{$Name like /abc/ and $IPAddress not like /X.X/}
SET: $datacenter = "ABC"

Action-Commands:{$Name like /idef/ }
SET: $datacenter = "def"

Action-Commands:{$Name like /ghi/ }
SET: $datacenter = "ghi"

Action-Commands:{$Name like /na10/}
SET: $datacenter = "NA10"

Action-Commands:{$Name like /jkl/}
SET: $datacenter = "jkl"

Action-Commands:
SET: $syslog = getListValue(syslog,datacenter,$datacenter,syslogserver,"NOTFOUND")

Showing results for 
Search instead for 
Do you mean 

Recommended for You