From 6ecf17ee4d957ed392a35f89c375378f97bab1e3 Mon Sep 17 00:00:00 2001 From: Ganesh Nalawade Date: Wed, 11 Sep 2019 11:06:08 +0530 Subject: [PATCH] Return commands key instead of xml in result for junos rm (#62041) Fixes https://github.com/ansible/ansible/issues/61773 * Change `xml` key name to `commands` key to be in sync with other platform resource modules. (cherry picked from commit ff53ca76b83d151fb05ba0c69def6089dc893135) --- changelogs/fragments/junos_rm_commands_key.yaml | 2 ++ .../network/junos/config/interfaces/interfaces.py | 2 +- .../junos/config/l2_interfaces/l2_interfaces.py | 2 +- .../junos/config/l3_interfaces/l3_interfaces.py | 2 +- .../module_utils/network/junos/config/lacp/lacp.py | 2 +- .../junos/config/lacp_interfaces/lacp_interfaces.py | 2 +- .../junos/config/lag_interfaces/lag_interfaces.py | 2 +- .../network/junos/config/lldp_global/lldp_global.py | 2 +- .../junos/config/lldp_interfaces/lldp_interfaces.py | 2 +- .../module_utils/network/junos/config/vlans/vlans.py | 2 +- .../tests/netconf/junos_l3_interfaces.yml | 12 ++++++------ 11 files changed, 17 insertions(+), 15 deletions(-) create mode 100644 changelogs/fragments/junos_rm_commands_key.yaml diff --git a/changelogs/fragments/junos_rm_commands_key.yaml b/changelogs/fragments/junos_rm_commands_key.yaml new file mode 100644 index 00000000000..3e5017ea6c8 --- /dev/null +++ b/changelogs/fragments/junos_rm_commands_key.yaml @@ -0,0 +1,2 @@ +bugfixes: +- Return commands key instead of xml in result for junos resource module (https://github.com/ansible/ansible/issues/61773) diff --git a/lib/ansible/module_utils/network/junos/config/interfaces/interfaces.py b/lib/ansible/module_utils/network/junos/config/interfaces/interfaces.py index 9d80a58436c..1c6bfd2c761 100644 --- a/lib/ansible/module_utils/network/junos/config/interfaces/interfaces.py +++ b/lib/ansible/module_utils/network/junos/config/interfaces/interfaces.py @@ -76,7 +76,7 @@ class Interfaces(ConfigBase): if self._module._diff: result['diff'] = {'prepared': diff} - result['xml'] = config_xmls + result['commands'] = config_xmls changed_interfaces_facts = self.get_interfaces_facts() diff --git a/lib/ansible/module_utils/network/junos/config/l2_interfaces/l2_interfaces.py b/lib/ansible/module_utils/network/junos/config/l2_interfaces/l2_interfaces.py index 3eb2e117113..9537e284065 100644 --- a/lib/ansible/module_utils/network/junos/config/l2_interfaces/l2_interfaces.py +++ b/lib/ansible/module_utils/network/junos/config/l2_interfaces/l2_interfaces.py @@ -77,7 +77,7 @@ class L2_interfaces(ConfigBase): if self._module._diff: result['diff'] = {'prepared': diff} - result['xml'] = config_xmls + result['commands'] = config_xmls changed_l2_interfaces_facts = self.get_l2_interfaces_facts() diff --git a/lib/ansible/module_utils/network/junos/config/l3_interfaces/l3_interfaces.py b/lib/ansible/module_utils/network/junos/config/l3_interfaces/l3_interfaces.py index 2b740def000..06db84bd235 100644 --- a/lib/ansible/module_utils/network/junos/config/l3_interfaces/l3_interfaces.py +++ b/lib/ansible/module_utils/network/junos/config/l3_interfaces/l3_interfaces.py @@ -81,7 +81,7 @@ class L3_interfaces(ConfigBase): if self._module._diff: result['diff'] = {'prepared': diff} - result['xml'] = config_xmls + result['commands'] = config_xmls changed_interfaces_facts = self.get_l3_interfaces_facts() diff --git a/lib/ansible/module_utils/network/junos/config/lacp/lacp.py b/lib/ansible/module_utils/network/junos/config/lacp/lacp.py index a5562a0e770..875f63880a8 100644 --- a/lib/ansible/module_utils/network/junos/config/lacp/lacp.py +++ b/lib/ansible/module_utils/network/junos/config/lacp/lacp.py @@ -75,7 +75,7 @@ class Lacp(ConfigBase): if self._module._diff: result['diff'] = {'prepared': diff} - result['xml'] = config_xmls + result['commands'] = config_xmls changed_lacp_facts = self.get_lacp_facts() diff --git a/lib/ansible/module_utils/network/junos/config/lacp_interfaces/lacp_interfaces.py b/lib/ansible/module_utils/network/junos/config/lacp_interfaces/lacp_interfaces.py index 00d0a8af266..62be176df32 100644 --- a/lib/ansible/module_utils/network/junos/config/lacp_interfaces/lacp_interfaces.py +++ b/lib/ansible/module_utils/network/junos/config/lacp_interfaces/lacp_interfaces.py @@ -73,7 +73,7 @@ class Lacp_interfaces(ConfigBase): if self._module._diff: result['diff'] = {'prepared': diff} - result['xml'] = config_xmls + result['commands'] = config_xmls changed_lacp_interfaces_facts = self.get_lacp_interfaces_facts() diff --git a/lib/ansible/module_utils/network/junos/config/lag_interfaces/lag_interfaces.py b/lib/ansible/module_utils/network/junos/config/lag_interfaces/lag_interfaces.py index 16d69f569c3..3d8fc62941a 100644 --- a/lib/ansible/module_utils/network/junos/config/lag_interfaces/lag_interfaces.py +++ b/lib/ansible/module_utils/network/junos/config/lag_interfaces/lag_interfaces.py @@ -75,7 +75,7 @@ class Lag_interfaces(ConfigBase): if self._module._diff: result['diff'] = {'prepared': diff} - result['xml'] = config_xmls + result['commands'] = config_xmls changed_lag_interfaces_facts = self.get_lag_interfaces_facts() diff --git a/lib/ansible/module_utils/network/junos/config/lldp_global/lldp_global.py b/lib/ansible/module_utils/network/junos/config/lldp_global/lldp_global.py index 3b33a667284..57c8b5c6279 100644 --- a/lib/ansible/module_utils/network/junos/config/lldp_global/lldp_global.py +++ b/lib/ansible/module_utils/network/junos/config/lldp_global/lldp_global.py @@ -73,7 +73,7 @@ class Lldp_global(ConfigBase): if self._module._diff: result['diff'] = {'prepared': diff} - result['xml'] = config_xmls + result['commands'] = config_xmls changed_lldp_global_facts = self.get_lldp_global_facts() diff --git a/lib/ansible/module_utils/network/junos/config/lldp_interfaces/lldp_interfaces.py b/lib/ansible/module_utils/network/junos/config/lldp_interfaces/lldp_interfaces.py index 008788cb662..4cbb0faccf6 100644 --- a/lib/ansible/module_utils/network/junos/config/lldp_interfaces/lldp_interfaces.py +++ b/lib/ansible/module_utils/network/junos/config/lldp_interfaces/lldp_interfaces.py @@ -74,7 +74,7 @@ class Lldp_interfaces(ConfigBase): if self._module._diff: result['diff'] = {'prepared': diff} - result['xml'] = config_xmls + result['commands'] = config_xmls changed_lldp_interfaces_facts = self.get_lldp_interfaces_facts() diff --git a/lib/ansible/module_utils/network/junos/config/vlans/vlans.py b/lib/ansible/module_utils/network/junos/config/vlans/vlans.py index 7cca4fa6af9..70aa5f72fc5 100644 --- a/lib/ansible/module_utils/network/junos/config/vlans/vlans.py +++ b/lib/ansible/module_utils/network/junos/config/vlans/vlans.py @@ -92,7 +92,7 @@ class Vlans(ConfigBase): if self._module._diff: result['diff'] = {'prepared': diff} - result['xml'] = config_xmls + result['commands'] = config_xmls changed_vlans_facts = self.get_vlans_facts() diff --git a/test/integration/targets/junos_l3_interfaces/tests/netconf/junos_l3_interfaces.yml b/test/integration/targets/junos_l3_interfaces/tests/netconf/junos_l3_interfaces.yml index 7a717cf5517..f74691d3380 100644 --- a/test/integration/targets/junos_l3_interfaces/tests/netconf/junos_l3_interfaces.yml +++ b/test/integration/targets/junos_l3_interfaces/tests/netconf/junos_l3_interfaces.yml @@ -20,8 +20,8 @@ - assert: that: - result is changed - - "'192.168.100.1/24' in result.xml[0]" - - "'10.200.16.20/24' in result.xml[0]" + - "'192.168.100.1/24' in result.commands[0]" + - "'10.200.16.20/24' in result.commands[0]" - "result.after[0].name == 'ge-1/0/0'" - "result.after[0].ipv4[0]['address'] == '192.168.100.1/24'" - "result.after[0].ipv4[1]['address'] == '10.200.16.20/24'" @@ -61,8 +61,8 @@ - assert: that: - result is changed - - "'100.64.0.1/10' in result.xml[0]" - - "'100.64.0.2/10' in result.xml[0]" + - "'100.64.0.1/10' in result.commands[0]" + - "'100.64.0.2/10' in result.commands[0]" - "result.after[0].name == 'ge-1/0/0'" - "result.after[0].ipv4[0]['address'] == '192.168.100.1/24'" - "result.after[0].ipv4[1]['address'] == '10.200.16.20/24'" @@ -79,7 +79,7 @@ - assert: that: - result is changed - - "'ge-2/0/00' in result.xml[0]" + - "'ge-2/0/00' in result.commands[0]" - name: Override all config junos_l3_interfaces: @@ -96,4 +96,4 @@ - assert: that: - result is changed - - "'fxp00' in result.xml[0]" + - "'fxp00' in result.commands[0]"