mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
junos_linkagg implementation and junos modules refactor (#26587)
* junos_linkagg implementation and junos modules refactor * junos_linkagg implementation * junos_linkagg integration test * net_linkagg integration test for junos * decouple `load_config` and `commit` operations, to allow single commit (in case on confirm commit) and to perform batch commit (multiple `load_config` followed by single `commit`) * Other related refactor * Fix CI issues * Fix unit test failure
This commit is contained in:
parent
82558baaf6
commit
be89ef3eb6
30 changed files with 1140 additions and 220 deletions
|
@ -129,9 +129,9 @@ EXAMPLES = """
|
|||
"""
|
||||
|
||||
RETURN = """
|
||||
diff:
|
||||
diff.prepared:
|
||||
description: Configuration difference before and after applying change.
|
||||
returned: when configuration is changed.
|
||||
returned: when configuration is changed and diff option is enabled.
|
||||
type: string
|
||||
sample: >
|
||||
[edit interfaces]
|
||||
|
@ -141,9 +141,10 @@ diff:
|
|||
"""
|
||||
import collections
|
||||
|
||||
from ansible.module_utils.junos import junos_argument_spec, check_args
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.junos import junos_argument_spec, check_args
|
||||
from ansible.module_utils.junos import load_config, map_params_to_obj, map_obj_to_ele
|
||||
from ansible.module_utils.junos import commit_configuration, discard_changes, locked_config
|
||||
|
||||
try:
|
||||
from lxml.etree import tostring
|
||||
|
@ -225,21 +226,22 @@ def main():
|
|||
|
||||
validate_param_values(module, param_to_xpath_map)
|
||||
|
||||
want = list()
|
||||
want.append(map_params_to_obj(module, param_to_xpath_map))
|
||||
|
||||
want = map_params_to_obj(module, param_to_xpath_map)
|
||||
ele = map_obj_to_ele(module, want, top, choice_to_value_map)
|
||||
|
||||
kwargs = {'commit': not module.check_mode}
|
||||
kwargs['action'] = 'replace'
|
||||
with locked_config(module):
|
||||
diff = load_config(module, tostring(ele), warnings, action='replace')
|
||||
|
||||
diff = load_config(module, tostring(ele), warnings, **kwargs)
|
||||
commit = not module.check_mode
|
||||
if diff:
|
||||
if commit:
|
||||
commit_configuration(module)
|
||||
else:
|
||||
discard_changes(module)
|
||||
result['changed'] = True
|
||||
|
||||
if diff:
|
||||
result.update({
|
||||
'changed': True,
|
||||
'diff': diff,
|
||||
})
|
||||
if module._diff:
|
||||
result['diff'] = {'prepared': diff}
|
||||
|
||||
module.exit_json(**result)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue