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
|
@ -108,18 +108,21 @@ import re
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.network.iosxr.iosxr import get_config, load_config
|
||||
from ansible.module_utils.network.iosxr.iosxr import iosxr_argument_spec, check_args
|
||||
from ansible.module_utils.network.iosxr.iosxr import iosxr_argument_spec
|
||||
|
||||
|
||||
def diff_list(want, have):
|
||||
adds = set(want).difference(have)
|
||||
removes = set(have).difference(want)
|
||||
return (adds, removes)
|
||||
|
||||
|
||||
def map_obj_to_commands(want, have, module):
|
||||
commands = list()
|
||||
state = module.params['state']
|
||||
|
||||
needs_update = lambda x: want.get(x) and (want.get(x) != have.get(x))
|
||||
def needs_update(x):
|
||||
return want.get(x) and (want.get(x) != have.get(x))
|
||||
|
||||
if state == 'absent':
|
||||
if have['hostname'] != 'ios':
|
||||
|
@ -167,20 +170,24 @@ def map_obj_to_commands(want, have, module):
|
|||
|
||||
return commands
|
||||
|
||||
|
||||
def parse_hostname(config):
|
||||
match = re.search(r'^hostname (\S+)', config, re.M)
|
||||
return match.group(1)
|
||||
|
||||
|
||||
def parse_domain_name(config):
|
||||
match = re.search(r'^domain name (\S+)', config, re.M)
|
||||
if match:
|
||||
return match.group(1)
|
||||
|
||||
|
||||
def parse_lookup_source(config):
|
||||
match = re.search(r'^domain lookup source-interface (\S+)', config, re.M)
|
||||
if match:
|
||||
return match.group(1)
|
||||
|
||||
|
||||
def map_config_to_obj(module):
|
||||
config = get_config(module)
|
||||
return {
|
||||
|
@ -192,6 +199,7 @@ def map_config_to_obj(module):
|
|||
'name_servers': re.findall(r'^domain name-server (\S+)', config, re.M)
|
||||
}
|
||||
|
||||
|
||||
def map_params_to_obj(module):
|
||||
return {
|
||||
'hostname': module.params['hostname'],
|
||||
|
@ -202,6 +210,7 @@ def map_params_to_obj(module):
|
|||
'name_servers': module.params['name_servers']
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
""" Main entry point for Ansible module execution
|
||||
"""
|
||||
|
@ -223,7 +232,6 @@ def main():
|
|||
supports_check_mode=True)
|
||||
|
||||
warnings = list()
|
||||
check_args(module, warnings)
|
||||
|
||||
result = {'changed': False, 'warnings': warnings}
|
||||
|
||||
|
@ -240,5 +248,6 @@ def main():
|
|||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue