Removed breaking type check from nagios module (#49568)

* Removed extraneous type check from nagios module, in order to allow python 3.x

* Removed now useless import types

* Added changelog fragment

* Update changelog.

* Rebased and removed check due to module adding earlier guardrails

* Updated changelog to mention earlier fix adding now completely removed guardrails

* Remove superfluous type checks. Fix docs type.

* Update ignore.txt.

(cherry picked from commit 5d8302120b)
This commit is contained in:
silverwizard 2019-08-07 16:43:14 -04:00 committed by Toshio Kuratomi
parent 08e23a2a93
commit 1eb11edb14
2 changed files with 6 additions and 18 deletions

View file

@ -0,0 +1,3 @@
---
bugfixes:
- "nagios - Removed redundant type check which caused crashes. Guardrails added elsewhere in earlier change."

View file

@ -65,6 +65,7 @@ options:
description:
- Minutes to schedule downtime for.
- Only usable with the C(downtime) action.
type: int
default: 30
services:
description:
@ -193,7 +194,6 @@ EXAMPLES = '''
command: DISABLE_FAILURE_PREDICTION
'''
import types
import time
import os.path
import stat
@ -271,7 +271,6 @@ def main():
action = module.params['action']
host = module.params['host']
servicegroup = module.params['servicegroup']
minutes = module.params['minutes']
services = module.params['services']
cmdfile = module.params['cmdfile']
command = module.params['command']
@ -284,7 +283,7 @@ def main():
# command = command
#
# AnsibleModule will verify most stuff, we need to verify
# 'minutes' and 'service' manually.
# 'service' manually.
##################################################################
if action not in ['command', 'silence_nagios', 'unsilence_nagios']:
@ -295,13 +294,6 @@ def main():
# Make sure there's an actual service selected
if not services:
module.fail_json(msg='no service selected to set downtime for')
# Make sure minutes is a number
try:
m = int(minutes)
if not isinstance(m, types.IntType):
module.fail_json(msg='minutes must be a number')
except Exception:
module.fail_json(msg='invalid entry for minutes')
######################################################################
if action == 'delete_downtime':
@ -315,13 +307,6 @@ def main():
# Make sure there's an actual servicegroup selected
if not servicegroup:
module.fail_json(msg='no servicegroup selected to set downtime for')
# Make sure minutes is a number
try:
m = int(minutes)
if not isinstance(m, types.IntType):
module.fail_json(msg='minutes must be a number')
except Exception:
module.fail_json(msg='invalid entry for minutes')
##################################################################
if action in ['enable_alerts', 'disable_alerts']:
@ -367,7 +352,7 @@ class Nagios(object):
self.comment = kwargs['comment']
self.host = kwargs['host']
self.servicegroup = kwargs['servicegroup']
self.minutes = int(kwargs['minutes'])
self.minutes = kwargs['minutes']
self.cmdfile = kwargs['cmdfile']
self.command = kwargs['command']