Make warning logs consistent (#23666)
* Make warning logs consistent Arguments outside provider with default value should not log as warning in case it is not mentioned in play. * Make nxos timeout default consistent and add comments * Make comments more verbosepull/4420/head
parent
698fa37a44
commit
bf1a543f06
|
@ -40,7 +40,7 @@ _DEVICE_CONNECTION = None
|
||||||
|
|
||||||
eos_argument_spec = {
|
eos_argument_spec = {
|
||||||
'host': dict(),
|
'host': dict(),
|
||||||
'port': dict(type='int', default=443),
|
'port': dict(type='int'),
|
||||||
'username': dict(fallback=(env_fallback, ['ANSIBLE_NET_USERNAME'])),
|
'username': dict(fallback=(env_fallback, ['ANSIBLE_NET_USERNAME'])),
|
||||||
'password': dict(fallback=(env_fallback, ['ANSIBLE_NET_PASSWORD']), no_log=True),
|
'password': dict(fallback=(env_fallback, ['ANSIBLE_NET_PASSWORD']), no_log=True),
|
||||||
'ssh_keyfile': dict(fallback=(env_fallback, ['ANSIBLE_NET_SSH_KEYFILE']), type='path'),
|
'ssh_keyfile': dict(fallback=(env_fallback, ['ANSIBLE_NET_SSH_KEYFILE']), type='path'),
|
||||||
|
@ -49,14 +49,21 @@ eos_argument_spec = {
|
||||||
'authorize': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTHORIZE']), type='bool'),
|
'authorize': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTHORIZE']), type='bool'),
|
||||||
'auth_pass': dict(no_log=True, fallback=(env_fallback, ['ANSIBLE_NET_AUTH_PASS'])),
|
'auth_pass': dict(no_log=True, fallback=(env_fallback, ['ANSIBLE_NET_AUTH_PASS'])),
|
||||||
|
|
||||||
'use_ssl': dict(type='bool', default=True),
|
'use_ssl': dict(type='bool'),
|
||||||
'validate_certs': dict(type='bool', default=True),
|
'validate_certs': dict(type='bool'),
|
||||||
'timeout': dict(type='int'),
|
'timeout': dict(type='int'),
|
||||||
|
|
||||||
'provider': dict(type='dict'),
|
'provider': dict(type='dict'),
|
||||||
'transport': dict(choices=['cli', 'eapi'])
|
'transport': dict(choices=['cli', 'eapi'])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add argument's default value here
|
||||||
|
ARGS_DEFAULT_VALUE = {
|
||||||
|
'port': 443,
|
||||||
|
'use_ssl': True,
|
||||||
|
'validate_certs': True
|
||||||
|
}
|
||||||
|
|
||||||
def check_args(module, warnings):
|
def check_args(module, warnings):
|
||||||
provider = module.params['provider'] or {}
|
provider = module.params['provider'] or {}
|
||||||
for key in eos_argument_spec:
|
for key in eos_argument_spec:
|
||||||
|
@ -64,6 +71,13 @@ def check_args(module, warnings):
|
||||||
warnings.append('argument %s has been deprecated and will be '
|
warnings.append('argument %s has been deprecated and will be '
|
||||||
'removed in a future version' % key)
|
'removed in a future version' % key)
|
||||||
|
|
||||||
|
# set argument's default value if not provided in input
|
||||||
|
# This is done to avoid unwanted argument deprecation warning
|
||||||
|
# in case argument is not given as input (outside provider).
|
||||||
|
for key in ARGS_DEFAULT_VALUE:
|
||||||
|
if not module.params.get(key, None):
|
||||||
|
module.params[key] = ARGS_DEFAULT_VALUE[key]
|
||||||
|
|
||||||
if provider:
|
if provider:
|
||||||
for param in ('auth_pass', 'password'):
|
for param in ('auth_pass', 'password'):
|
||||||
if provider.get(param):
|
if provider.get(param):
|
||||||
|
|
|
@ -36,11 +36,16 @@ junos_argument_spec = {
|
||||||
'username': dict(fallback=(env_fallback, ['ANSIBLE_NET_USERNAME'])),
|
'username': dict(fallback=(env_fallback, ['ANSIBLE_NET_USERNAME'])),
|
||||||
'password': dict(fallback=(env_fallback, ['ANSIBLE_NET_PASSWORD']), no_log=True),
|
'password': dict(fallback=(env_fallback, ['ANSIBLE_NET_PASSWORD']), no_log=True),
|
||||||
'ssh_keyfile': dict(fallback=(env_fallback, ['ANSIBLE_NET_SSH_KEYFILE']), type='path'),
|
'ssh_keyfile': dict(fallback=(env_fallback, ['ANSIBLE_NET_SSH_KEYFILE']), type='path'),
|
||||||
'timeout': dict(type='int', default=10),
|
'timeout': dict(type='int'),
|
||||||
'provider': dict(type='dict'),
|
'provider': dict(type='dict'),
|
||||||
'transport': dict()
|
'transport': dict()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add argument's default value here
|
||||||
|
ARGS_DEFAULT_VALUE = {
|
||||||
|
'timeout': 10
|
||||||
|
}
|
||||||
|
|
||||||
def check_args(module, warnings):
|
def check_args(module, warnings):
|
||||||
provider = module.params['provider'] or {}
|
provider = module.params['provider'] or {}
|
||||||
for key in junos_argument_spec:
|
for key in junos_argument_spec:
|
||||||
|
@ -48,6 +53,13 @@ def check_args(module, warnings):
|
||||||
warnings.append('argument %s has been deprecated and will be '
|
warnings.append('argument %s has been deprecated and will be '
|
||||||
'removed in a future version' % key)
|
'removed in a future version' % key)
|
||||||
|
|
||||||
|
# set argument's default value if not provided in input
|
||||||
|
# This is done to avoid unwanted argument deprecation warning
|
||||||
|
# in case argument is not given as input (outside provider).
|
||||||
|
for key in ARGS_DEFAULT_VALUE:
|
||||||
|
if not module.params.get(key, None):
|
||||||
|
module.params[key] = ARGS_DEFAULT_VALUE[key]
|
||||||
|
|
||||||
if provider:
|
if provider:
|
||||||
for param in ('password',):
|
for param in ('password',):
|
||||||
if provider.get(param):
|
if provider.get(param):
|
||||||
|
|
|
@ -54,6 +54,11 @@ nxos_argument_spec = {
|
||||||
'transport': dict(choices=['cli', 'nxapi'])
|
'transport': dict(choices=['cli', 'nxapi'])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add argument's default value here
|
||||||
|
ARGS_DEFAULT_VALUE = {
|
||||||
|
'timeout': 10
|
||||||
|
}
|
||||||
|
|
||||||
def check_args(module, warnings):
|
def check_args(module, warnings):
|
||||||
provider = module.params['provider'] or {}
|
provider = module.params['provider'] or {}
|
||||||
for key in nxos_argument_spec:
|
for key in nxos_argument_spec:
|
||||||
|
@ -61,6 +66,13 @@ def check_args(module, warnings):
|
||||||
warnings.append('argument %s has been deprecated and will be '
|
warnings.append('argument %s has been deprecated and will be '
|
||||||
'removed in a future version' % key)
|
'removed in a future version' % key)
|
||||||
|
|
||||||
|
# set argument's default value if not provided in input
|
||||||
|
# This is done to avoid unwanted argument deprecation warning
|
||||||
|
# in case argument is not given as input (outside provider).
|
||||||
|
for key in ARGS_DEFAULT_VALUE:
|
||||||
|
if not module.params.get(key, None):
|
||||||
|
module.params[key] = ARGS_DEFAULT_VALUE[key]
|
||||||
|
|
||||||
if provider:
|
if provider:
|
||||||
for param in ('password',):
|
for param in ('password',):
|
||||||
if provider.get(param):
|
if provider.get(param):
|
||||||
|
@ -240,7 +252,7 @@ class Nxapi:
|
||||||
|
|
||||||
headers = {'Content-Type': 'application/json'}
|
headers = {'Content-Type': 'application/json'}
|
||||||
result = list()
|
result = list()
|
||||||
timeout = self._module.params['timeout'] or 10
|
timeout = self._module.params['timeout']
|
||||||
|
|
||||||
for req in requests:
|
for req in requests:
|
||||||
if self._nxapi_auth:
|
if self._nxapi_auth:
|
||||||
|
|
|
@ -375,7 +375,7 @@ def main():
|
||||||
key = 'ansible_net_%s' % key
|
key = 'ansible_net_%s' % key
|
||||||
ansible_facts[key] = value
|
ansible_facts[key] = value
|
||||||
|
|
||||||
module.exit_json(ansible_facts=ansible_facts)
|
module.exit_json(ansible_facts=ansible_facts, warnings=warnings)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in New Issue