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.

Help With Config Change Template

I am working on a config change template on a Juniper SRX device where rather than needing the devices WAN IP, I need the network address IP which is -1 digit in the 4th Octet, i.e. the WAN IP is 209.41.64.14 but the IP address I need in the command is 208.41.64.13. I have created a script where I can get the WAN IP (209.41.64.14), but cannot think of a way to the get to the -1 IP for the network address (209.41.64.13). Is there any way to accomplish this in SW?

Current script:

/*

.CHANGE_TEMPLATE_DESCRIPTION

.CHANGE_TEMPLATE_TAGS

        JUNIPER, SRX, JUNOS

.PLATFORM_DESCRIPTION

        JUNIPER, SRX, JUNOS

.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 UpdateNTP  (

                                         NCM.Nodes @ContextNode       )

{

  // Only select Juniper devices

foreach ( @node in @ContextNode )

{

  if ( @node.MachineType Contains 'SRX100H2' )

//ONLY SELECT SRX100 DEVICES

{

   // Set NTP Server and Static Route

  CLI

 

{

configure

set system ntp server 164.92.5.6

set routing-options static route 164.92.5.6/32 next-hop @node.AgentIP

      }

      CLI

  {

commit

exit

    }

  }

}

}

RETURN:

configure

set system ntp server 164.92.5.6

set routing-options static route 164.92.5.6/32 next-hop 209.41.64.14 (NEED THIS TO BE 209.41.64.13)

commit

exit

Thank you,

Justin M.

  • For anyone that was interested in the solution I was able to find one. By defining variables and doing the math and then using the resulting @num3 for the next-hop:

    {

    string @num1

    int @num2

    string @num3

               

                @num1 = GetOctet(@node.AgentIP,4)

                @num2 = (@num1-1)

    @num3 = SetOctet(@node.AgentIP, 4, @num2)

    }

    {

      // Only select Juniper devices

    foreach ( @node in @ContextNode )

    {

      if ( @node.MachineType Contains 'SRX100H2' )

    //ONLY SELECT SRX100 DEVICES

    {

       // Set NTP Server and Static Route

      CLI

    {

    configure

    set system ntp server 164.92.5.6

    set routing-options static route 164.92.5.6/32 next-hop @num3

          }

          CLI

      {

    commit

    exit

        }

      }

    }

    }

  • Hello Jmoran

    I was wondering if you can help me out, I'm not at all a programmer but I wanted to do the following job with in solarwinds.

    I was able to make the interface description script work. but wanted so see if I can trim down the domain name (switch-B4-4503.domain.com) and the interface portion (Interface: GigabitEthernet1/1/3) to only (switchname gi1/1/3)

    base on you previews example it might be possible by parsing some of the data.

    this is the cct script I'm using

    thank you !

    /*
    .CHANGE_TEMPLATE_DESCRIPTION
            This template sets an interface description based off of cdp neighbors.
    .CHANGE_TEMPLATE_TAGS
                    Cisco, interface, description, properties
    .PLATFORM_DESCRIPTION
            Cisco IOS

    .PARAMETER_LABEL @ContextNode
            NCM Nodes
    .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 ChangeInterfacesBasedOnDescription (
                                                NCM.Nodes @ContextNode
    string @num1
    int @num2
    string @num3
               
    @num1 = GetOctet(@CDPEntry.RemotePort,)
    @num2 = (@num1-1)
    @num3 = SetOctet(@node.AgentIP, 4, @num2
           )
    {
      // Enter configuration mode
      CLI
      {
        configure terminal
      }

      int @MatchFound
      
      @MatchFound = 0

      // Loop through selected interfaces
      foreach (@CDPEntry in @ContextNode.CiscoCdp)
      {
        foreach (@Interface in @ContextNode.Interfaces)
        {
                     if (@Interface.InterfaceIndex == @CDPEntry.IfIndex)
             if (@CDPEntry.RemoteDevice startsWith 'SEP')
                         {
                         } else
             if (@CDPEntry.RemoteDevice startsWith 'ATA')
                         {
                         } else
             if (@CDPEntry.RemotePlatform contains 'AIR-AP')
                         {
                         }
                    else {
                                    // Set command
                                    CLI
                                    {
                                                    interface @Interface.InterfaceDescription
                                    }
                                    CLI
                                    {
                                                    description  @CDPEntry.RemoteDevice
                                    }
                
                                    CLI
                                    {
                                                    exit
                                    }
                                    @MatchFound = 1             

          }
       
      }
    }

      if (@MatchFound != 1)
      {
         CLI
         {
             NO MATCHES FOUND
         }
      }
      // Exit configuration mode
      CLI
      {
        exit
      }
    }

  • Did you ever find an answer to this?  I have the same issue as all of our switches have ip domain name configured.