mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00: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:
@@ -140,9 +140,8 @@ from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.pycompat24 import get_exception
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.module_utils.network.common.parsing import Conditional
|
||||
from ansible.module_utils.network.common.utils import ComplexList
|
||||
from ansible.module_utils.network.eos.eos import run_commands
|
||||
from ansible.module_utils.network.eos.eos import eos_argument_spec, check_args
|
||||
from ansible.module_utils.network.eos.eos import eos_argument_spec
|
||||
|
||||
VALID_KEYS = ['command', 'output', 'prompt', 'response']
|
||||
|
||||
@@ -157,16 +156,7 @@ def to_lines(stdout):
|
||||
|
||||
|
||||
def parse_commands(module, warnings):
|
||||
spec = dict(
|
||||
command=dict(key=True),
|
||||
output=dict(),
|
||||
prompt=dict(),
|
||||
answer=dict()
|
||||
)
|
||||
|
||||
transform = ComplexList(spec, module)
|
||||
commands = transform(module.params['commands'])
|
||||
|
||||
commands = module.params['commands']
|
||||
if module.check_mode:
|
||||
for item in list(commands):
|
||||
if not item['command'].startswith('show'):
|
||||
@@ -189,8 +179,15 @@ def to_cli(obj):
|
||||
def main():
|
||||
"""entry point for module execution
|
||||
"""
|
||||
command_spec = dict(
|
||||
command=dict(key=True),
|
||||
output=dict(),
|
||||
prompt=dict(),
|
||||
answer=dict()
|
||||
)
|
||||
|
||||
argument_spec = dict(
|
||||
commands=dict(type='list', required=True),
|
||||
commands=dict(type='list', elements='dict', options=command_spec, required=True),
|
||||
|
||||
wait_for=dict(type='list', aliases=['waitfor']),
|
||||
match=dict(default='all', choices=['all', 'any']),
|
||||
@@ -207,7 +204,6 @@ def main():
|
||||
result = {'changed': False}
|
||||
|
||||
warnings = list()
|
||||
check_args(module, warnings)
|
||||
commands = parse_commands(module, warnings)
|
||||
if warnings:
|
||||
result['warnings'] = warnings
|
||||
|
||||
Reference in New Issue
Block a user