cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 7

Hostname change in multiple Cisco Devices

Hi,

 My expertise in scripting is close to none; however, it seems to be more difficult with Solarwinds given that there is no much explanation regarding the variables, etc. and documentation is scarce, in my opinion. The issue is that I am trying to change hostnames in a multiple of cisco devices that are selected due to the NCM.Nodes @ ContextNode but I can't figure out where to declare the variable and how to create a loop that asks me to enter the new hostname for each of the nodes I previously chose.

Any help is greatly appreciated.

Thank you.

Labels (3)
0 Kudos
7 Replies

The correct syntax for using Custom Properties in NCM is:

@ContextNode.CustomPropertyName

 

I'm going through a project right now where I'm appending a custom property to the end of our switch hostnames, the script looks like this:

script SwitchRename (NCM.Nodes @ContextNode)
{
  string @NewNodeName = @ContextNode.NodeCaption + ' - ' + @ContextNode.NewName
  CLI
  {

config t

hostname @NewNodeName

end
wr me

  }
}

 

So the resulting hostname on a device called "Core Switch" with a custom property of "MDF" would be Core Switch - MDF

To add on for @rgarciar1801 using this method you wouldnt have a looping prompt to ask you for the new names at run time, you would set up a custom property on the nodes and set all those values ahead of time, then the script just reads the value from the node custom property and does it. From a programming perspective think of it as being similar to the difference between scripts that are intended to be run interactively versus scripts that are written with the assumption that you would execute them with no user interaction. Those parameters we enter in config change templates are basically just arguments we pass into the script, once it starts it isn't going to ask you for new data so you need to make sure it has everything you need before you try to kick it off.
- Marc Netterfield, Github
0 Kudos
Level 16

Hi 

Use node costume property to update the new host name  

From config management run 

config t

 

hostmane @new-node-name

 

Level 7

The change requires multiple devices and what you stated works for one. Now, here is what I could like to accomplish

Due to @ContextNode I must select 5 nodes (for instance)

then create a for each loop or something stating:

Node1 - new-hostname1

Node2 - new hostname

etc.

Build the script which will include the 5 nodes previously selected with the following commands:

Node-1

configuration terminal

hostname new-hostname1

Node-2

configuration terminal

hostname new-hostname2

etc.

An option is if I could define the new custom property inside the foreach loop but I haven't been able to find how to.

thanks.

0 Kudos

With config change templates there is no functionality to create loops of user interactivity.  You need to understand the workflow, NCM is not like a shell script or CLI where it takes actions in real time and allows for new data to be processed as it runs.  Every bit of data you will use in the script has to be known before the script begins, that first screen where you get to populate the parameters is the only time you will get to manually enter anything in and then based on what you put in there NCM is going to actually create the script it uses on the backend to do the work.  The examples being given right now of using a custom property are a common way to deal with running a script where there are values that are host specific.

On the plus side, there is a serious effort started recently to make it so can NCM use Python for scripting jobs, which I'm expecting should really open up a lot more flexibility going forward when that finally gets completed.

- Marc Netterfield, Github
0 Kudos
Level 7

Hi

@mesverrumThat explains why I couldn't find a possible answer, and even other programmers couldn't understand why all the variables needed to be defined at the beginning. My use case right now is to make multiple different changes that are device specific but it seems like I will have to go a different route.

Regarding the Custom Properties workaround, I still don't see how I could make those changes in a bulk. If you (or anyone else) could provide me with a script that uses a foreach loop that prompts (or allow me to device) the change I want per device, it will be awesome. I also have a hard time understanding Solarwinds SWISS schema and trying to make sense of it as it doesn't always applies.

thank you.

0 Kudos
Level 16

Hi

Just use the normal confirmation manager 

Orion/NCM/ConfigurationManagement.aspx

Choose the nodes that need to change hostname 

make sure that they got the CP with the updated name 

The CP name is “new-hostnmae” the value should be the expected new host name  

Then run

configuration terminal

hostname @new-hostname

That will make NCM to take the value and insert to config