mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-09 01:39:10 -07:00
Deprecate Entity, EntityCollection and use subspec in network modules (#33575)
* Deprecate Entity, EntityCollection and use subspec in network modules * As per proposal https://github.com/ansible/proposals/issues/76 deprecate use of Entity, EntityCollection, ComplexDict, ComplexList and use subspec instead. * Refactor ios modules * Refactor eos modules * Refactor vyos modules * Refactor nxos modules * Refactor iosxr modules * Add support for key in suboptions handling * Fix CI issues
This commit is contained in:
parent
a23da23491
commit
4349b56643
15 changed files with 195 additions and 200 deletions
|
@ -1929,14 +1929,23 @@ class AnsibleModule(object):
|
|||
|
||||
self._options_context.append(k)
|
||||
|
||||
key = None
|
||||
for (name, value) in spec.items():
|
||||
# specifies how to map a single value to spec
|
||||
if value.get('key'):
|
||||
key = name
|
||||
break
|
||||
|
||||
if isinstance(params[k], dict):
|
||||
elements = [params[k]]
|
||||
else:
|
||||
elements = params[k]
|
||||
|
||||
for param in elements:
|
||||
for index, param in enumerate(elements):
|
||||
if not isinstance(param, dict):
|
||||
self.fail_json(msg="value of %s must be of type dict or list of dict" % k)
|
||||
if key is None:
|
||||
self.fail_json(msg="options spec require a key argument to map it to a single value '%s'" % param)
|
||||
elements[index] = param = {key: param}
|
||||
|
||||
self._set_fallbacks(spec, param)
|
||||
options_aliases = self._handle_aliases(spec, param)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue