This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Mass Config Change - Updating mask on all devices

The day has come where I need to expand our management subnet which means I need to update the mask on all our network devices.

The hurdle I need to overcome is being able to use output from the device as a variable to change configuration.

This is on Cisco IOS and Cisco NXOS. The command is pretty simple in concept:

     sh run int vlan 1000 (nxos: show run int mgmt0)

     int {interface}

     ip add {ip address from above output} 255.255.255.128 (nxos: /25)

The trick is A: being able to store that output while the script is running, and B: to parse the IP address out of the output into a variable, and C: being able to call that variable into the running script.

Parents
  • Hi,

    if the IP address of the affected devices is like the interface ip, the following script could help you out:

    (Only tested it on a IOS-device)

    /*

    .CHANGE_TEMPLATE_DESCRIPTION

    .CHANGE_TEMPLATE_TAGS

            Cisco, Nexus, NX-OS

    .PLATFORM_DESCRIPTION

            Cisco IOS, NEXUS

    .PARAMETER_LABEL @ContextNode

            NCM Node

    .PARAMETER_DESCRIPTION @ContextNode

            The node the template will operate on.  All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables.

    */

    script UpdateNetMask  (

                                             NCM.Nodes @ContextNode       )

    {

      // Only select Cisco devices

      foreach ( @node in @ContextNode )

      {

         if ( @node.SysDescr Contains 'NX-OS(tm) n' )

    //ONLY SELECT NX-OS DEVICES

        {

        // Set or update NEXUS Emergency User and Password

          CLI

          {

    configure terminal

    interface mgmt0

    ip add @node.AgentIP/25

          }

        }

         if (@node.SysDescr contains 'IOS' )

    // ONLY SELECT IOS DEVICES

        {

          // Enter configuration mode

          CLI

          {

    configure terminal

    interface vlan 1000

    ip add @node.AgentIP 255.255.255.128

          }

          CLI

          {

    exit

    copy run start

    startup-config

          }

        }

      }

    }

    An example output would look like:

    configure terminal

    interface vlan 1000

    ip add 1.1.1.1 255.255.255.128

    exit

    copy run start

    startup-config

    Regards

    Rene

  • Thank you!

    Where is AgentIP coming from? I assume this is an element inside Orion, and if so, how would I go about finding this particular element?

    What language is this?

    Finding usable information on this level of scripting seems impossible. I can script in Perl and Python, but this is different and I cant find any specific documentation for it.

  • You are welcome.

    The AgentIP is a solarwinds entity.The script is a regular config change template. You can find some predefined in your ncm installation and even more here on thwack which you can import directly from the ncm webconsole.

    pastedImage_2.png

    You can find the documentation here: Config change templates

    And here you can find a complete list of entities you can use in config change templates: SolarWinds Information Service data entities

    Regards

    Rene

Reply Children
  • Perfect. I was looking for a Command Script solution, but this is exactly what I needed. I cant stress enough how much time and frustration you have saved me.

    Just FYI - I have already ran it on all the IOS devices successfully, though it doesnt like the "copy run start" command for some reason. Says its an invalid command for some silly reason.

    It does not work on NXOS devices:

    Error:Variable @node.AgentIP/25 could not be matched. Possible causes of this are:

    1) It has not been declared.

    2) You are referencing an entity property which does not exist.

    3) You are missing a closing bracket in a prior native block.

    I suspect the /25 is the problem here.

  • For NXOS I just changed it from AgentIP/25 to AgentIP 255.255.255.128 and that worked.

    Thanks again !!!!!!!!!

  • I also figured out why copy run start wasnt working - Changing exit to end gets back to root prompt and then it works.

  • Glad you could figure it out. I just copy&paste the script together out of other scripts. emoticons_silly.png  So sorry for the hassle.

    What you could try to make the command work with CIDR Notation is something like this: ip add @node.AgentIP + "/25"

    I have currently no Access to my System so i can't test it myself.

    Regards

    Rene