mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Fix unwanted deprecation message in network module args (#28984)
* Fix unwanted deprecation message in network module argspec Fixes #25663 Fixes #24537 * segregate provider spec and top level arg spec * add deprecation key in top level arg spec * remove action plugin code to load provider and add that logic at a common place in network_common.py file * Fix CI issue * Minor change
This commit is contained in:
committed by
Ricardo Carrillo Cruz
parent
d52316fcc2
commit
599fe23ed6
@@ -43,10 +43,16 @@ aireos_provider_spec = {
|
||||
aireos_argument_spec = {
|
||||
'provider': dict(type='dict', options=aireos_provider_spec)
|
||||
}
|
||||
aireos_argument_spec.update(aireos_provider_spec)
|
||||
|
||||
# Add argument's default value here
|
||||
ARGS_DEFAULT_VALUE = {}
|
||||
aireos_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
}
|
||||
aireos_argument_spec.update(aireos_top_spec)
|
||||
|
||||
|
||||
def sanitize(resp):
|
||||
@@ -59,21 +65,12 @@ def sanitize(resp):
|
||||
return '\n'.join(cleaned).strip()
|
||||
|
||||
|
||||
def get_argspec():
|
||||
return aireos_argument_spec
|
||||
def get_provider_argspec():
|
||||
return aireos_provider_spec
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in aireos_argument_spec:
|
||||
if key not in ['provider', 'authorize'] and module.params[key]:
|
||||
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]
|
||||
pass
|
||||
|
||||
|
||||
def get_config(module, flags=None):
|
||||
|
||||
@@ -43,27 +43,25 @@ aruba_provider_spec = {
|
||||
aruba_argument_spec = {
|
||||
'provider': dict(type='dict', options=aruba_provider_spec)
|
||||
}
|
||||
aruba_argument_spec.update(aruba_provider_spec)
|
||||
|
||||
# Add argument's default value here
|
||||
ARGS_DEFAULT_VALUE = {}
|
||||
aruba_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
}
|
||||
|
||||
aruba_argument_spec.update(aruba_top_spec)
|
||||
|
||||
|
||||
def get_argspec():
|
||||
return aruba_argument_spec
|
||||
def get_provider_argspec():
|
||||
return aruba_provider_spec
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in aruba_argument_spec:
|
||||
if key not in ['provider', 'authorize'] and module.params[key]:
|
||||
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]
|
||||
pass
|
||||
|
||||
|
||||
def get_config(module, flags=None):
|
||||
|
||||
@@ -33,7 +33,7 @@ from ansible.module_utils.connection import Connection, exec_command
|
||||
_DEVICE_CONFIGS = {}
|
||||
_CONNECTION = None
|
||||
|
||||
asa_argument_spec = {
|
||||
asa_provider_spec = {
|
||||
'host': dict(),
|
||||
'port': dict(type='int'),
|
||||
'username': dict(fallback=(env_fallback, ['ANSIBLE_NET_USERNAME'])),
|
||||
@@ -42,11 +42,28 @@ asa_argument_spec = {
|
||||
'authorize': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTHORIZE']), type='bool'),
|
||||
'auth_pass': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTH_PASS']), no_log=True),
|
||||
'timeout': dict(type='int'),
|
||||
'provider': dict(type='dict'),
|
||||
'context': dict(),
|
||||
'passwords': dict()
|
||||
}
|
||||
|
||||
asa_argument_spec = {
|
||||
'provider': dict(type='dict', options=asa_provider_spec),
|
||||
}
|
||||
|
||||
asa_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
'authorize': dict(type='bool'),
|
||||
'auth_pass': dict(removed_in_version=2.3, no_log=True),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
'context': dict(),
|
||||
'passwords': dict()
|
||||
}
|
||||
asa_argument_spec.update(asa_top_spec)
|
||||
|
||||
command_spec = {
|
||||
'command': dict(key=True),
|
||||
'prompt': dict(),
|
||||
@@ -54,21 +71,12 @@ command_spec = {
|
||||
}
|
||||
|
||||
|
||||
def get_argspec():
|
||||
return asa_argument_spec
|
||||
def get_provider_argspec():
|
||||
return asa_provider_spec
|
||||
|
||||
|
||||
def check_args(module):
|
||||
provider = module.params['provider'] or {}
|
||||
|
||||
for key in asa_argument_spec:
|
||||
if key not in ['provider', 'authorize'] and module.params[key]:
|
||||
module.warn('argument %s has been deprecated and will be removed in a future version' % key)
|
||||
|
||||
if provider:
|
||||
for param in ('auth_pass', 'password'):
|
||||
if provider.get(param):
|
||||
module.no_log_values.update(return_values(provider[param]))
|
||||
pass
|
||||
|
||||
|
||||
def get_connection(module):
|
||||
|
||||
@@ -66,14 +66,21 @@ ce_provider_spec = {
|
||||
ce_argument_spec = {
|
||||
'provider': dict(type='dict', options=ce_provider_spec),
|
||||
}
|
||||
ce_argument_spec.update(ce_provider_spec)
|
||||
ce_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'use_ssl': dict(removed_in_version=2.3, type='bool'),
|
||||
'validate_certs': dict(removed_in_version=2.3, type='bool'),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
'transport': dict(choices=['cli']),
|
||||
}
|
||||
ce_argument_spec.update(ce_top_spec)
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in ce_argument_spec:
|
||||
if key not in ['provider', 'transport'] and module.params[key]:
|
||||
warnings.append('argument %s has been deprecated and will be '
|
||||
'removed in a future version' % key)
|
||||
pass
|
||||
|
||||
|
||||
def load_params(module):
|
||||
|
||||
@@ -58,14 +58,21 @@ dellos10_provider_spec = {
|
||||
dellos10_argument_spec = {
|
||||
'provider': dict(type='dict', options=dellos10_provider_spec),
|
||||
}
|
||||
dellos10_argument_spec.update(dellos10_provider_spec)
|
||||
dellos10_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
'authorize': dict(removed_in_version=2.3, type='bool'),
|
||||
'auth_pass': dict(removed_in_version=2.3, no_log=True),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
}
|
||||
dellos10_argument_spec.update(dellos10_top_spec)
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in dellos10_argument_spec:
|
||||
if key != 'provider' and module.params[key]:
|
||||
warnings.append('argument %s has been deprecated and will be '
|
||||
'removed in a future version' % key)
|
||||
pass
|
||||
|
||||
|
||||
def get_config(module, flags=None):
|
||||
|
||||
@@ -57,14 +57,21 @@ dellos6_provider_spec = {
|
||||
dellos6_argument_spec = {
|
||||
'provider': dict(type='dict', options=dellos6_provider_spec),
|
||||
}
|
||||
dellos6_argument_spec.update(dellos6_provider_spec)
|
||||
dellos6_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
'authorize': dict(removed_in_version=2.3, type='bool'),
|
||||
'auth_pass': dict(removed_in_version=2.3, no_log=True),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
}
|
||||
dellos6_argument_spec.update(dellos6_top_spec)
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in dellos6_argument_spec:
|
||||
if key != 'provider' and module.params[key]:
|
||||
warnings.append('argument %s has been deprecated and will be '
|
||||
'removed in a future version' % key)
|
||||
pass
|
||||
|
||||
|
||||
def get_config(module, flags=None):
|
||||
|
||||
@@ -58,14 +58,21 @@ dellos9_provider_spec = {
|
||||
dellos9_argument_spec = {
|
||||
'provider': dict(type='dict', options=dellos9_provider_spec),
|
||||
}
|
||||
dellos9_argument_spec.update(dellos9_provider_spec)
|
||||
dellos9_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
'authorize': dict(removed_in_version=2.3, type='bool'),
|
||||
'auth_pass': dict(removed_in_version=2.3, no_log=True),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
}
|
||||
dellos9_argument_spec.update(dellos9_top_spec)
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in dellos9_argument_spec:
|
||||
if key != 'provider' and module.params[key]:
|
||||
warnings.append('argument %s has been deprecated and will be '
|
||||
'removed in a future version' % key)
|
||||
pass
|
||||
|
||||
|
||||
def get_config(module, flags=None):
|
||||
|
||||
@@ -49,23 +49,32 @@ eos_provider_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'),
|
||||
'validate_certs': dict(type='bool'),
|
||||
'use_ssl': dict(default=True, type='bool'),
|
||||
'validate_certs': dict(default=True, type='bool'),
|
||||
'timeout': dict(type='int'),
|
||||
|
||||
'transport': dict(choices=['cli', 'eapi'])
|
||||
'transport': dict(default='cli', choices=['cli', 'eapi'])
|
||||
}
|
||||
eos_argument_spec = {
|
||||
'provider': dict(type='dict', options=eos_provider_spec),
|
||||
}
|
||||
eos_argument_spec.update(eos_provider_spec)
|
||||
eos_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
|
||||
# Add argument's default value here
|
||||
ARGS_DEFAULT_VALUE = {
|
||||
'transport': 'cli',
|
||||
'use_ssl': True,
|
||||
'validate_certs': True
|
||||
'authorize': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTHORIZE']), type='bool'),
|
||||
'auth_pass': dict(no_log=True, removed_in_version=2.3),
|
||||
|
||||
'use_ssl': dict(removed_in_version=2.3, type='bool'),
|
||||
'validate_certs': dict(removed_in_version=2.3, type='bool'),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
|
||||
'transport': dict(removed_in_version=2.3, choices=['cli', 'eapi'])
|
||||
}
|
||||
eos_argument_spec.update(eos_top_spec)
|
||||
|
||||
|
||||
def get_argspec():
|
||||
@@ -73,21 +82,7 @@ def get_argspec():
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in eos_argument_spec:
|
||||
if module._name == 'eos_user':
|
||||
if (key not in ['username', 'password', 'provider', 'transport', 'authorize'] and
|
||||
module.params[key]):
|
||||
warnings.append('argument %s has been deprecated and will be removed in a future version' % key)
|
||||
else:
|
||||
if key not in ['provider', 'authorize'] and module.params[key]:
|
||||
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]
|
||||
pass
|
||||
|
||||
|
||||
def load_params(module):
|
||||
|
||||
@@ -40,26 +40,31 @@ ios_provider_spec = {
|
||||
'ssh_keyfile': dict(fallback=(env_fallback, ['ANSIBLE_NET_SSH_KEYFILE']), type='path'),
|
||||
'authorize': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTHORIZE']), type='bool'),
|
||||
'auth_pass': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTH_PASS']), no_log=True),
|
||||
'timeout': dict(type='int'),
|
||||
'timeout': dict(type='int')
|
||||
}
|
||||
ios_argument_spec = {
|
||||
'provider': dict(type='dict', options=ios_provider_spec),
|
||||
}
|
||||
ios_argument_spec.update(ios_provider_spec)
|
||||
|
||||
ios_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
'authorize': dict(fallback=(env_fallback, ['ANSIBLE_NET_AUTHORIZE']), type='bool'),
|
||||
'auth_pass': dict(removed_in_version=2.3, no_log=True),
|
||||
'timeout': dict(removed_in_version=2.3, type='int')
|
||||
}
|
||||
ios_argument_spec.update(ios_top_spec)
|
||||
|
||||
|
||||
def get_argspec():
|
||||
return ios_argument_spec
|
||||
def get_provider_argspec():
|
||||
return ios_provider_spec
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in ios_argument_spec:
|
||||
if module._name == 'ios_user':
|
||||
if key not in ['password', 'provider', 'authorize'] and module.params[key]:
|
||||
warnings.append('argument %s has been deprecated and will be in a future version' % key)
|
||||
else:
|
||||
if key not in ['provider', 'authorize'] and module.params[key]:
|
||||
warnings.append('argument %s has been deprecated and will be removed in a future version' % key)
|
||||
pass
|
||||
|
||||
|
||||
def get_defaults_flag(module):
|
||||
|
||||
@@ -44,21 +44,23 @@ iosxr_provider_spec = {
|
||||
iosxr_argument_spec = {
|
||||
'provider': dict(type='dict', options=iosxr_provider_spec)
|
||||
}
|
||||
iosxr_argument_spec.update(iosxr_provider_spec)
|
||||
iosxr_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
}
|
||||
iosxr_argument_spec.update(iosxr_top_spec)
|
||||
|
||||
|
||||
def get_argspec():
|
||||
return iosxr_argument_spec
|
||||
def get_provider_argspec():
|
||||
return iosxr_provider_spec
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in iosxr_argument_spec:
|
||||
if module._name == 'iosxr_user':
|
||||
if key not in ['password', 'provider'] and module.params[key]:
|
||||
warnings.append('argument %s has been deprecated and will be in a future version' % key)
|
||||
else:
|
||||
if key != 'provider' and module.params[key]:
|
||||
warnings.append('argument %s has been deprecated and will be removed in a future version' % key)
|
||||
pass
|
||||
|
||||
|
||||
def get_config(module, flags=None):
|
||||
|
||||
@@ -50,28 +50,24 @@ junos_provider_spec = {
|
||||
junos_argument_spec = {
|
||||
'provider': dict(type='dict', options=junos_provider_spec),
|
||||
}
|
||||
junos_argument_spec.update(junos_provider_spec)
|
||||
|
||||
# Add argument's default value here
|
||||
ARGS_DEFAULT_VALUE = {}
|
||||
junos_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
'transport': dict(removed_in_version=2.3)
|
||||
}
|
||||
junos_argument_spec.update(junos_top_spec)
|
||||
|
||||
|
||||
def get_argspec():
|
||||
return junos_argument_spec
|
||||
def get_provider_argspec():
|
||||
return junos_provider_spec
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in junos_argument_spec:
|
||||
if key not in ('provider',) and module.params[key]:
|
||||
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]
|
||||
pass
|
||||
|
||||
|
||||
def _validate_rollback_id(module, value):
|
||||
|
||||
@@ -337,6 +337,38 @@ def remove_default_spec(spec):
|
||||
del spec[item]['default']
|
||||
|
||||
|
||||
def load_provider(spec, args):
|
||||
provider = args.get('provider', {})
|
||||
for key, value in iteritems(spec):
|
||||
if key not in provider:
|
||||
if key in args:
|
||||
provider[key] = args[key]
|
||||
elif 'fallback' in value:
|
||||
provider[key] = _fallback(value['fallback'])
|
||||
elif 'default' in value:
|
||||
provider[key] = value['default']
|
||||
else:
|
||||
provider[key] = None
|
||||
args['provider'] = provider
|
||||
return provider
|
||||
|
||||
|
||||
def _fallback(fallback):
|
||||
strategy = fallback[0]
|
||||
args = []
|
||||
kwargs = {}
|
||||
|
||||
for item in fallback[1:]:
|
||||
if isinstance(item, dict):
|
||||
kwargs = item
|
||||
else:
|
||||
args = item
|
||||
try:
|
||||
return strategy(*args, **kwargs)
|
||||
except AnsibleFallbackNotFound:
|
||||
pass
|
||||
|
||||
|
||||
class Template:
|
||||
|
||||
def __init__(self):
|
||||
|
||||
@@ -51,38 +51,34 @@ nxos_provider_spec = {
|
||||
'validate_certs': dict(type='bool'),
|
||||
'timeout': dict(type='int'),
|
||||
|
||||
'transport': dict(choices=['cli', 'nxapi'])
|
||||
'transport': dict(default='cli', choices=['cli', 'nxapi'])
|
||||
}
|
||||
nxos_argument_spec = {
|
||||
'provider': dict(type='dict', options=nxos_provider_spec),
|
||||
}
|
||||
nxos_argument_spec.update(nxos_provider_spec)
|
||||
nxos_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
|
||||
# Add argument's default value here
|
||||
ARGS_DEFAULT_VALUE = {
|
||||
'transport': 'cli'
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3),
|
||||
|
||||
'use_ssl': dict(removed_in_version=2.3, type='bool'),
|
||||
'validate_certs': dict(removed_in_version=2.3, type='bool'),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
|
||||
'transport': dict(default='cli', choices=['cli', 'nxapi'])
|
||||
}
|
||||
nxos_argument_spec.update(nxos_top_spec)
|
||||
|
||||
|
||||
def get_argspec():
|
||||
return nxos_argument_spec
|
||||
def get_provider_argspec():
|
||||
return nxos_provider_spec
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in nxos_argument_spec:
|
||||
if module._name == 'nxos_user':
|
||||
if key not in ['password', 'provider', 'transport'] and module.params[key]:
|
||||
warnings.append('argument %s has been deprecated and will be in a future version' % key)
|
||||
else:
|
||||
if key not in ['provider', 'transport'] and module.params[key]:
|
||||
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]
|
||||
pass
|
||||
|
||||
|
||||
def load_params(module):
|
||||
|
||||
@@ -49,13 +49,19 @@ sros_provider_spec = {
|
||||
sros_argument_spec = {
|
||||
'provider': dict(type='dict', options=sros_provider_spec),
|
||||
}
|
||||
sros_argument_spec.update(sros_provider_spec)
|
||||
sros_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
}
|
||||
sros_argument_spec.update(sros_top_spec)
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
for key in sros_argument_spec:
|
||||
if key != 'provider' and module.params[key]:
|
||||
warnings.append('argument %s has been deprecated and will be removed in a future version' % key)
|
||||
pass
|
||||
|
||||
|
||||
def get_config(module, flags=None):
|
||||
|
||||
@@ -45,11 +45,21 @@ vyos_provider_spec = {
|
||||
vyos_argument_spec = {
|
||||
'provider': dict(type='dict', options=vyos_provider_spec),
|
||||
}
|
||||
vyos_argument_spec.update(vyos_provider_spec)
|
||||
vyos_top_spec = {
|
||||
'host': dict(removed_in_version=2.3),
|
||||
'port': dict(removed_in_version=2.3, type='int'),
|
||||
|
||||
'username': dict(removed_in_version=2.3),
|
||||
'password': dict(removed_in_version=2.3, no_log=True),
|
||||
'ssh_keyfile': dict(removed_in_version=2.3, type='path'),
|
||||
|
||||
'timeout': dict(removed_in_version=2.3, type='int'),
|
||||
}
|
||||
vyos_argument_spec.update(vyos_top_spec)
|
||||
|
||||
|
||||
def get_argspec():
|
||||
return vyos_argument_spec
|
||||
def get_provider_argspec():
|
||||
return vyos_provider_spec
|
||||
|
||||
|
||||
def check_args(module, warnings):
|
||||
|
||||
Reference in New Issue
Block a user