mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 14:22:46 +00:00
This reverts commit 4349b56643.
This commit is contained in:
@@ -147,7 +147,8 @@ import time
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.common.parsing import Conditional, FailedConditionalError
|
||||
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, run_commands
|
||||
from ansible.module_utils.network.common.utils import ComplexList
|
||||
from ansible.module_utils.network.nxos.nxos import check_args, nxos_argument_spec, run_commands
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
@@ -162,7 +163,14 @@ def to_lines(stdout):
|
||||
|
||||
|
||||
def parse_commands(module, warnings):
|
||||
commands = module.params['commands']
|
||||
transform = ComplexList(dict(
|
||||
command=dict(key=True),
|
||||
output=dict(),
|
||||
prompt=dict(),
|
||||
answer=dict()
|
||||
), module)
|
||||
|
||||
commands = transform(module.params['commands'])
|
||||
|
||||
if module.check_mode:
|
||||
for item in list(commands):
|
||||
@@ -186,16 +194,9 @@ 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(
|
||||
# { command: <str>, output: <str>, prompt: <str>, response: <str> }
|
||||
commands=dict(type='list', elements='dict', options=command_spec, required=True),
|
||||
commands=dict(type='list', required=True),
|
||||
|
||||
wait_for=dict(type='list', aliases=['waitfor']),
|
||||
match=dict(default='all', choices=['any', 'all']),
|
||||
@@ -212,6 +213,7 @@ def main():
|
||||
result = {'changed': False}
|
||||
|
||||
warnings = list()
|
||||
check_args(module, warnings)
|
||||
commands = parse_commands(module, warnings)
|
||||
result['warnings'] = warnings
|
||||
|
||||
|
||||
@@ -112,10 +112,11 @@ commands:
|
||||
import re
|
||||
|
||||
from ansible.module_utils.network.nxos.nxos import get_config, load_config
|
||||
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec
|
||||
from ansible.module_utils.network.nxos.nxos import nxos_argument_spec, check_args
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.six import iteritems
|
||||
from ansible.module_utils.network.common.config import NetworkConfig
|
||||
from ansible.module_utils.network.common.utils import ComplexList
|
||||
|
||||
_CONFIGURED_VRFS = None
|
||||
|
||||
@@ -301,45 +302,49 @@ def map_params_to_obj(module):
|
||||
obj = {
|
||||
'hostname': module.params['hostname'],
|
||||
'domain_lookup': module.params['domain_lookup'],
|
||||
'system_mtu': module.params['system_mtu'],
|
||||
'domain_name': module.params['domain_name'],
|
||||
'domain_search': module.params['domain_search'],
|
||||
'name_servers': module.params['name_servers']
|
||||
'system_mtu': module.params['system_mtu']
|
||||
}
|
||||
|
||||
domain_name = ComplexList(dict(
|
||||
name=dict(key=True),
|
||||
vrf=dict()
|
||||
), module)
|
||||
|
||||
domain_search = ComplexList(dict(
|
||||
name=dict(key=True),
|
||||
vrf=dict()
|
||||
), module)
|
||||
|
||||
name_servers = ComplexList(dict(
|
||||
server=dict(key=True),
|
||||
vrf=dict()
|
||||
), module)
|
||||
|
||||
for arg, cast in [('domain_name', domain_name), ('domain_search', domain_search),
|
||||
('name_servers', name_servers)]:
|
||||
if module.params[arg] is not None:
|
||||
obj[arg] = cast(module.params[arg])
|
||||
else:
|
||||
obj[arg] = None
|
||||
|
||||
return obj
|
||||
|
||||
|
||||
def main():
|
||||
""" main entry point for module execution
|
||||
"""
|
||||
domain_name_spec = dict(
|
||||
name=dict(key=True),
|
||||
vrf=dict()
|
||||
)
|
||||
|
||||
domain_search_spec = dict(
|
||||
name=dict(key=True),
|
||||
vrf=dict()
|
||||
)
|
||||
|
||||
name_servers_spec = dict(
|
||||
server=dict(key=True),
|
||||
vrf=dict()
|
||||
)
|
||||
|
||||
argument_spec = dict(
|
||||
hostname=dict(),
|
||||
domain_lookup=dict(type='bool'),
|
||||
|
||||
# { name: <str>, vrf: <str> }
|
||||
domain_name=dict(type='list', elements='dict', options=domain_name_spec),
|
||||
domain_name=dict(type='list'),
|
||||
|
||||
# {name: <str>, vrf: <str> }
|
||||
domain_search=dict(type='list', elements='dict', options=domain_search_spec),
|
||||
domain_search=dict(type='list'),
|
||||
|
||||
# { server: <str>; vrf: <str> }
|
||||
name_servers=dict(type='list', elements='dict', options=name_servers_spec),
|
||||
name_servers=dict(type='list'),
|
||||
|
||||
system_mtu=dict(type='int'),
|
||||
lookup_source=dict(),
|
||||
@@ -352,6 +357,7 @@ def main():
|
||||
supports_check_mode=True)
|
||||
|
||||
warnings = list()
|
||||
check_args(module, warnings)
|
||||
|
||||
result = {'changed': False}
|
||||
if warnings:
|
||||
@@ -370,6 +376,5 @@ def main():
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user