mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 03:41:25 -07:00
IOS-XR NetConf and Cliconf plugin work (#33332)
* - Netconf plugin addition for iosxr - Utilities refactoring to support netconf and cliconf - iosx_banner refactoring for netconf and cliconf - Integration testcases changes to accomodate above changes * Fix sanity failures, shippable errors and review comments * fix pep8 issue * changes run_command method to send specific command args * - Review comment fixes - iosxr_command changes to remove ComplexDict based command_spec * - Move namespaces removal method from utils to netconf plugin * Minor refactoring in utils and change in deprecation message * rewrite build_xml logic and import changes for new utils dir structure * - Review comment changes and minor changes to documentation * * refactor common code and docs updates
This commit is contained in:
parent
4b6061ce3e
commit
2bc4c4f156
42 changed files with 1090 additions and 247 deletions
|
@ -94,6 +94,7 @@ tasks:
|
|||
commands:
|
||||
- show version
|
||||
- show interfaces
|
||||
- [{ command: example command that prompts, prompt: expected prompt, answer: yes}]
|
||||
|
||||
- name: run multiple commands and evaluate the output
|
||||
iosxr_command:
|
||||
|
@ -125,9 +126,9 @@ failed_conditions:
|
|||
import time
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.iosxr.iosxr import run_commands, iosxr_argument_spec, check_args
|
||||
from ansible.module_utils.network.iosxr.iosxr import run_command, iosxr_argument_spec
|
||||
from ansible.module_utils.network.iosxr.iosxr import command_spec
|
||||
from ansible.module_utils.network.common.parsing import Conditional
|
||||
from ansible.module_utils.network.common.utils import ComplexList
|
||||
from ansible.module_utils.six import string_types
|
||||
from ansible.module_utils._text import to_native
|
||||
|
||||
|
@ -140,27 +141,27 @@ def to_lines(stdout):
|
|||
|
||||
|
||||
def parse_commands(module, warnings):
|
||||
command = ComplexList(dict(
|
||||
command=dict(key=True),
|
||||
prompt=dict(),
|
||||
answer=dict()
|
||||
), module)
|
||||
commands = command(module.params['commands'])
|
||||
|
||||
commands = module.params['commands']
|
||||
for item in list(commands):
|
||||
if module.check_mode and not item['command'].startswith('show'):
|
||||
try:
|
||||
command = item['command']
|
||||
except Exception:
|
||||
command = item
|
||||
if module.check_mode and not command.startswith('show'):
|
||||
warnings.append(
|
||||
'only show commands are supported when using check mode, not '
|
||||
'executing `%s`' % item['command']
|
||||
'executing `%s`' % command
|
||||
)
|
||||
commands.remove(item)
|
||||
elif item['command'].startswith('conf'):
|
||||
elif command.startswith('conf'):
|
||||
module.fail_json(
|
||||
msg='iosxr_command does not support running config mode '
|
||||
'commands. Please use iosxr_config instead'
|
||||
)
|
||||
|
||||
return commands
|
||||
|
||||
|
||||
def main():
|
||||
spec = dict(
|
||||
commands=dict(type='list', required=True),
|
||||
|
@ -174,11 +175,12 @@ def main():
|
|||
|
||||
spec.update(iosxr_argument_spec)
|
||||
|
||||
spec.update(command_spec)
|
||||
|
||||
module = AnsibleModule(argument_spec=spec,
|
||||
supports_check_mode=True)
|
||||
|
||||
warnings = list()
|
||||
check_args(module, warnings)
|
||||
|
||||
commands = parse_commands(module, warnings)
|
||||
|
||||
|
@ -190,7 +192,7 @@ def main():
|
|||
match = module.params['match']
|
||||
|
||||
while retries > 0:
|
||||
responses = run_commands(module, commands)
|
||||
responses = run_command(module, commands)
|
||||
|
||||
for item in list(conditionals):
|
||||
if item(responses):
|
||||
|
@ -210,7 +212,6 @@ def main():
|
|||
msg = 'One or more conditional statements have not be satisfied'
|
||||
module.fail_json(msg=msg, failed_conditions=failed_conditions)
|
||||
|
||||
|
||||
result = {
|
||||
'changed': False,
|
||||
'stdout': responses,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue