3 Replies Latest reply on Feb 17, 2020 6:08 AM by smarks73

    How to add bulk external nodes

    rupen73

      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

        • Re: How to add bulk external nodes
          smarks73

          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.

            • Re: How to add bulk external nodes
              kenosmith3

              I would like to see your script

                • Re: How to add bulk external nodes
                  smarks73

                  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"

                      }

                  }