mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 13:52:54 +00:00
PEP 8 E111 & E114 cleanup. (#20838)
This commit is contained in:
@@ -307,7 +307,7 @@ def delete_monitor(module):
|
||||
def mute_monitor(module):
|
||||
monitor = _get_monitor(module)
|
||||
if not monitor:
|
||||
module.fail_json(msg="Monitor %s not found!" % module.params['name'])
|
||||
module.fail_json(msg="Monitor %s not found!" % module.params['name'])
|
||||
elif monitor['options']['silenced']:
|
||||
module.fail_json(msg="Monitor is already muted. Datadog does not allow to modify muted alerts, consider unmuting it first.")
|
||||
elif (module.params['silenced'] is not None
|
||||
@@ -327,7 +327,7 @@ def mute_monitor(module):
|
||||
def unmute_monitor(module):
|
||||
monitor = _get_monitor(module)
|
||||
if not monitor:
|
||||
module.fail_json(msg="Monitor %s not found!" % module.params['name'])
|
||||
module.fail_json(msg="Monitor %s not found!" % module.params['name'])
|
||||
elif not monitor['options']['silenced']:
|
||||
module.exit_json(changed=False)
|
||||
try:
|
||||
|
||||
@@ -144,21 +144,21 @@ def post_annotation(module):
|
||||
|
||||
def main():
|
||||
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
user = dict(required=True),
|
||||
api_key = dict(required=True),
|
||||
name = dict(required=False),
|
||||
title = dict(required=True),
|
||||
source = dict(required=False),
|
||||
description = dict(required=False),
|
||||
start_time = dict(required=False, default=None, type='int'),
|
||||
end_time = dict(require=False, default=None, type='int'),
|
||||
links = dict(type='list')
|
||||
)
|
||||
)
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
user = dict(required=True),
|
||||
api_key = dict(required=True),
|
||||
name = dict(required=False),
|
||||
title = dict(required=True),
|
||||
source = dict(required=False),
|
||||
description = dict(required=False),
|
||||
start_time = dict(required=False, default=None, type='int'),
|
||||
end_time = dict(require=False, default=None, type='int'),
|
||||
links = dict(type='list')
|
||||
)
|
||||
)
|
||||
|
||||
post_annotation(module)
|
||||
post_annotation(module)
|
||||
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.urls import *
|
||||
|
||||
@@ -567,8 +567,8 @@ def selector(module):
|
||||
to take given the right parameters"""
|
||||
|
||||
if module.params["target"] == "host":
|
||||
target = Host(module.params, module)
|
||||
target.site_facts()
|
||||
target = Host(module.params, module)
|
||||
target.site_facts()
|
||||
elif module.params["target"] == "hostgroup":
|
||||
# Validate target specific required parameters
|
||||
if module.params["fullpath"] is not None:
|
||||
|
||||
@@ -286,29 +286,29 @@ def sensu_check(module, path, name, state='present', backup=False):
|
||||
reasons.append('`{opt}\' was removed'.format(opt=opt))
|
||||
|
||||
if module.params['custom']:
|
||||
# Convert to json
|
||||
custom_params = module.params['custom']
|
||||
overwrited_fields = set(custom_params.keys()) & set(simple_opts + ['type','subdue','subdue_begin','subdue_end'])
|
||||
if overwrited_fields:
|
||||
msg = 'You can\'t overwriting standard module parameters via "custom". You are trying overwrite: {opt}'.format(opt=list(overwrited_fields))
|
||||
module.fail_json(msg=msg)
|
||||
# Convert to json
|
||||
custom_params = module.params['custom']
|
||||
overwrited_fields = set(custom_params.keys()) & set(simple_opts + ['type','subdue','subdue_begin','subdue_end'])
|
||||
if overwrited_fields:
|
||||
msg = 'You can\'t overwriting standard module parameters via "custom". You are trying overwrite: {opt}'.format(opt=list(overwrited_fields))
|
||||
module.fail_json(msg=msg)
|
||||
|
||||
for k,v in custom_params.items():
|
||||
if k in config['checks'][name]:
|
||||
if not config['checks'][name][k] == v:
|
||||
changed = True
|
||||
reasons.append('`custom param {opt}\' was changed'.format(opt=k))
|
||||
else:
|
||||
changed = True
|
||||
reasons.append('`custom param {opt}\' was added'.format(opt=k))
|
||||
check[k] = v
|
||||
simple_opts += custom_params.keys()
|
||||
for k,v in custom_params.items():
|
||||
if k in config['checks'][name]:
|
||||
if not config['checks'][name][k] == v:
|
||||
changed = True
|
||||
reasons.append('`custom param {opt}\' was changed'.format(opt=k))
|
||||
else:
|
||||
changed = True
|
||||
reasons.append('`custom param {opt}\' was added'.format(opt=k))
|
||||
check[k] = v
|
||||
simple_opts += custom_params.keys()
|
||||
|
||||
# Remove obsolete custom params
|
||||
for opt in set(config['checks'][name].keys()) - set(simple_opts + ['type','subdue','subdue_begin','subdue_end']):
|
||||
changed = True
|
||||
reasons.append('`custom param {opt}\' was deleted'.format(opt=opt))
|
||||
del check[opt]
|
||||
changed = True
|
||||
reasons.append('`custom param {opt}\' was deleted'.format(opt=opt))
|
||||
del check[opt]
|
||||
|
||||
if module.params['metric']:
|
||||
if 'type' not in check or check['type'] != 'metric':
|
||||
|
||||
Reference in New Issue
Block a user