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 verbose
This commit is contained in:
Ganesh Nalawade 2017-04-18 21:59:38 +05:30 committed by GitHub
commit bf1a543f06
4 changed files with 44 additions and 6 deletions

View file

@ -40,7 +40,7 @@ _DEVICE_CONNECTION = None
eos_argument_spec = {
'host': dict(),
'port': dict(type='int', default=443),
'port': dict(type='int'),
'username': dict(fallback=(env_fallback, ['ANSIBLE_NET_USERNAME'])),
'password': dict(fallback=(env_fallback, ['ANSIBLE_NET_PASSWORD']), no_log=True),
'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'),
'auth_pass': dict(no_log=True, fallback=(env_fallback, ['ANSIBLE_NET_AUTH_PASS'])),
'use_ssl': dict(type='bool', default=True),
'validate_certs': dict(type='bool', default=True),
'use_ssl': dict(type='bool'),
'validate_certs': dict(type='bool'),
'timeout': dict(type='int'),
'provider': dict(type='dict'),
'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):
provider = module.params['provider'] or {}
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 '
'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:
for param in ('auth_pass', 'password'):
if provider.get(param):