1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Remove deprecated options from modules (#50246)

* Remove deprecated options from modules

* Update tests

* Add porting guide notes
This commit is contained in:
Nathaniel Case 2019-01-22 09:18:26 -05:00 committed by GitHub
parent 7f2b9a8a31
commit 9702893729
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 25 additions and 121 deletions

View file

@ -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.

View file

@ -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'},

View file

@ -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'])

View file

@ -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'])

View file

@ -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)

View file

@ -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

View file

@ -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:

View file

@ -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:

View file

@ -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)

View file

@ -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)

View file

@ -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',