Skip to content

Commit

Permalink
Additional fix for deprecation warnings. (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
BGmot authored Jan 8, 2023
1 parent a5ce006 commit 0635e33
Show file tree
Hide file tree
Showing 29 changed files with 71 additions and 64 deletions.
14 changes: 7 additions & 7 deletions plugins/doc_fragments/zabbix.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ class ModuleDocFragment(object):
description:
- The timeout of API request (seconds).
- This option is deprecated with the move to httpapi connection and will be removed in the next release
- The default value is C(10)
type: int
default: 10
validate_certs:
description:
- If set to False, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates.
- If not set the environment variable C(ZABBIX_VALIDATE_CERTS) will be used.
- This option is deprecated with the move to httpapi connection and will be removed in the next release
type: bool
default: true
description:
- If set to False, SSL certificates will not be validated. This should only be used on personally controlled sites using self-signed certificates.
- If not set the environment variable C(ZABBIX_VALIDATE_CERTS) will be used.
- This option is deprecated with the move to httpapi connection and will be removed in the next release
- The default value is C(true)
type: bool
notes:
- If you use I(login_password=zabbix), the word "zabbix" is replaced by "********" in all module output, because I(login_password) uses C(no_log).
See L(this FAQ,https://docs.ansible.com/ansible/latest/network/user_guide/faq.html#why-is-my-output-sometimes-replaced-with) for more information.
Expand Down
4 changes: 1 addition & 3 deletions plugins/module_utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,11 @@ def zabbix_common_argument_spec():
no_log=True
),
timeout=dict(
type='int',
default=10
type='int'
),
validate_certs=dict(
type='bool',
required=False,
default=True,
fallback=(env_fallback, ['ZABBIX_VALIDATE_CERTS'])
),
)
Expand Down
13 changes: 11 additions & 2 deletions plugins/module_utils/wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,17 @@ def __init__(self, module, zbx=None):
self._zapi = zbx
else:
server_url = module.params['server_url']
validate_certs = module.params['validate_certs']
timeout = module.params['timeout']

if module.params['validate_certs'] is None:
validate_certs = True
else:
validate_certs = module.params['validate_certs']

if module.params['timeout'] is None:
timeout = 10
else:
timeout = module.params['timeout']

self._zapi = ZabbixAPI(server_url, timeout=timeout, validate_certs=validate_certs)

self.login()
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -1967,8 +1967,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

name = module.params['name']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -559,8 +559,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

authentication_type = module.params['authentication_type']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_autoregister.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

tls_accept = module.params['tls_accept']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_discovery_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,8 +649,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

state = module.params['state']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_globalmacro.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

macro_name = normalize_macro_name(module.params['macro_name'])
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_group_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

if module._name == 'zabbix_group_facts':
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_host.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,8 +1048,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

host_name = module.params['host_name']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_host_events_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

trigger_severity_map = {'not_classified': 0, 'information': 1, 'warning': 2, 'average': 3, 'high': 4, 'disaster': 5}
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_hostmacro.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

host_name = module.params['host_name']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_housekeeping.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

hk_events_mode = module.params['hk_events_mode']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

maint = MaintenanceModule(module)
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

if not HAS_PYDOTPLUS:
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_mediatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,8 +718,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

state = module.params['state']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,8 +363,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

proxy_name = module.params['proxy_name']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_proxy_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

name = module.params['proxy_name']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

screens = module.params['screens']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

name = module.params['name']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -654,8 +654,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

name = module.params['name']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

template_name = module.params['template_name']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_template_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

template_name = module.params['template_name']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,8 +677,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

username = module.params['username']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_user_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

parameters = {
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_user_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

username = module.params['username']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_user_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection '
'and will be removed in the next release' % p)

Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_usergroup.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)

name = module.params['name']
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/zabbix_valuemap.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ def main():

zabbix_utils.require_creds_params(module)

for p in ['server_url', 'login_user', 'login_password']:
if p in module.params and module.params[p]:
for p in ['server_url', 'login_user', 'login_password', 'timeout', 'validate_certs']:
if p in module.params and not module.params[p] is None:
module.warn('Option "%s" is deprecated with the move to httpapi connection and will be removed in the next release' % p)
vm = ValuemapModule(module)

Expand Down

0 comments on commit 0635e33

Please sign in to comment.