Skip to content
github-plexxi edited this page Oct 7, 2013 · 3 revisions

When things break you will see a print out in the console, usually a stack dump. However, you can modify a global variable in swClassLib.py, DEBUG = 0, 1, or 2, which has increasing levels of debug.

Here is the response when the ip is wrong

>>> sw = SolarWinds(ip="10.10.10.127", username="bob", password="jud")
>>> sw.getOrionViews()
Could not connect in call from [(<frame object at 0x9aedc7c>, 'swClassLib.py', 89, 'sendRequest', ['\t\tcaller = inspect.stack()\n'], 0), (<frame object at 0xb5f08cd4>, 'swClassLib.py', 1425, 'getOrionViews', ["\t\t\tcurrOrionViews = self.sendRequest(Type='GET', URL= '/SolarWinds/InformationService/v3/Json/Query?query=' + selectQuery, status=200)\n"], 0), (<frame object at 0xb5f190c4>, '<stdin>', 1, '<module>', None, None)]. Unable to continue
[]

Here is an example when the username/password is wrong, you get a standard 403 error

>>> sw = SolarWinds(ip="10.10.10.128", username="bob", password="jud")
>>> sw.getOrionViews()
Received HTTP response 403 from 10.10.10.128. Caller is [(<frame object at 0x9aedc7c>, 'swClassLib.py', 89, 'sendRequest', ['\t\tcaller = inspect.stack()\n'], 0), (<frame object at 0xb5f08cd4>, 'swClassLib.py', 1425, 'getOrionViews', ["\t\t\tcurrOrionViews = self.sendRequest(Type='GET', URL= '/SolarWinds/InformationService/v3/Json/Query?query=' + selectQuery, status=200)\n"], 0), (<frame object at 0xb5f0e824>, '<stdin>', 1, '<module>', None, None)]. Unable to continue
[]

Here is an example when it goes wrong because of a bug in the code

There was a bug in the whereList code, so it improperly formatted the request. This kind of thing is actually hard to debug. Clearly the library could be improved to help diagnose this in future.

>>> vms = sw.getOrionVIMVirtualMachines(whereList=whereList)
Received HTTP response 400 from 10.10.10.128. Caller is [(<frame object at 0x9d082a4>, 'swClassLib.py', 89, 'sendRequest', ['\t\tcaller = inspect.stack()\n'], 0), (<frame object at 0xb60271e4>, 'swClassLib.py', 1749, 'getOrionVIMVirtualMachines', ["\t\t\tcurrOrionVIMVirtualMachines = self.sendRequest(Type='GET', URL= '/SolarWinds/InformationService/v3/Json/Query?query=' + selectQuery, status=200)\n"], 0), (<frame object at 0xb601038c>, '<stdin>', 1, '<module>', None, None)]. Unable to continue

HTTP response 400 means bad request

Now here it is with debug on, and you can see the query at the end WHERE+NAME+=+

There should be a value there, so this is what is wrong

Sorry, you will need to scroll right / left to see it all

>>> sw.getOrionVIMVirtualMachines(whereList=whereList)
send: 'GET /SolarWinds/InformationService/v3/Json/Query?query=SELECT+VirtualMachineID+,+ManagedObjectID+,+UUID+,+HostID+,+NodeID+,+ResourcePoolID+,+VMConfigFile+,+MemoryConfigured+,+MemoryShares+,+CPUShares+,+GuestState+,+IPAddress+,+LogDirectory+,+GuestVmWareToolsVersion+,+GuestVmWareToolsStatus+,+Name+,+GuestName+,+GuestFamily+,+GuestDnsName+,+NicCount+,+VDisksCount+,+ProcessorCount+,+PowerState+,+BootTime+,+ConfigStatus+,+OverallStatus+,+NodeStatus+,+NetworkUsageRate+,+NetworkTransmitRate+,+NetworkReceiveRate+,+CpuLoad+,+CpuUsageMHz+,+MemUsage+,+MemUsageMB+,+IsLicensed+FROM+Orion.VIM.VirtualMachines+WHERE+Name+=+ HTTP/1.1\r\nHost: 10.10.10.128:17778\r\nAccept-Encoding: identity\r\nContent-Type: application/json\r\nauthorization: Basic YWRtaW46\n\r\nAccept: application/json\r\n\r\n'
reply: 'HTTP/1.1 400 Bad Request\r\n'
header: Content-Length: 68
header: Content-Type: application/json
header: Server: Microsoft-HTTPAPI/2.0
header: Date: Mon, 07 Oct 2013 17:06:46 GMT
Response Status from [(<frame object at 0x99aaef4>, 'swClassLib.py', 89, 'sendRequest', ['\t\tcaller = inspect.stack()\n'], 0), (<frame object at 0x97f845c>, 'swClassLib.py', 1749, 'getOrionVIMVirtualMachines', ["\t\t\tcurrOrionVIMVirtualMachines = self.sendRequest(Type='GET', URL= '/SolarWinds/InformationService/v3/Json/Query?query=' + selectQuery, status=200)\n"], 0), (<frame object at 0xb60105c4>, '<stdin>', 1, '<module>', None, None)] = 400. Expecting 200
Received HTTP response 400 from 10.10.10.128. Caller is [(<frame object at 0x99aaef4>, 'swClassLib.py', 89, 'sendRequest', ['\t\tcaller = inspect.stack()\n'], 0), (<frame object at 0x97f845c>, 'swClassLib.py', 1749, 'getOrionVIMVirtualMachines', ["\t\t\tcurrOrionVIMVirtualMachines = self.sendRequest(Type='GET', URL= '/SolarWinds/InformationService/v3/Json/Query?query=' + selectQuery, status=200)\n"], 0), (<frame object at 0xb60105c4>, '<stdin>', 1, '<module>', None, None)]. Unable to continue
[]