mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-25 06:10:22 -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
|
@ -27,8 +27,9 @@
|
|||
#
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.module_utils.basic import env_fallback, return_values
|
||||
from ansible.module_utils.network.common.utils import to_list, ComplexList
|
||||
from ansible.module_utils.connection import exec_command
|
||||
from ansible.module_utils.network.common.utils import to_list
|
||||
from ansible.module_utils.six import string_types
|
||||
|
||||
_DEVICE_CONFIGS = {}
|
||||
|
||||
|
@ -100,20 +101,12 @@ def get_config(module, flags=None):
|
|||
return cfg
|
||||
|
||||
|
||||
def to_commands(module, commands):
|
||||
spec = {
|
||||
'command': dict(key=True),
|
||||
'prompt': dict(),
|
||||
'answer': dict()
|
||||
}
|
||||
transform = ComplexList(spec, module)
|
||||
return transform(commands)
|
||||
|
||||
|
||||
def run_commands(module, commands, check_rc=True):
|
||||
responses = list()
|
||||
commands = to_commands(module, to_list(commands))
|
||||
for cmd in commands:
|
||||
for cmd in to_list(commands):
|
||||
if isinstance(cmd, string_types):
|
||||
cmd = {'command': cmd}
|
||||
|
||||
cmd = module.jsonify(cmd)
|
||||
rc, out, err = exec_command(module, cmd)
|
||||
if check_rc and rc != 0:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue