3 Replies Latest reply on Oct 24, 2017 6:17 AM by cgevans

    Create node with credential set

    crutchas24

      Is there a way to create nodes with an existing credential set? I'm looking through the documentation and not seeing any sort of relationship for Orion.Nodes to Orion.Credential. Am I just missing something?

       

      In my python code I'm doing this to grab credential sets:

       

      cred_sets = swis_obj.query('SELECT ID, Name FROM Orion.Credential')['results']

       

      But I can't seem to find a way to pass this as a property to create a new node using it.

        • Re: Create node with credential set
          tdanner

          The CredentialIDs for nodes are kept in the Orion.NodeSettings entity, which has a key/value structure. The SettingName for WMI credential sets is "WMICredential" and the SettingNames for SNMPv3 credential sets are "ROSNMPCredentialID" (used for read options like polling) and "RWSNMPCredentialID" (used for read/write operations like administratively shutting down an interface).

           

          To supply a credential set ID in discovery, see the Discovery · solarwinds/OrionSDK Wiki · GitHub page.

           

          To supply a credential set ID when adding a node, first add the node with no credentials, then add the appropriate entry (using the NodeID for the newly-created node) to Orion.NodeSettings.

          1 of 1 people found this helpful
            • Re: Create node with credential set
              cgevans

              Is this still a valid way of doing this? The API prevents you from adding an SMMPv3 node without specifying credentials. You can add an entry to the NodeSettings table after creation, but it is now an additional entry for that node and remnants of the old credentials used when creating the node are left behind. Is there a better way now?

                • Re: Create node with credential set
                  cgevans

                  For anyone looking for a solution to this, I solved it by creating the SNMPv3 node with placeholder credentials and then deleting those and adding an existing credential to the NodeSettings table.

                   

                  Python example:

                   

                  # If the node is SNMP version 3, then update the credential set from placeholder credentials.
                  if settings['sw_snmp_version'] == "3":
                      # Delete the SNMPv3 placeholder credentials.
                      results = sw_api.query("SELECT Uri From Orion.NodeSettings WHERE NodeID=@id "
                                             "AND SettingName='ROSNMPCredentialID'", id=nodeid)
                      uri = results['results'][0]['Uri']
                      sw_api.delete(uri)
                  
                      # Assign an existing SNMPv3 credential set.
                      properties = {
                          'NodeID': nodeid,
                          'SettingName': 'ROSNMPCredentialID',
                          'SettingValue': settings['sw_snmp3_credentialset']
                      }
                  
                      results = sw_api.create('Orion.NodeSettings', **properties)