SumoLogic-Labs / collector-management-client

A Python script for quickly managing a subset of installed Collectors

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

deleteOfflineCollectors has extra leading / in path causing delete to fail with HTTP 400

rjury-sumo opened this issue · comments

the deleteOfflineCollectors code has an extra / that is prefixed to the final path. So using a -url with a trailing / will fail
The api call with fail with as it ends up with //

if you listofflinecollectors the path is constructed as 'collectors/offline'

this is also true in the prompt to delete offline collectors:
https://github.com/SumoLogic-Labs/collector-management-client/blob/main/sumo_mgmt.py#L711

 collectors = get_collectors('collectors/offline', None, args.deleteOfflineCollectors[0])

creating say:
http://api.au.sumologic.com/api/v1/collectors/offline?offset=0&limit=1000&aliveBeforeDays=100

However the actual delete call has a preceding / extra so when the user enters Y it sends an invalid url:
https://github.com/SumoLogic-Labs/collector-management-client/blob/main/sumo_mgmt.py#L686
url is constructed as:

url = args.url[0] + '/collectors/offline'

http://api.au.sumologic.com/api/v1//collectors/offline?aliveBeforeDays=100

This will fail and return a http 400.

To fix surely line 686 should be:

url = args.url[0] + 'collectors/offline'