solarwinds / orionsdk-python

Python client for interacting with the SolarWinds Orion API
Apache License 2.0
210 stars 89 forks source link

Unable to get resources list of a node #49

Open AravindBalajiS opened 4 years ago

AravindBalajiS commented 4 years ago

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

sajithapps commented 4 years ago

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

sajithapps commented 4 years ago

Also tried this

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

Output:

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

davidlowie commented 4 years ago

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?

teonat commented 4 years ago

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'}
markatdxb commented 4 years ago

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

davidlowie commented 4 years ago

@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?

markatdxb commented 4 years ago

Hello ,apparently this issue should be fixed in the latest Orion version but i haven't had a chance to test it yet.

On Fri, 10 Jul 2020, 05:08 davidlowie, notifications@github.com wrote:

@markatdxb https://github.com/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?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/solarwinds/orionsdk-python/issues/49#issuecomment-656374496, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKPVXJPDFJKZZOMQ5OYXQ5LR2Y5VFANCNFSM4LSAGEMA .

davidlowie commented 4 years ago

I installed 2020.2 on my test system but that system wasn’t having any issue with 2019.4

The difference is that it has only one polling engine.

Sent from my iPhone

On Jul 9, 2020, at 9:02 PM, markatdxb notifications@github.com wrote:



Hello ,apparently this issue should be fixed in the latest Orion version but i haven't had a chance to test it yet.

On Fri, 10 Jul 2020, 05:08 davidlowie, notifications@github.com wrote:

@markatdxb https://github.com/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?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/solarwinds/orionsdk-python/issues/49#issuecomment-656374496, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKPVXJPDFJKZZOMQ5OYXQ5LR2Y5VFANCNFSM4LSAGEMA .

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/solarwinds/orionsdk-python/issues/49*issuecomment-656469638__;Iw!!FRfS_D4!OjDUEK-RWyI4cP6gwAvLwGY6V8FO4Uf3aZzuAnIFgnhrRkQ_lvXkj9hXYk2V5CoaxmoH9w$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/APOMQJNGB52FULMUJMVJSZDR22HCFANCNFSM4LSAGEMA__;!!FRfS_D4!OjDUEK-RWyI4cP6gwAvLwGY6V8FO4Uf3aZzuAnIFgnhrRkQ_lvXkj9hXYk2V5Cqphy6Veg$.

This email message and any attachments are confidential and intended for use by the addressee(s) only. If you are not the intended recipient, please notify me immediately by replying to this message, and destroy all copies of this message and any attachments. Thank you.

amat3ur85 commented 3 years ago

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:

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)

]]>

mrxinu commented 3 years ago

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.