Reply

Best method for using one script to apply different commands to different devices.

JBrown_1
Techie
Posts: 26
6511     0

What is the best method to apply a script to multiple devices, yet have the script run differnet commands depending on the device?

One thought I had was to use a variable for the device name and let that start a trigger.  I was not sure if that was the best method or if there is another way to do this with NetMRI.  Such as create several scripts and a job and somehow associate the correct script with the correct device and package all of them into one job.  My goal is to have one item in NetMRI that the user can run and provide the variable data and NetMRI apply the correct variables to the correct devices.

A specific example of this is creating SVI - vlan interface on two different switches.  Same VLAN, yet each switch having a different IP address and participating in HSRP or GLBP.  Most of the script would be the same, yet for each device, the IP address would have to be unique.  

 

Thank you in advance.

Joe

PERL or CCS?

MGriffin
Techie
Posts: 37
6511     0

Joe,

Is this a PERL script or CCS implementation?

There is a multitude of ways to accomplish this task, but one way is that you could use a filter to run a specific command against a specific device within the same script.

If this is CCS, and we're using a trigger section; same trigger section, filter on the Trigger-Commands directive themselves:

 


Trigger:  Run Command

Trigger-Description: Run the correct command set on the correct device

Trigger-Filter: true

Trigger-Template: (match command output here)

Trigger-Commands: {$IPAddress eq "10.1.1.1" }
  (commands to execute here)

Trigger-Commands: { $IPAddress in [172.16.0.0/24] AND $model like /3750/ }
  (commands to execute)

It sounds like using a list

Adviser
Posts: 357
6511     0

It sounds like using a list would be the best way to go for this use case. This allows you to set up a table within NetMRI, and you can lookup different values based on the specific device. 

Highlighted

It is CCS.  I have the VM

JBrown_1
Techie
Posts: 26
6511     0

It is CCS.  I have the VM version and have not had something so complicated yet that I needed to go through the work of setting up Perl appliance to be able to run Perl scripts.  I may go that route in the future if I run into limitations of CCS.

Yes, I was thinking filters would be certainly one way to do this.  The only downside is all the conditional checks and deciding what to hard code vs use for variables.

I was just reading about

JBrown_1
Techie
Posts: 26
6512     0

I was just reading about lists and BPM.  I was curious if lists could be used for things other than templates.  Sounds like from your response that they can.  I will research that some more.  

I assume with a list, the user will have to edit the list each time to set the data they want for the job.  It would be better if the job could prompt the user for the variable data at the time they run it.

Script -Variables

MGriffin
Techie
Posts: 37
6512     0

Joe,

Script-Variables will do just that, prompt at the start of the script for information to be input.

yes, I was hoping for a

JBrown_1
Techie
Posts: 26
6512     0

yes, I was hoping for a combination of the lookup capabilities of a list with the convenience factor of script variables.  

I might try using variables, but predefining the values for the commonly used ones in scripts.

You could always dynamimcally

Adviser
Posts: 53
6512     0

You could always dynamimcally pass the user entered Script-Variables to the list lookup call at runtime.

Thanks,

- Chris

 

Re: It sounds like using a list

Posts: 80
6512     0

John,

 

Do you have a simple example? I am struggling with the same problem and I am having trouble relating the list to the trigger template so it can implement the correct values.

 

Thanks in advance.

Susan


@JBelamaric wrote:

It sounds like using a list would be the best way to go for this use case. This allows you to set up a table within NetMRI, and you can lookup different values based on the specific device. 


 

Re: It sounds like using a list

Moderator Dave_Signori
Moderator
Posts: 109
6512     0

 

Hi Susan,

 

See this CCS tutorial in the Bloxfest forum:

 

https://community.infoblox.com/cixhp49439/attachments/cixhp49439/Bloxfest/91/2/Bloxfest%202016%20-%2...

 

Slides 11 through 13 has an example of using a list within a CCS script.  There's a Trigger example in there too.

 

Dave

@DaveSignori

Re: It sounds like using a list

Posts: 80
6512     0

Hi Dave,

 

What I want to be able to do is reference the name of a device against a list and then pick a value.  For example say the device names are

 

abc123

abc345

abc678

789abc

 

action:

show hostname

 

I want the trigger to look for any instance of abc (not sure I can use regex in a trigger template).  Because the result of the action is just 1 line I am evaluting just a single word.

trigger template:

.*abc.*

 

And then say OK well if abc exists in that device name, then look up the abc value in the list and select the appropriate value in the list like this:

 

abc 1.1.1.1

dcf   2.2.2.2

fgh   3.3.3.3

 

This I am not quite sure to execute on.  Please advise what I am missing between your example (which I am familar with) and what I am trying to do.

 

Susan

 

Showing results for 
Search instead for 
Do you mean 

Recommended for You