Quantcast
Channel: THWACK: Popular Discussions - Orion SDK
Viewing all articles
Browse latest Browse all 3719

Python Add Node Error

$
0
0

I'm getting an error message when I run the following node:

 

===============================================================================================

#!/usr/bin/python

from __future__ import print_function

import re

import requests

from orionsdk import SwisClient

 

def main():

    npm_server = 'SOLARWINDSHOSTNAMEFRONTEND'

    username = 'MYUSERNAME'

    password = 'MYPASSWORD'

 

    swis = SwisClient(npm_server, username, password)

    print("Add an SNMP v3c node:")

 

    # fill these in for the node you want to add!

    ip_address = 'IPADRESSOFTHENEWNODE'

 

    # set up property bag for the new node

    props = {

        'IPAddress': ip_address,

        'EngineID': 2,

        'ObjectSubType': 'SNMP',

        'SNMPVersion': 3,

        'Caption': 'HOSTNAMEOFTHENEWNODE',

        'SNMPV3AuthKey': 'SNMPPASSWORD',

        'SNMPv3AuthKeyIsPwd': True,

        'SNMPv3AuthMethod': 'MD5',

        'SNMPv3PrivKey': 'SNMPPASSWORD',

        'SNMPv3PrivKeyIsPwd': True,

        'SNMPv3PrivMethod': 'DES56',

        'SNMPV3Username': 'SNMPUSER'

    }

 

    print("Adding node {}... ".format(props['IPAddress']), end="")

    results = swis.create('Orion.Nodes', **props)

    print("DONE!")

 

    # extract the nodeID from the result

    nodeid = re.search('(\d+)$', results).group(0)

    print(nodeid)

 

    pollers_enabled = {

        'N.Status.ICMP.Native': True,

        'N.Status.SNMP.Native': False,

        'N.ResponseTime.ICMP.Native': True,

        'N.ResponseTime.SNMP.Native': False,

        'N.Details.SNMP.Generic': True,

        'N.Uptime.SNMP.Generic': True,

        'N.Cpu.SNMP.HrProcessorLoad': True,

        'N.Memory.SNMP.NetSnmpReal': True,

        'N.AssetInventory.Snmp.Generic': True,

        'N.Topology_Layer3.SNMP.ipNetToMedia': False,

        'N.Routing.SNMP.Ipv4CidrRoutingTable': False

    }

 

    pollers = []

    for k in pollers_enabled:

        pollers.append(

            {

                'PollerType': k,

                'NetObject': 'N:' + nodeid,

                'NetObjectType': 'N',

                'NetObjectID': nodeid,

                'Enabled': pollers_enabled[k]

            }

        )

 

    for poller in pollers:

        print("  Adding poller type: {} with status {}... ".format(poller['PollerType'], poller['Enabled']), end="")

        response = swis.create('Orion.Pollers', **poller)

        print("DONE!")

 

    print("Discover and add interfaces:")

    results = swis.invoke('Orion.NPM.Interfaces', 'DiscoverInterfacesOnNode', nodeid)

 

    # use the results['DiscoveredInterfaces'] for all interfaces

    # or get a subset of interfaces using a comprehension like below

    eth_only = [

            x for x

            in results['DiscoveredInterfaces']

            if x['Caption'].startswith('VLAN')]

 

    print(eth_only)

 

    results2 = swis.invoke(

            'Orion.NPM.Interfaces',

            'AddInterfacesOnNode',

            nodeid,

            eth_only,

            'AddDefaultPollers')

 

    print(results2)

 

requests.packages.urllib3.disable_warnings()

 

if __name__ == '__main__':

    main()

===============================================================================================

 

The error is:

 

===============================================================================================

Add an SNMP v3c node:

Adding node IPOFTHEBOX... Traceback (most recent call last):

  File "./prom_add_node2.py", line 112, in <module>

    main()

  File "./prom_add_node2.py", line 39, in main

    results = swis.create('Orion.Nodes', **props)

  File "/usr/lib/python2.7/site-packages/orionsdk/swisclient.py", line 34, in create

    "Create/" + entity, properties).json()

  File "/usr/lib/python2.7/site-packages/orionsdk/swisclient.py", line 59, in _req

    resp.raise_for_status()

  File "/usr/lib/python2.7/site-packages/requests/models.py", line 844, in raise_for_status

    raise HTTPError(http_error_msg, response=self)

requests.exceptions.HTTPError: 400 Client Error: Object reference not set to an instance of an object. for url: https://NAMEOFTHESOLARWINDSSERVER:17778/SolarWinds/InformationService/v3/Json/Create/Orion.Nodes

----------------------------------------------------------------------------------------------------------------------------------------

{"Message":"Invalid SWIS uri at character 18: Incomplete uri. Parser did not finish in End state, but instead was left in Scheme state\u000d\u000aParameter name: uri","ExceptionType":"System.ArgumentException","FullException":"System.ArgumentException: Invalid SWIS uri at character 18: Incomplete uri. Parser did not finish in End state, but instead was left in Scheme state\u000d\u000aParameter name: uri\u000d\u000a at SolarWinds.Data.Utility.SwisUriParser.ParsingError(String message)\u000d\u000a at SolarWinds.Data.Utility.SwisUriParser.ParseInternal()\u000d\u000a at SolarWinds.InformationService.Core.InformationService.Read(String uri)"}

===============================================================================================

 

 

Any thoughts?


Viewing all articles
Browse latest Browse all 3719

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>