1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

fix legacy PEP8 violations in zabbix modules, remove test exception for them (#31702)

* fix legacy PEP8 violations in zabbix_*, remove test exception for them

* fix new pep8 violations for zabbix_maintenance.py
This commit is contained in:
Eike Frost 2017-10-16 19:20:54 +02:00 committed by René Moser
parent 85bd104c7c
commit 1b71fb0499
6 changed files with 14 additions and 21 deletions

View file

@ -165,11 +165,11 @@ def main():
server_url=dict(type='str', required=True, aliases=['url']),
login_user=dict(type='str', required=True),
login_password=dict(type='str', required=True, no_log=True),
http_login_user=dict(type='str',required=False, default=None),
http_login_password=dict(type='str',required=False, default=None, no_log=True),
validate_certs=dict(type='bool',required=False, default=True),
http_login_user=dict(type='str', required=False, default=None),
http_login_password=dict(type='str', required=False, default=None, no_log=True),
validate_certs=dict(type='bool', required=False, default=True),
host_groups=dict(type='list', required=True, aliases=['host_group']),
state=dict(default="present", choices=['present','absent']),
state=dict(default="present", choices=['present', 'absent']),
timeout=dict(type='int', default=10)
),
supports_check_mode=True

View file

@ -226,7 +226,6 @@ import copy
try:
from zabbix_api import ZabbixAPI, ZabbixAPISubClass
# Extend the ZabbixAPI
# Since the zabbix-api python module too old (version 1.0, no higher version so far),
# it does not support the 'hostinterface' api calls,
@ -238,7 +237,6 @@ try:
ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd, validate_certs=validate_certs)
self.hostinterface = ZabbixAPISubClass(self, dict({"prefix": "hostinterface"}, **kwargs))
HAS_ZABBIX_API = True
except ImportError:
HAS_ZABBIX_API = False

View file

@ -151,7 +151,7 @@ class HostMacro(object):
# update host macro
def update_host_macro(self, host_macro_obj, macro_name, macro_value):
host_macro_id = host_macro_obj['hostmacroid']
if host_macro_obj['macro'] == '{$'+macro_name+'}' and host_macro_obj['value'] == macro_value:
if host_macro_obj['macro'] == '{$' + macro_name + '}' and host_macro_obj['value'] == macro_value:
self._module.exit_json(changed=False, result="Host macro %s already up to date" % macro_name)
try:
if self._module.check_mode:
@ -172,6 +172,7 @@ class HostMacro(object):
except Exception as e:
self._module.fail_json(msg="Failed to delete host macro %s: %s" % (macro_name, e))
def main():
module = AnsibleModule(
argument_spec=dict(
@ -200,7 +201,7 @@ def main():
http_login_password = module.params['http_login_password']
validate_certs = module.params['validate_certs']
host_name = module.params['host_name']
macro_name = (module.params['macro_name']).upper()
macro_name = (module.params['macro_name']).upper()
macro_value = module.params['macro_value']
state = module.params['state']
timeout = module.params['timeout']

View file

@ -184,7 +184,7 @@ def create_maintenance(zbx, group_ids, host_ids, start_time, maintenance_type, p
"active_since": str(start_time),
"active_till": str(end_time),
"description": desc,
"timeperiods": [{
"timeperiods": [{
"timeperiod_type": "0",
"start_date": str(start_time),
"period": str(period),
@ -208,7 +208,7 @@ def update_maintenance(zbx, maintenance_id, group_ids, host_ids, start_time, mai
"active_since": str(start_time),
"active_till": str(end_time),
"description": desc,
"timeperiods": [{
"timeperiods": [{
"timeperiod_type": "0",
"start_date": str(start_time),
"period": str(period),
@ -380,11 +380,11 @@ def main():
module.fail_json(msg="Failed to check maintenance %s existence: %s" % (name, error))
if maintenance and (
sorted(group_ids) != sorted(maintenance["groupids"])
or sorted(host_ids) != sorted(maintenance["hostids"])
or str(maintenance_type) != maintenance["maintenance_type"]
or str(int(start_time)) != maintenance["active_since"]
or str(int(start_time + period)) != maintenance["active_till"]
sorted(group_ids) != sorted(maintenance["groupids"]) or
sorted(host_ids) != sorted(maintenance["hostids"]) or
str(maintenance_type) != maintenance["maintenance_type"] or
str(int(start_time)) != maintenance["active_since"] or
str(int(start_time + period)) != maintenance["active_till"]
):
if module.check_mode:
changed = True

View file

@ -8,7 +8,6 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}

View file

@ -171,11 +171,6 @@ lib/ansible/modules/monitoring/sensu_check.py
lib/ansible/modules/monitoring/sensu_subscription.py
lib/ansible/modules/monitoring/stackdriver.py
lib/ansible/modules/monitoring/uptimerobot.py
lib/ansible/modules/monitoring/zabbix_group.py
lib/ansible/modules/monitoring/zabbix_host.py
lib/ansible/modules/monitoring/zabbix_hostmacro.py
lib/ansible/modules/monitoring/zabbix_maintenance.py
lib/ansible/modules/monitoring/zabbix_screen.py
lib/ansible/modules/network/a10/a10_server_axapi3.py
lib/ansible/modules/network/a10/a10_virtual_server.py
lib/ansible/modules/network/aos/aos_asn_pool.py