Skip to content

Commit

Permalink
Add updates option in return value of iosxr_config (#439)
Browse files Browse the repository at this point in the history
* Add updates option in return value of iosxr_config

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Delete tests/integration/network-integration.cfg

* Update fix_iosxr_config.yaml

* Update fix_iosxr_config.yaml

* Fix sanity

* Add relevent changelog

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Ashwini Mhatre <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 26, 2023
1 parent 73febeb commit 94c821c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/fix_iosxr_config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- iosxr_config Add updates option in return value(https://github.com/ansible-collections/cisco.iosxr/issues/438).
17 changes: 17 additions & 0 deletions docs/cisco.iosxr.iosxr_config_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,23 @@ Common return values are documented `here <https://docs.ansible.com/ansible/late
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">22:28:34</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="return-"></div>
<b>updates</b>
<a class="ansibleOptionLink" href="#return-" title="Permalink to this return value"></a>
<div style="font-size: small">
<span style="color: purple">list</span>
</div>
</td>
<td>If there are commands to run against the host</td>
<td>
<div>The set of commands that will be pushed to the remote device</div>
<br/>
<div style="font-size: smaller"><b>Sample:</b></div>
<div style="font-size: smaller; color: blue; word-wrap: break-word; word-break: break-all;">[&#x27;hostname foo&#x27;, &#x27;router ospf 1&#x27;, &#x27;router-id 1.1.1.1&#x27;]</div>
</td>
</tr>
</table>
<br/><br/>

Expand Down
6 changes: 6 additions & 0 deletions plugins/modules/iosxr_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@
returned: If there are commands to run against the host
type: list
sample: ['hostname foo', 'router ospf 1', 'router-id 1.1.1.1']
updates:
description: The set of commands that will be pushed to the remote device
returned: If there are commands to run against the host
type: list
sample: ['hostname foo', 'router ospf 1', 'router-id 1.1.1.1']
backup_path:
description: The full path to the backup file
returned: when backup is yes
Expand Down Expand Up @@ -392,6 +397,7 @@ def run(module, result):
commands.extend(module.params["after"])

result["commands"] = commands
result["updates"] = commands

commit = not check_mode
diff = load_config(
Expand Down
14 changes: 14 additions & 0 deletions tests/unit/modules/network/iosxr/test_iosxr_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,17 @@ def test_iosxr_config_replace_config_requires_src(self):
args = dict(replace="config")
set_module_args(args)
self.execute_module(failed=True)

def test_iosxr_config_updates(self):
src = load_fixture("iosxr_config_src.cfg")
set_module_args(dict(src=src))
self.conn.get_diff = MagicMock(
return_value=self.cliconf_obj.get_diff(src, self.running_config),
)
commands = [
"hostname foo",
"interface GigabitEthernet0/0",
"no ip address",
]
result = self.execute_module(changed=True, commands=commands)
self.assertEqual(sorted(result["updates"]), sorted(commands))

0 comments on commit 94c821c

Please sign in to comment.