solarwinds/orionsdk-python

Unable to get resources list of a node

Opened this issue · 10 comments

Below is the script that I tried to get resources list of a node:


    jobid = swis.invoke('Orion.Nodes', 'ScheduleListResources',NodeID)
    print(jobid)

    time.sleep(60)
    
    while True:
        results = swis.invoke('Orion.Nodes', 'GetScheduledListResourcesStatus', jobid,NodeID)
        print(results)
        if(results=='ReadyForImport'):
            break

    results = swis.invoke('Orion.Nodes', 'ImportListResourcesResult', jobid,NodeID)
    print(results)

Error:

requests.exceptions.HTTPError: 400 Client Error: Could not load file or assembly 'SolarWinds.Interfaces.Discovery.Strings, Version=3.5.0.638, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. for url: https://solarwinds_url:17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.Nodes/ImportListResourcesResult

Got same error any help would be much appreciated

 job_id = swis.invoke('Orion.Nodes', 'ScheduleListResources', node_id)
    print (job_id)
    status = "Unknown"

    while status == "Unknown":
        status = swis.invoke('Orion.Nodes', 'GetScheduledListResourcesStatus', job_id, node_id)
        print(status)
        time.sleep(10)

    while status != "ReadyForImport":
        status = swis.invoke('Orion.Nodes', 'GetScheduledListResourcesStatus', job_id, node_id)
        print(status)
        time.sleep(10)

    print("Importing list resources...")
    resources = swis.invoke('Orion.Nodes', 'ImportListResourcesResult', job_id, node_id)
    print(resources)
    time.sleep(10)

Got the below error:

Unknown
ReadyForImport
Importing list resources...
Traceback (most recent call last):
File "./test.py", line 79, in
main()
File "./test.py", line 59, in main
resources = swis.invoke('Orion.Nodes', 'ImportListResourcesResult', job_id, node_id)
File "/usr/lib/python2.7/site-packages/orionsdk/swisclient.py", line 31, in invoke
"Invoke/{}/{}".format(entity, verb), args).json()
File "/usr/lib/python2.7/site-packages/orionsdk/swisclient.py", line 63, in _req
resp.raise_for_status()
File "/usr/lib/python2.7/site-packages/requests/models.py", line 940, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Could not load file or assembly 'SolarWinds.Interfaces.Discovery.Strings, Version=3.5.0.638, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
The system cannot find the file specified. for url: https://solarwindsendpointurl:17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.Nodes/ImportListResourcesResult

Also tried this

  intefaces = swis.invoke('Orion.NPM.Interfaces', 'DiscoverInterfacesOnNode', node_id)
  print (intefaces)

Output:

{u'DiscoveredInterfaces': None, u'Result': 1}

Did something break in the discovery API? I'm having problems with it now with a script that has worked for years, ever since moving to 2019.4. Solarwinds is giving me a really bad attitude via support, "I'm not going to troubleshoot your script"

Where are you seeing this error log output?

It seems to me that adding of discovered interfaces through the APIs node discovery is broken at least.
They also mention this in an issue in the Powershell SDK
I'm currently working around this by manually discovering interfaces after the node is discovered and added to Orion through the API discovery like this:

import json

import requests
from requests.auth import HTTPBasicAuth

orion = 'your.orion.installation'
username = 'your_api_username'
password = 'your_api_password'
body = {'nodeId': 1234}
response = requests.post(
    f'https://{orion}:17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.NPM.Interfaces/DiscoverInterfacesOnNode',
    auth=HTTPBasicAuth(username, password),
    data=json.dumps(body),
    headers={'Accept': 'application/json'},
    verify=False).json()

response.get('DiscoveredInterfaces', []) will return a list of all the discovered interfaces, like this:

{
    'ifIndex': 0,
    'Caption': 'string',
    'ifType': 0,
    'ifSubType': 0,
    'InterfaceID': 0,
    'Manageable': True,
    'ifSpeed': 0,
    'ifAdminStatus': 0,
    'ifOperStatus': 0
}

These interfaces can then be added to the node with a post call to

f'https://{orion}:17778/SolarWinds/InformationService/v3/Json/Invoke/Orion.NPM.Interfaces/AddInterfacesOnNode'

with the body

body = {'nodeId': node_id, 'interfacesToAdd': interface_list, 'pollers': 'AddDefaultPollers'}

Hello we have opened case with SLW about 2 months ago and they confirmed it's broken in 2019.4. apparently no hotfix planned for this issue and need to wait for next release

@markatdxb any update from them? when I brought it up in a case they were pretty non-helpful like "Oh we don't support YOUR script that YOU wrote" and didn't admit that anything was wrong.

meanwhile, this has turned this into a manual process to discover nodes. How is this supposed to be an enterprise level app when you have to manually add nodes with the gui?

Hi all,

Any update on this?
Orion.NPM.Interfaces.DiscoverInterfacesOnNode invoke is not working on 2020.2.1 either.

Getting this error if the action is performed via SWQL studio:

-<![CDATA[
System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.

Server stack trace:
at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen()
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at SolarWinds.InformationService.Contract2.IInformationService.Invoke(String entity, String verb, XmlElement[] parameters)
at SolarWinds.InformationService.Contract2.InfoServiceProxy.Invoke(String entity, String verb, XmlElement[] parameters)
at SwqlStudio.InvokeVerbTab.Invoke_Click(Object sender, HtmlElementEventArgs e)

]]>

Hey @amat3ur85, what I've been seeing on THWACK is that this verb is losing popularity because it only works on SNMP and the discovery verbs are solid for all the protocols.