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:
parent
08e23a2a93
commit
1eb11edb14
2 changed files with 6 additions and 18 deletions
3
changelogs/fragments/49568-type-checking.yaml
Normal file
3
changelogs/fragments/49568-type-checking.yaml
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- "nagios - Removed redundant type check which caused crashes. Guardrails added elsewhere in earlier change."
|
|
@ -65,6 +65,7 @@ options:
|
||||||
description:
|
description:
|
||||||
- Minutes to schedule downtime for.
|
- Minutes to schedule downtime for.
|
||||||
- Only usable with the C(downtime) action.
|
- Only usable with the C(downtime) action.
|
||||||
|
type: int
|
||||||
default: 30
|
default: 30
|
||||||
services:
|
services:
|
||||||
description:
|
description:
|
||||||
|
@ -193,7 +194,6 @@ EXAMPLES = '''
|
||||||
command: DISABLE_FAILURE_PREDICTION
|
command: DISABLE_FAILURE_PREDICTION
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import types
|
|
||||||
import time
|
import time
|
||||||
import os.path
|
import os.path
|
||||||
import stat
|
import stat
|
||||||
|
@ -271,7 +271,6 @@ def main():
|
||||||
action = module.params['action']
|
action = module.params['action']
|
||||||
host = module.params['host']
|
host = module.params['host']
|
||||||
servicegroup = module.params['servicegroup']
|
servicegroup = module.params['servicegroup']
|
||||||
minutes = module.params['minutes']
|
|
||||||
services = module.params['services']
|
services = module.params['services']
|
||||||
cmdfile = module.params['cmdfile']
|
cmdfile = module.params['cmdfile']
|
||||||
command = module.params['command']
|
command = module.params['command']
|
||||||
|
@ -284,7 +283,7 @@ def main():
|
||||||
# command = command
|
# command = command
|
||||||
#
|
#
|
||||||
# AnsibleModule will verify most stuff, we need to verify
|
# AnsibleModule will verify most stuff, we need to verify
|
||||||
# 'minutes' and 'service' manually.
|
# 'service' manually.
|
||||||
|
|
||||||
##################################################################
|
##################################################################
|
||||||
if action not in ['command', 'silence_nagios', 'unsilence_nagios']:
|
if action not in ['command', 'silence_nagios', 'unsilence_nagios']:
|
||||||
|
@ -295,13 +294,6 @@ def main():
|
||||||
# Make sure there's an actual service selected
|
# Make sure there's an actual service selected
|
||||||
if not services:
|
if not services:
|
||||||
module.fail_json(msg='no service selected to set downtime for')
|
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':
|
if action == 'delete_downtime':
|
||||||
|
@ -315,13 +307,6 @@ def main():
|
||||||
# Make sure there's an actual servicegroup selected
|
# Make sure there's an actual servicegroup selected
|
||||||
if not servicegroup:
|
if not servicegroup:
|
||||||
module.fail_json(msg='no servicegroup selected to set downtime for')
|
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']:
|
if action in ['enable_alerts', 'disable_alerts']:
|
||||||
|
@ -367,7 +352,7 @@ class Nagios(object):
|
||||||
self.comment = kwargs['comment']
|
self.comment = kwargs['comment']
|
||||||
self.host = kwargs['host']
|
self.host = kwargs['host']
|
||||||
self.servicegroup = kwargs['servicegroup']
|
self.servicegroup = kwargs['servicegroup']
|
||||||
self.minutes = int(kwargs['minutes'])
|
self.minutes = kwargs['minutes']
|
||||||
self.cmdfile = kwargs['cmdfile']
|
self.cmdfile = kwargs['cmdfile']
|
||||||
self.command = kwargs['command']
|
self.command = kwargs['command']
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue