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.

How to add bulk external nodes

Hello.

Is anyone ever had to add bulk external nodes? If so I would appreciate any help on how to do this. We have a requirement to add around 150 external nodes. I have tried using the Discovery tool, but cannot see an option to add as 'external' nodes

Also what would really be helpful is if I can update the custom properties of the external nodes.

Thanks in advance

Rupen

  • This might be too late for you, but I have a Powershell script that can add external nodes with custom properties via the API from a CSV file.

    In its current state it's specific to my requirements, but if you're still interested I can make it a little more generic and post here.

  • I would like to see your script emoticons_happy.png

  • Hi, this should do the job.  Replace the IP address of the server, the path to the CSV files and the Custom Property details as required.

    #******* SET IP ADDRESS TO NPM SERVER YOU WANT TO CREATE NODES ON******

    $OrionServer="X.X.X.X"


    #******* Set path to CSV file containin node names *****

    # The CSV file should have TWO COLUMNS

    # The FIRST column should have a header cell called "NodeName"

    # The cells below are the names of the external nodes to create

    # The SECOND column should be called "Load"

    # The cells below this should contain a "Y" for each node you wish to create

    # (This allows you to have one big list but not create them all at the same time if you don't want to)

    $nodeListFile="FULL FILE PATH HERE\externalNodesList.csv"


    #**** The script will ask for credentials.  Must have Node Manager rights*****

    $creds=Get-Credential

    $swis=Connect-Swis -Credential $creds -Hostname $OrionServer


    try {$nodes=Import-Csv $nodeListFile}

    catch {Write-Host "Could not import file.  Check path and type";Break}


    ForEach ($externalnode in $nodes)

    {

        $externalNodeName=$externalnode.nodename

        if ($externalnode.Load -eq 'Y')

        {

           

            $nodeExists = Get-SwisData $swis "SELECT Uri FROM Orion.Nodes WHERE Caption='$externalNodeName'"

      

            if (-not $nodeExists)

            {

                Write-Host "Creating node:"$externalNodeName

                # add the external node

                $newNodeProps = @{Caption = $externalNodeName;Vendor="Placeholder";IPAddress = "0.0.0.0";EngineID = 1;ObjectSubType = "ICMP";External=$TRUE;}

                $newNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $newNodeProps

                $newNode = Get-SwisObject $swis -Uri $newNodeUri

               

               

                # ********* SET CUSTOM PROPERTIES********

                # ****Change / add custom property names and values in line below*****

                $customProps = @{CUSTOM_PROPERTY_NAME_1="Value 1";CUSTOM_PROPERTY_NAME_2="Value 2"}

                # build the URI for Custom Properties access

                $customPropsUri = $newNodeUri+"/CustomProperties";

                # Set the custom property

                Set-SwisObject $swis -Uri $customPropsUri -Properties $customProps

               

                # WAIT 1 SECOND (To avoid overloading NPM server.  Can be removed)

                Start-Sleep -Milliseconds 1000  

            }

            else

            {

                Write-Host "Node already exists:"$externalNodeName   

            }

        }

        else

        {

            Write-host "Skipping node: $externalNodeName"

        }

    }  


     







  • # The SECOND column should be called "Load"

    # The cells below this should contain a "Y" for each node you wish to create

    # (This allows you to have one big list but not create them all at the same time if you don't want to)

     - So just to be clear - as I can be slow at times :D 


    NodeName    LOAD
    Node_1            Y
    Node_2            
    Node_3            Y

    The above would create 2 nodes called Nde_1 and Node_3 as I understand it.

    Is there anyway your script can be added/amended to include the IP and the Node name?

    EDIT 2: The Set CustomProperty bit seems to fail so I've removed that but would still like to put a name and an  IP in, but I am no programmer.

  • If you needed to add node name and IP address of each of these nodes in bulk , you could do this by using most of the script above with some minor changes - see updated script and updated CSV related comments below : 

    #******* SET IP ADDRESS TO NPM SERVER YOU WANT TO CREATE NODES ON******

    $OrionServer="X.X.X.X"



    #******* Set path to CSV file containin node names *****

    # The CSV file should have THREE COLUMNS

    # The FIRST column should have a header cell called "NodeName"

    # The cells below are the names of the external nodes to create

    # The SECOND column should have a header cell called "IPA"

    # The cells below it should have the IP addresses associated with each of the nodes to create

    # The THIRD column should be called "Load"

    # The cells below this should contain a "Y" for each node you wish to create

    # (This allows you to have one big list but not create them all at the same time if you don't want to)

    $nodeListFile="FULL FILE PATH HERE\externalNodesList.csv"



    #**** The script will ask for credentials.  Must have Node Manager rights*****

    $creds=Get-Credential

    $swis=Connect-Swis -Credential $creds -Hostname $OrionServer



    try {$nodes=Import-Csv $nodeListFile}

    catch {Write-Host "Could not import file.  Check path and type";Break}



    ForEach ($externalnode in $nodes)

    {

        $externalNodeName=$externalnode.nodename

        $externalIpAddress=$externalnode.ipa

        if ($externalnode.Load -eq 'Y')

        {

           

            $nodeExists = Get-SwisData $swis "SELECT Uri FROM Orion.Nodes WHERE Caption='$externalNodeName'"

     

            if (-not $nodeExists)

            {

                Write-Host "Creating node:"$externalNodeName

                # add the external node

                $newNodeProps = @{Caption = $externalNodeName;Vendor="Placeholder";IPAddress = $externalIpAddress;EngineID = 1;ObjectSubType = "ICMP";External=$TRUE;}

                $newNodeUri = New-SwisObject $swis -EntityType "Orion.Nodes" -Properties $newNodeProps

                $newNode = Get-SwisObject $swis -Uri $newNodeUri

               

               

                # ********* SET CUSTOM PROPERTIES********

                # ****Change / add custom property names and values in line below*****

                $customProps = @{CUSTOM_PROPERTY_NAME_1="Value 1";CUSTOM_PROPERTY_NAME_2="Value 2"}

                # build the URI for Custom Properties access

                $customPropsUri = $newNodeUri+"/CustomProperties";

                # Set the custom property

                Set-SwisObject $swis -Uri $customPropsUri -Properties $customProps

               

                # WAIT 1 SECOND (To avoid overloading NPM server.  Can be removed)

                Start-Sleep -Milliseconds 1000  

            }

            else

            {

                Write-Host "Node already exists:"$externalNodeName  

            }

        }

        else

        {

            Write-host "Skipping node: $externalNodeName"

        }

    }  

  • Awesome stuff - many, many thanks Rachel.

  • Hey - any chance you can assist again?

    The external nodes all imported fine after your huge assist with the code. However, I now need to do the same task, only this time I need to import them as SNMP v2 nodes and set their SNMP community string at the same time.

    So can you please amend the script so that it adds nodes in bulk with an associated IP Address, SNMPVersion of 2 and SNMP string?

  • Hi  , 

    Unfortunately I am not a PowerShell expert, but there is a script on github and you could combine that with what you have already. https://github.com/solarwinds/OrionSDK/blob/master/Samples/PowerShell/CRUD.AddNode.ps1