device import from libreNMS failure
When trying to import devices from libreNMS, the followign error is rasied:
object{8} | object | | {8}
-- | -- | -- | --
object | | {8}
duration:0:00:00 | | duration | : | 0:00:00
| duration | : | 0:00:00
properties{2} | | properties | | {2}
| properties | | {2}
result:Traceback (most recent call last): File \"/usr/home/darcy/eNMS/eNMS/models/automation.py\", line 757, in run_service_job results = self.service.job(self, payload, *args) File \"/usr/home/darcy/eNMS/eNMS/services/miscellaneous/topology_import.py\", line 36, in job getattr(self, f\"query_{self.import_type}\")() File \"/usr/home/darcy/eNMS/eNMS/services/miscellaneous/topology_import.py\", line 93, in query_librenms ).json()[\"devices\"]KeyError: 'devices' | | result | : | Traceback (most recent call last): File \"/usr/home/darcy/eNMS/eNMS/models/automation.py\", line 757, in run_service_job results = self.service.job(self, payload, *args) File \"/usr/home/darcy/eNMS/eNMS/services/miscellaneous/topology_import.py\", line 36, in job getattr(self, f\"query_{self.import_type}\")() File \"/usr/home/darcy/eNMS/eNMS/services/miscellaneous/topology_import.py\", line 93, in query_librenms ).json()[\"devices\"]KeyError: 'devices'
| result | : | Traceback (most recent call last): File \"/usr/home/darcy/eNMS/eNMS/models/automation.py\", line 757, in run_service_job results = self.service.job(self, payload, *args) File \"/usr/home/darcy/eNMS/eNMS/services/miscellaneous/topology_import.py\", line 36, in job getattr(self, f\"query_{self.import_type}\")() File \"/usr/home/darcy/eNMS/eNMS/services/miscellaneous/topology_import.py\", line 93, in query_librenms ).json()[\"devices\"]KeyError: 'devices'
runtime:2020-08-05 02:59:41.059297 | | runtime | : | 2020-08-05 02:59:41.059297
| runtime | : | 2020-08-05 02:59:41.059297
state{2} | | state | | {2}
| state | | {2}
success:false | | success | : | false
| success | : | false
summary{2} | | summary | | {2}
| summary | | {2}
trigger:UI | | trigger | : | UI
| trigger | : | UI
``` This is regression behavior, as it was working in -master ~30 days ago
that code hasn't changed in 4 months: https://github.com/eNMS-automation/eNMS/blame/081fdb2d4493dfa6d11afcb7b8f2bcfeb84299a0/eNMS/services/miscellaneous/topology_import.py#L89-L107
so if something has changed, it's either your environment, or librenms ?
upon further investigation, the issue is a trailing / in the url. this results in the following to be sent to librenms:
Host: nms.if.hamwan.ca
User-Agent: curl/7.71.1
Accept: */*
X-Auth-Token: <hidden>
returning back to the process:
HTTP/1.1 401 Unauthorized
Date: Wed, 05 Aug 2020 13:25:45 GMT
Server: Apache/2.4.29 (Ubuntu)
Cache-Control: no-cache, private
Set-Cookie: XSRF-TOKEN=eyJpdiI6IjV0OG5MV0c1Q3gvcmxIZFZDL1FXbHc9PSIsInZhbHVlIjoiMW5kMVYwVFVRQWgrME8vdm9MYXVJWmxISVduT1NSSXZLc1BSY0VBM3RQOWRKMVpXSnNwTGhqU0laemlnT3RSOCIsIm1hYyI6Ijk3YmY5NzNlZmU0MGI4N2ViMjBkZDVmZDZiY2RmNmQxZWIxYzAzZTI0ODdlYmU1MjFiYTVkYTI5MTY2NjJjNmUifQ%3D%3D; expires=Wed, 05-Aug-2020 15:25:45 GMT; Max-Age=7200; path=/; samesite=lax
Set-Cookie: laravel_session=eyJpdiI6IjlrS0ZlQWluTnBZS2tkMlVCd244eHc9PSIsInZhbHVlIjoiZDA3TnB0Z3h3Sm5GNm4vZkRCOVZHWVRiT2xpSlpNNDJXblh4aUdOd2JWWDZkczhPd2M0TnJaZmRSY0hMWGVjUiIsIm1hYyI6IjBhNjA0ZmY1N2IzNmI3N2FjYmEyMzM5MmJiNWFhY2ZkOGNkMjQ0N2EwOGNlZjE5MGRmMzI3ZWM2MzI5NDkxZTcifQ%3D%3D; expires=Wed, 05-Aug-2020 15:25:45 GMT; Max-Age=7200; path=/; httponly; samesite=lax
Content-Length: 30
Content-Type: application/json
{"message":"Unauthenticated."}[!http]
This response code is not checked, and the message is not interpreted.
Confirmation of the // in the url being the casue of the issues was confirmed with curl:
[darcy@nms /usr/home/darcy/eNMS]$ curl -s -H "X-Auth-Token: <hidden>" http://librenms//api/v0/devices | wc -l
0
[darcy@nms /usr/home/darcy/eNMS]$ curl -s -H "X-Auth-Token: <hidden>" http://librenms/api/v0/devices | wc -l
4181
And in the gui.