mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -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
|
@ -38,7 +38,7 @@ options:
|
|||
description:
|
||||
- netconf vrf name
|
||||
required: false
|
||||
default: none
|
||||
default: default
|
||||
state:
|
||||
description:
|
||||
- Specifies the state of the C(iosxr_netconf) resource on
|
||||
|
@ -75,7 +75,7 @@ import re
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.connection import exec_command
|
||||
from ansible.module_utils.network.iosxr.iosxr import iosxr_argument_spec, check_args
|
||||
from ansible.module_utils.network.iosxr.iosxr import iosxr_argument_spec
|
||||
from ansible.module_utils.network.iosxr.iosxr import get_config, load_config
|
||||
from ansible.module_utils.six import iteritems
|
||||
|
||||
|
@ -90,16 +90,12 @@ def map_obj_to_commands(updates, module):
|
|||
if have['state'] == 'present':
|
||||
commands.append('no netconf-yang agent ssh')
|
||||
|
||||
if 'netconf_port' in have:
|
||||
commands.append('no ssh server netconf port %s' % have['netconf_port'])
|
||||
if 'netconf_port' in have:
|
||||
commands.append('no ssh server netconf port %s' % have['netconf_port'])
|
||||
|
||||
if want['netconf_vrf']:
|
||||
for vrf in have['netconf_vrf']:
|
||||
if vrf == want['netconf_vrf']:
|
||||
commands.append('no ssh server netconf vrf %s' % vrf)
|
||||
else:
|
||||
for vrf in have['netconf_vrf']:
|
||||
commands.append('no ssh server netconf vrf %s' % vrf)
|
||||
if have['netconf_vrf']:
|
||||
for vrf in have['netconf_vrf']:
|
||||
commands.append('no ssh server netconf vrf %s' % vrf)
|
||||
else:
|
||||
if have['state'] == 'absent':
|
||||
commands.append('netconf-yang agent ssh')
|
||||
|
@ -131,9 +127,9 @@ def parse_port(config):
|
|||
def map_config_to_obj(module):
|
||||
obj = {'state': 'absent'}
|
||||
|
||||
netconf_config = get_config(module, flags=['netconf-yang agent'])
|
||||
netconf_config = get_config(module, config_filter='netconf-yang agent')
|
||||
|
||||
ssh_config = get_config(module, flags=['ssh server'])
|
||||
ssh_config = get_config(module, config_filter='ssh server')
|
||||
ssh_config = [config_line for config_line in (line.strip() for line in ssh_config.splitlines()) if config_line]
|
||||
obj['netconf_vrf'] = []
|
||||
for config in ssh_config:
|
||||
|
@ -141,7 +137,7 @@ def map_config_to_obj(module):
|
|||
obj.update({'netconf_port': parse_port(config)})
|
||||
if 'netconf vrf' in config:
|
||||
obj['netconf_vrf'].append(parse_vrf(config))
|
||||
if 'ssh' in netconf_config or 'netconf_port' in obj or obj['netconf_vrf']:
|
||||
if 'ssh' in netconf_config and ('netconf_port' in obj or obj['netconf_vrf']):
|
||||
obj.update({'state': 'present'})
|
||||
|
||||
if 'ssh' in netconf_config and 'netconf_port' not in obj:
|
||||
|
@ -176,7 +172,7 @@ def main():
|
|||
"""
|
||||
argument_spec = dict(
|
||||
netconf_port=dict(type='int', default=830, aliases=['listens_on']),
|
||||
netconf_vrf=dict(aliases=['vrf']),
|
||||
netconf_vrf=dict(aliases=['vrf'], default='default'),
|
||||
state=dict(default='present', choices=['present', 'absent']),
|
||||
)
|
||||
argument_spec.update(iosxr_argument_spec)
|
||||
|
@ -185,7 +181,6 @@ def main():
|
|||
supports_check_mode=True)
|
||||
|
||||
warnings = list()
|
||||
check_args(module, warnings)
|
||||
|
||||
result = {'changed': False, 'warnings': warnings}
|
||||
|
||||
|
@ -197,10 +192,6 @@ def main():
|
|||
if commands:
|
||||
if not module.check_mode:
|
||||
diff = load_config(module, commands, result['warnings'], commit=True)
|
||||
if diff:
|
||||
if module._diff:
|
||||
result['diff'] = {'prepared': diff}
|
||||
exec_command(module, 'exit')
|
||||
result['changed'] = True
|
||||
|
||||
module.exit_json(**result)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue