Fix traceback for empty config (#62520)
Signed-off-by: NilashishC <nilashishchakraborty8@gmail.com>
This commit is contained in:
parent
9aff5f6007
commit
67213ccb4d
4 changed files with 80 additions and 0 deletions
|
@ -108,6 +108,10 @@ class Interfaces(ConfigBase):
|
|||
"""
|
||||
commands = []
|
||||
state = self._module.params['state']
|
||||
|
||||
if state in ('merged', 'replaced', 'overridden') and not want:
|
||||
self._module.fail_json(msg='value of config parameter must not be empty for state {0}'.format(state))
|
||||
|
||||
if state == 'overridden':
|
||||
commands.extend(self._state_overridden(want=want, have=have))
|
||||
|
||||
|
|
|
@ -110,6 +110,10 @@ class L3_interfaces(ConfigBase):
|
|||
"""
|
||||
commands = []
|
||||
state = self._module.params['state']
|
||||
|
||||
if state in ('merged', 'replaced', 'overridden') and not want:
|
||||
self._module.fail_json(msg='value of config parameter must not be empty for state {0}'.format(state))
|
||||
|
||||
if state == 'overridden':
|
||||
commands.extend(self._state_overridden(want=want, have=have))
|
||||
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
- debug:
|
||||
msg: "START vyos_interfaces empty_config integration tests on connection={{ ansible_connection }}"
|
||||
|
||||
- name: Merged with empty config should give appropriate error message
|
||||
vyos_interfaces:
|
||||
config:
|
||||
state: merged
|
||||
register: result
|
||||
ignore_errors: True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.msg == 'value of config parameter must not be empty for state merged'
|
||||
|
||||
- name: Replaced with empty config should give appropriate error message
|
||||
vyos_interfaces:
|
||||
config:
|
||||
state: replaced
|
||||
register: result
|
||||
ignore_errors: True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.msg == 'value of config parameter must not be empty for state replaced'
|
||||
|
||||
- name: Overridden with empty config should give appropriate error message
|
||||
vyos_interfaces:
|
||||
config:
|
||||
state: overridden
|
||||
register: result
|
||||
ignore_errors: True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.msg == 'value of config parameter must not be empty for state overridden'
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
- debug:
|
||||
msg: "START vyos_l3_interfaces empty_config integration tests on connection={{ ansible_connection }}"
|
||||
|
||||
- name: Merged with empty config should give appropriate error message
|
||||
vyos_l3_interfaces:
|
||||
config:
|
||||
state: merged
|
||||
register: result
|
||||
ignore_errors: True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.msg == 'value of config parameter must not be empty for state merged'
|
||||
|
||||
- name: Replaced with empty config should give appropriate error message
|
||||
vyos_l3_interfaces:
|
||||
config:
|
||||
state: replaced
|
||||
register: result
|
||||
ignore_errors: True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.msg == 'value of config parameter must not be empty for state replaced'
|
||||
|
||||
- name: Overridden with empty config should give appropriate error message
|
||||
vyos_l3_interfaces:
|
||||
config:
|
||||
state: overridden
|
||||
register: result
|
||||
ignore_errors: True
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- result.msg == 'value of config parameter must not be empty for state overridden'
|
Loading…
Reference in a new issue