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:
Ganesh Nalawade 2017-09-12 16:30:01 +05:30 committed by Ricardo Carrillo Cruz
parent d52316fcc2
commit 599fe23ed6
30 changed files with 283 additions and 634 deletions

View file

@ -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):