5 Replies Latest reply on Jan 29, 2016 6:01 AM by Steven Klassen

    Rest Api Connection Failed

    mpaul_vijay

      Hi Everyone,

       

      I am trying to run the example code from GitHub to connect to Orion and fetch the VM list but seeing the following error during the connection though the IP and Solarwinds is active . What am I missing here.?

       

      from swClassLib import *

      sw = SolarWinds(ip='X.X.X.X', username="admin", password="admin")

      vms = sw.getOrionVIMVirtualMachines()

      print ("My VMs\n")

      for vm in vms:

         print (vm.getName(), vm.getIPAddress())

       

       

      Could not connect in call from [(<frame object at 0x023CA9F8>, 'C:\\Python27\\Lib\\swClassLib.py', 97, 'sendRequest', ['        caller = inspect.stack()\n'], 0), (<frame object at 0x0240D9E8>, 'C:\\Python27\\Lib\\swClassLib.py', 3226, 'getOrionVIMVirtualMachines', ['                status=200)\n'], 0), (<frame object at 0x005AD608>, 'C:/Users/admin/PycharmProjects/SSH/ORION.py', 4, '<module>', ['vms = sw.getOrionVIMVirtualMachines()\n'], 0)]. Unable to continue

      My VMs

       

       

      Thanks

      Paul

        • Re: Rest Api Connection Failed
          tdanner

          I just noticed that this question has been sitting unanswered for a long time. Sorry about that.

           

          If you are still in need of assistance, could you point me to this code for "swClassLib"? I can't tell just from the exception trace what the underlying error is.

            • Re: Rest Api Connection Failed
              t0nyt93

              Hey tdanner,

              I've come across the same issue. The source code is around 7,500 lines long, so instead of posting code snippets out of context:

              https://github.com/Plexxi/SolarWindsOrionREST

              Here is a link to the repo.

              I believe the function of interest is in swClassLib at line 88, sendRequest().

               

              Send request is called in multiple functions, (such as getOrionContainer at line 572) in the form of:

                if selectQuery:

                          currOrionContainer = self.sendRequest(

                              Type='GET',

                              URL='/SolarWinds/InformationService/v3/Json/Query?query=' +  selectQuery, #Select query is essentially a mySQL query

                              status=200)

               

              In my case I get the same error, which is dumped by the caller() function as a result of a failed Try/Except. I believe my issue could be my basic understanding of this code, for example I initialize my class as so:

                   from swClassLib import *

                   from swCommonLib import *

                   SW = SolarWinds(ip = 'X.X.X.X', username = '<my_username>',password = 'passwordistaco')

              and then I try to access a table in the database.

                   myTableofInterest = getOrionContainer()

                   ^ this is the call that results in the same error as the OP's.

               

              My question is, Am I receiving an error because I don't understand the API and I'm not accessing the database correctly? Or is there another underlying issue...