-
Bug
-
Resolution: Fixed
-
Low
-
None
-
Severity 3 - Minor
-
Issue Summary
OEC Solarwinds Web Help Desk package has 2 issues.
First point the mapped action in config.json does not match the actions named in the actionExecutor.py script.
Second point the actionExecutor.py script contains 3 bug in lines 50, 68, and 102, its is unable to concatenate response.status_code as part of a string as it is an integer, this only happens when executing a mapped action which fails..... when we attempt to log the failure an exception is thrown.
Steps to Reproduce
First point you can simply look at the repo to see that the mapped action in config.json do not match any of the actions defined in the actionExecutor.py.
Second Point after fixing the config.json attempt to execute an action so that it forces a failure, a good way to do this is change the id in actionExecutor.py from from 6 to 7 in line 22 and then attempt to acknowledge a corresponding alert in Opsgenie.
Expected Results
First point the mapped actions in config.json should have corresponding actions with the same name in actionExecutor.py.
Second Point if the actions failed it should be able to write to log without without exception being thrown when writing to log.
Actual Results
First point since the mapped action in config.json do not match those in the script it is impossible for the actions in the script to be executed.
Second point if an actions fail to execute, exceptions are returned referencing lines 50, 68 and 102 as the offending lines stating that response.status_code could not be converted to string as it is type int.
Traceback (most recent call last): File "C:\opsgenie\opsgenie-oec\scripts\actionExecutor.py", line 131, in <module> main() ~~~~^^ File "C:\opsgenie\opsgenie-oec\scripts\actionExecutor.py", line 125, in main send_acknowledge_request() ~~~~~~~~~~~~~~~~~~~~~~~~^^ File "C:\opsgenie\opsgenie-oec\scripts\actionExecutor.py", line 68, in send_acknowledge_request LOG_PREFIX + " Could not execute at Solarwinds; response: " + response.status_code + ' ' + str( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ TypeError: can only concatenate str (not "int") to str
Workaround
First Point instead of using the existing example config.json file in github rather use this one which has the mapped actions correctly named.
{ "apiKey": "<API_KEY>", "baseUrl": "https://api.opsgenie.com", "logLevel": "DEBUG", "globalArgs": [], "globalFlags": { "serverUrl": "<serverUrl>", "apiToken": "<apiToken>" }, "actionMappings": { "Acknowledge": { "filepath": "<path_of_script>", "sourceType": "<local | git>", "env": [], "stdout": "<path_of_output_file_of_script>" }, "AddNote": { "filepath": "<path_of_script>", "sourceType": "<local | git>", "env": [], "stdout": "<path_of_output_file_of_script>" }, "Close": { "filepath": "<path_of_script>", "sourceType": "<local | git>", "env": [], "stdout": "<path_of_output_file_of_script>" } }, "pollerConf": { "pollingWaitIntervalInMillis": 100, "visibilityTimeoutInSec": 30, "maxNumberOfMessages": 10 }, "poolConf": { "maxNumberOfWorker": 12, "minNumberOfWorker": 4, "monitoringPeriodInMillis": 15000, "keepAliveTimeInMillis": 6000, "queueSize": 0 } }
Second Point you can fix the type error by casting response.status_code to a string, to do this change lines 50, 68 and 102 to the following:
LOG_PREFIX + " Could not execute at Solarwinds; response: " + str(response.status_code) + ' ' + str( response.content))