mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-24 03:11:24 -07:00
network command modules cleanup (#45242)
* Standardize _command modules * Centralize command transformation process * Fix check mode error test
This commit is contained in:
parent
df768914a1
commit
285b927889
11 changed files with 115 additions and 204 deletions
|
@ -34,6 +34,7 @@ from itertools import chain
|
|||
from struct import pack
|
||||
from socket import inet_aton, inet_ntoa
|
||||
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.module_utils.six import iteritems, string_types
|
||||
from ansible.module_utils.six.moves import zip
|
||||
from ansible.module_utils.basic import AnsibleFallbackNotFound
|
||||
|
@ -60,6 +61,26 @@ def to_list(val):
|
|||
return list()
|
||||
|
||||
|
||||
def to_lines(stdout):
|
||||
for item in stdout:
|
||||
if isinstance(item, string_types):
|
||||
item = to_text(item).split('\n')
|
||||
yield item
|
||||
|
||||
|
||||
def transform_commands(module):
|
||||
transform = ComplexList(dict(
|
||||
command=dict(key=True),
|
||||
output=dict(),
|
||||
prompt=dict(type='list'),
|
||||
answer=dict(type='list'),
|
||||
sendonly=dict(type='bool', default=False),
|
||||
check_all=dict(type='bool', default=False),
|
||||
), module)
|
||||
|
||||
return transform(module.params['commands'])
|
||||
|
||||
|
||||
def sort_list(val):
|
||||
if isinstance(val, list):
|
||||
return sorted(val)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue