From 9702893729007fead14006b67936a43840f31332 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Tue, 22 Jan 2019 09:18:26 -0500 Subject: [PATCH] Remove deprecated options from modules (#50246) * Remove deprecated options from modules * Update tests * Add porting guide notes --- .../rst/porting_guides/porting_guide_2.8.rst | 7 +++- lib/ansible/modules/network/eos/eos_config.py | 35 ++----------------- lib/ansible/modules/network/ios/ios_config.py | 32 ++--------------- .../modules/network/nxos/nxos_config.py | 34 ++---------------- .../modules/network/nxos/nxos_vrf_af.py | 7 ---- .../targets/ios_config/tasks/cli.yaml | 2 +- .../targets/ios_config/tasks/cli_config.yaml | 2 +- .../targets/ios_config/tests/cli/save.yaml | 13 +++---- .../modules/network/eos/test_eos_config.py | 4 +-- .../modules/network/ios/test_ios_config.py | 4 +-- .../modules/network/nxos/test_nxos_vrf_af.py | 6 ++-- 11 files changed, 25 insertions(+), 121 deletions(-) diff --git a/docs/docsite/rst/porting_guides/porting_guide_2.8.rst b/docs/docsite/rst/porting_guides/porting_guide_2.8.rst index acaa367d2e..e98265a91d 100644 --- a/docs/docsite/rst/porting_guides/porting_guide_2.8.rst +++ b/docs/docsite/rst/porting_guides/porting_guide_2.8.rst @@ -213,4 +213,9 @@ import and instantiate ``ansible.utils.display.Display`` on its own. Networking ========== -No notable changes. +* The ``eos_config``, ``ios_config``, and ``nxos_config`` modules have removed the deprecated + ``save`` and ``force`` parameters, use the ``save_when`` parameter to replicate their + functionality. + +* The ``nxos_vrf_af`` module has removed the ``safi`` paramter. This parameter was deprecated + in Ansible 2.4 and has had no impact on the module since then. diff --git a/lib/ansible/modules/network/eos/eos_config.py b/lib/ansible/modules/network/eos/eos_config.py index 23ce45392d..1902d77792 100644 --- a/lib/ansible/modules/network/eos/eos_config.py +++ b/lib/ansible/modules/network/eos/eos_config.py @@ -99,17 +99,6 @@ options: line is not correct. default: line choices: ['line', 'block', 'config'] - force: - description: - - The force argument instructs the module to not consider the - current devices running-config. When set to true, this will - cause the module to push the contents of I(src) into the device - without first checking if already configured. - - Note this argument should be considered deprecated. To achieve - the equivalent, set the C(match=none) which is idempotent. This argument - will be removed in Ansible 2.6. - type: bool - default: 'no' backup: description: - This argument will cause the module to create a full backup of @@ -142,19 +131,6 @@ options: type: bool default: 'no' version_added: "2.2" - save: - description: - - The C(save) argument instructs the module to save the - running-config to startup-config. This operation is performed - after any changes are made to the current running config. If - no changes are made, the configuration is still saved to the - startup config. This option will always cause the module to - return changed. - - This option is deprecated as of Ansible 2.4 and will be removed - in Ansible 2.8, use C(save_when) instead. - type: bool - default: 'no' - version_added: "2.2" save_when: description: - When changes are made to the device running-configuration, the @@ -332,19 +308,12 @@ def main(): running_config=dict(aliases=['config']), intended_config=dict(), - - # save is deprecated as of ans2.4, use save_when instead - save=dict(default=False, type='bool', removed_in_version='2.8'), - - # force argument deprecated in ans2.2 - force=dict(default=False, type='bool', removed_in_version='2.6') ) argument_spec.update(eos_argument_spec) mutually_exclusive = [('lines', 'src'), - ('parents', 'src'), - ('save', 'save_when')] + ('parents', 'src')] required_if = [('match', 'strict', ['lines']), ('match', 'exact', ['lines']), @@ -420,7 +389,7 @@ def main(): running_config = module.params['running_config'] startup_config = None - if module.params['save_when'] == 'always' or module.params['save']: + if module.params['save_when'] == 'always': save_config(module, result) elif module.params['save_when'] == 'modified': output = run_commands(module, [{'command': 'show running-config', 'output': 'text'}, diff --git a/lib/ansible/modules/network/ios/ios_config.py b/lib/ansible/modules/network/ios/ios_config.py index 6b010dd0e2..a443bccd9c 100644 --- a/lib/ansible/modules/network/ios/ios_config.py +++ b/lib/ansible/modules/network/ios/ios_config.py @@ -103,17 +103,6 @@ options: configuration action. default: "@" version_added: "2.3" - force: - description: - - The force argument instructs the module to not consider the - current devices running-config. When set to true, this will - cause the module to push the contents of I(src) into the device - without first checking if already configured. - - Note this argument should be considered deprecated. To achieve - the equivalent, set the C(match=none) which is idempotent. This argument - will be removed in Ansible 2.6. - type: bool - default: 'no' backup: description: - This argument will cause the module to create a full backup of @@ -145,16 +134,6 @@ options: type: bool default: 'no' version_added: "2.2" - save: - description: - - The C(save) argument instructs the module to save the running- - config to the startup-config at the conclusion of the module - running. If check mode is specified, this argument is ignored. - - This option is deprecated as of Ansible 2.4 and will be removed - in Ansible 2.8, use C(save_when) instead. - type: bool - default: 'no' - version_added: "2.2" save_when: description: - When changes are made to the device running-configuration, the @@ -394,19 +373,12 @@ def main(): diff_against=dict(choices=['startup', 'intended', 'running']), diff_ignore_lines=dict(type='list'), - - # save is deprecated as of ans2.4, use save_when instead - save=dict(default=False, type='bool', removed_in_version='2.8'), - - # force argument deprecated in ans2.2 - force=dict(default=False, type='bool', removed_in_version='2.6') ) argument_spec.update(ios_argument_spec) mutually_exclusive = [('lines', 'src'), - ('parents', 'src'), - ('save', 'save_when')] + ('parents', 'src')] required_if = [('match', 'strict', ['lines']), ('match', 'exact', ['lines']), @@ -478,7 +450,7 @@ def main(): running_config = module.params['running_config'] startup_config = None - if module.params['save_when'] == 'always' or module.params['save']: + if module.params['save_when'] == 'always': save_config(module, result) elif module.params['save_when'] == 'modified': output = run_commands(module, ['show running-config', 'show startup-config']) diff --git a/lib/ansible/modules/network/nxos/nxos_config.py b/lib/ansible/modules/network/nxos/nxos_config.py index 1c343e0cf2..69ec50e259 100644 --- a/lib/ansible/modules/network/nxos/nxos_config.py +++ b/lib/ansible/modules/network/nxos/nxos_config.py @@ -103,17 +103,6 @@ options: line is not correct. replace I(config) is supported only on Nexus 9K device. default: line choices: ['line', 'block', 'config'] - force: - description: - - The force argument instructs the module to not consider the - current devices running-config. When set to true, this will - cause the module to push the contents of I(src) into the device - without first checking if already configured. - - Note this argument should be considered deprecated. To achieve - the equivalent, set the C(match=none) which is idempotent. This argument - will be removed in a future release. - type: bool - default: 'no' backup: description: - This argument will cause the module to create a full backup of @@ -146,18 +135,6 @@ options: type: bool default: 'no' version_added: "2.2" - save: - description: - - The C(save) argument instructs the module to save the - running-config to startup-config. This operation is performed - after any changes are made to the current running config. If - no changes are made, the configuration is still saved to the - startup config. This option will always cause the module to - return changed. - - This option is deprecated as of Ansible 2.4, use C(save_when) - type: bool - default: 'no' - version_added: "2.2" save_when: description: - When changes are made to the device running-configuration, the @@ -359,19 +336,12 @@ def main(): diff_against=dict(choices=['running', 'startup', 'intended']), diff_ignore_lines=dict(type='list'), - - # save is deprecated as of ans2.4, use save_when instead - save=dict(default=False, type='bool', removed_in_version='2.8'), - - # force argument deprecated in ans2.2 - force=dict(default=False, type='bool', removed_in_version='2.6') ) argument_spec.update(nxos_argument_spec) mutually_exclusive = [('lines', 'src', 'replace_src'), - ('parents', 'src'), - ('save', 'save_when')] + ('parents', 'src')] required_if = [('match', 'strict', ['lines']), ('match', 'exact', ['lines']), @@ -448,7 +418,7 @@ def main(): running_config = module.params['running_config'] startup_config = None - if module.params['save_when'] == 'always' or module.params['save']: + if module.params['save_when'] == 'always': save_config(module, result) elif module.params['save_when'] == 'modified': output = execute_show_commands(module, ['show running-config', 'show startup-config']) diff --git a/lib/ansible/modules/network/nxos/nxos_vrf_af.py b/lib/ansible/modules/network/nxos/nxos_vrf_af.py index 0466b482bd..a00b994c7a 100644 --- a/lib/ansible/modules/network/nxos/nxos_vrf_af.py +++ b/lib/ansible/modules/network/nxos/nxos_vrf_af.py @@ -42,12 +42,6 @@ options: - Address-Family Identifier (AFI). required: true choices: ['ipv4', 'ipv6'] - safi: - description: - - Sub Address-Family Identifier (SAFI). - - Deprecated in 2.4 - required: true - choices: ['unicast', 'multicast'] route_target_both_auto_evpn: description: - Enable/Disable the EVPN route-target 'auto' setting for both @@ -88,7 +82,6 @@ def main(): afi=dict(required=True, choices=['ipv4', 'ipv6']), route_target_both_auto_evpn=dict(required=False, type='bool'), state=dict(choices=['present', 'absent'], default='present'), - safi=dict(choices=['unicast', 'multicast'], removed_in_version="2.4"), ) argument_spec.update(nxos_argument_spec) diff --git a/test/integration/targets/ios_config/tasks/cli.yaml b/test/integration/targets/ios_config/tasks/cli.yaml index ea5c8c3742..87a42971bb 100644 --- a/test/integration/targets/ios_config/tasks/cli.yaml +++ b/test/integration/targets/ios_config/tasks/cli.yaml @@ -10,7 +10,7 @@ set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" - name: run test cases (connection=network_cli) - include: "{{ test_case_to_run }}" + include: "{{ test_case_to_run }} ansible_connection=network_cli" with_items: "{{ test_items }}" loop_control: loop_var: test_case_to_run diff --git a/test/integration/targets/ios_config/tasks/cli_config.yaml b/test/integration/targets/ios_config/tasks/cli_config.yaml index f5d5b551fb..cb96d05e5f 100644 --- a/test/integration/targets/ios_config/tasks/cli_config.yaml +++ b/test/integration/targets/ios_config/tasks/cli_config.yaml @@ -9,7 +9,7 @@ - name: set test_items set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" -- name: run test case (connection=network_cli) +- name: run test cases (connection=network_cli) include: "{{ test_case_to_run }} ansible_connection=network_cli" with_items: "{{ test_items }}" loop_control: diff --git a/test/integration/targets/ios_config/tests/cli/save.yaml b/test/integration/targets/ios_config/tests/cli/save.yaml index 70aedb3489..bd83961575 100644 --- a/test/integration/targets/ios_config/tests/cli/save.yaml +++ b/test/integration/targets/ios_config/tests/cli/save.yaml @@ -9,22 +9,17 @@ parents: - interface Loopback999 match: none + save_when: modified - -- name: save config +- name: save should always run ios_config: - save: true + save_when: always register: result - assert: that: - "result.changed == true" -- name: save should always run - ios_config: - save: true - register: result - - name: delete config (setup) ios_config: replace: line @@ -33,7 +28,7 @@ save_when: modified register: result -- name: save should always run +- name: save should run when changed ios_config: replace: line lines: diff --git a/test/units/modules/network/eos/test_eos_config.py b/test/units/modules/network/eos/test_eos_config.py index b2bfba0175..113f539247 100644 --- a/test/units/modules/network/eos/test_eos_config.py +++ b/test/units/modules/network/eos/test_eos_config.py @@ -199,9 +199,9 @@ class TestEosConfigModule(TestEosModule): self.assertEqual(self.get_config.call_count, 0) self.assertEqual(self.load_config.call_count, 0) - def test_eos_config_save(self): + def test_eos_config_save_always(self): self.run_commands.return_value = "hostname foo" - set_module_args(dict(save=True)) + set_module_args(dict(save_when='always')) self.execute_module(changed=True) self.assertEqual(self.run_commands.call_count, 1) self.assertEqual(self.get_config.call_count, 0) diff --git a/test/units/modules/network/ios/test_ios_config.py b/test/units/modules/network/ios/test_ios_config.py index a6030e5823..55479b759f 100644 --- a/test/units/modules/network/ios/test_ios_config.py +++ b/test/units/modules/network/ios/test_ios_config.py @@ -108,9 +108,9 @@ class TestIosConfigModule(TestIosModule): self.assertEqual(self.get_config.call_count, 0) self.assertEqual(self.conn.edit_config.call_count, 0) - def test_ios_config_save(self): + def test_ios_config_save_always(self): self.run_commands.return_value = "hostname foo" - set_module_args(dict(save=True)) + set_module_args(dict(save_when='always')) self.execute_module(changed=True) self.assertEqual(self.run_commands.call_count, 1) self.assertEqual(self.get_config.call_count, 0) diff --git a/test/units/modules/network/nxos/test_nxos_vrf_af.py b/test/units/modules/network/nxos/test_nxos_vrf_af.py index a5eaace5f5..c26f480b24 100644 --- a/test/units/modules/network/nxos/test_nxos_vrf_af.py +++ b/test/units/modules/network/nxos/test_nxos_vrf_af.py @@ -46,18 +46,18 @@ class TestNxosVrfafModule(TestNxosModule): self.load_config.return_value = None def test_nxos_vrf_af_present(self): - set_module_args(dict(vrf='ntc', afi='ipv4', safi='unicast', state='present')) + set_module_args(dict(vrf='ntc', afi='ipv4', state='present')) result = self.execute_module(changed=True) self.assertEqual(sorted(result['commands']), sorted(['vrf context ntc', 'address-family ipv4 unicast'])) def test_nxos_vrf_af_absent(self): - set_module_args(dict(vrf='ntc', afi='ipv4', safi='unicast', state='absent')) + set_module_args(dict(vrf='ntc', afi='ipv4', state='absent')) result = self.execute_module(changed=False) self.assertEqual(result['commands'], []) def test_nxos_vrf_af_route_target(self): - set_module_args(dict(vrf='ntc', afi='ipv4', safi='unicast', route_target_both_auto_evpn=True)) + set_module_args(dict(vrf='ntc', afi='ipv4', route_target_both_auto_evpn=True)) result = self.execute_module(changed=True) self.assertEqual(sorted(result['commands']), sorted(['vrf context ntc', 'address-family ipv4 unicast',