Skip to content

Commit

Permalink
Playbook check and diff modes util and radius-server implemetation (#279
Browse files Browse the repository at this point in the history
)

* Playbook check and diff modes util and radius-server implemetation

* Add fragment file

* Fix sanity errors

* Address review comments

* Address review comment
  • Loading branch information
mingjunzhang2019 committed Jul 14, 2023
1 parent 59a4e7a commit 70dcac1
Show file tree
Hide file tree
Showing 4 changed files with 449 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
major_changes:
- Playbook check and diff modes utility functions and sonic_radius_server module support for the check and diff modes (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/279).
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,20 @@
get_replaced_config,
normalize_interface_name,
)
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.formatted_diff_utils import (
__DELETE_CONFIG_IF_NO_SUBCONFIG,
get_new_config,
get_formatted_config_diff
)

PATCH = 'patch'
DELETE = 'delete'
TEST_KEYS = [
{'host': {'name': ''}},
]
TEST_KEYS_formatted_diff = [
{'host': {'name': '', '__delete_op': __DELETE_CONFIG_IF_NO_SUBCONFIG}},
]


class Radius_server(ConfigBase):
Expand Down Expand Up @@ -92,6 +100,16 @@ def execute_module(self):
if result['changed']:
result['after'] = changed_radius_server_facts

new_config = changed_radius_server_facts
if self._module.check_mode:
result.pop('after', None)
new_config = get_new_config(commands, existing_radius_server_facts,
TEST_KEYS_formatted_diff)
result['after(generated)'] = new_config

if self._module._diff:
result['config_diff'] = get_formatted_config_diff(existing_radius_server_facts,
new_config)
result['warnings'] = warnings
return result

Expand Down
Loading

0 comments on commit 70dcac1

Please sign in to comment.