vyosnoconfig tracebackfix (#62518)
* vyosnoconfig tracebackfix Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com> * vyos noconfig tracebackfix test cases added Signed-off-by: rohitthakur2590 <rohitthakur2590@outlook.com> * test/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml
This commit is contained in:
parent
55f285a384
commit
b24f7d2800
6 changed files with 103 additions and 0 deletions
|
@ -107,6 +107,8 @@ class Lag_interfaces(ConfigBase):
|
||||||
"""
|
"""
|
||||||
commands = []
|
commands = []
|
||||||
state = self._module.params['state']
|
state = self._module.params['state']
|
||||||
|
if state in ('merged', 'replaced', 'overridden') and not want:
|
||||||
|
self._module.fail_json(msg='config is required for state {0}'.format(state))
|
||||||
if state == 'overridden':
|
if state == 'overridden':
|
||||||
commands.extend(self._state_overridden(want, have))
|
commands.extend(self._state_overridden(want, have))
|
||||||
elif state == 'deleted':
|
elif state == 'deleted':
|
||||||
|
|
|
@ -100,6 +100,8 @@ class Lldp_global(ConfigBase):
|
||||||
"""
|
"""
|
||||||
commands = []
|
commands = []
|
||||||
state = self._module.params['state']
|
state = self._module.params['state']
|
||||||
|
if state in ('merged', 'replaced') and not want:
|
||||||
|
self._module.fail_json(msg='config is required for state {0}'.format(state))
|
||||||
if state == 'deleted':
|
if state == 'deleted':
|
||||||
commands.extend(self._state_deleted(want=None, have=have))
|
commands.extend(self._state_deleted(want=None, have=have))
|
||||||
elif state == 'merged':
|
elif state == 'merged':
|
||||||
|
|
|
@ -110,6 +110,8 @@ class Lldp_interfaces(ConfigBase):
|
||||||
"""
|
"""
|
||||||
commands = []
|
commands = []
|
||||||
state = self._module.params['state']
|
state = self._module.params['state']
|
||||||
|
if state in ('merged', 'replaced', 'overridden') and not want:
|
||||||
|
self._module.fail_json(msg='config is required for state {0}'.format(state))
|
||||||
if state == 'overridden':
|
if state == 'overridden':
|
||||||
commands.extend(self._state_overridden(want=want, have=have))
|
commands.extend(self._state_overridden(want=want, have=have))
|
||||||
elif state == 'deleted':
|
elif state == 'deleted':
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
- debug:
|
||||||
|
msg: "START vyos_lag_interfaces empty_config integration tests on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: Merged with empty config should give appropriate error message
|
||||||
|
vyos_lag_interfaces:
|
||||||
|
config:
|
||||||
|
state: merged
|
||||||
|
register: result
|
||||||
|
ignore_errors: True
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result.msg == 'config is required for state merged'
|
||||||
|
|
||||||
|
- name: Replaced with empty config should give appropriate error message
|
||||||
|
vyos_lag_interfaces:
|
||||||
|
config:
|
||||||
|
state: replaced
|
||||||
|
register: result
|
||||||
|
ignore_errors: True
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result.msg == 'config is required for state replaced'
|
||||||
|
|
||||||
|
- name: Overridden with empty config should give appropriate error message
|
||||||
|
vyos_lag_interfaces:
|
||||||
|
config:
|
||||||
|
state: overridden
|
||||||
|
register: result
|
||||||
|
ignore_errors: True
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result.msg == 'config is required for state overridden'
|
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
- debug:
|
||||||
|
msg: "START vyos_lldp_global empty_config integration tests on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: Merged with empty config should give appropriate error message
|
||||||
|
vyos_lldp_global:
|
||||||
|
config:
|
||||||
|
state: merged
|
||||||
|
register: result
|
||||||
|
ignore_errors: True
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result.msg == 'config is required for state merged'
|
||||||
|
|
||||||
|
- name: Replaced with empty config should give appropriate error message
|
||||||
|
vyos_lldp_global:
|
||||||
|
config:
|
||||||
|
state: replaced
|
||||||
|
register: result
|
||||||
|
ignore_errors: True
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result.msg == 'config is required for state replaced'
|
|
@ -0,0 +1,36 @@
|
||||||
|
---
|
||||||
|
- debug:
|
||||||
|
msg: "START vyos_lldp_interfaces empty_config integration tests on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
- name: Merged with empty config should give appropriate error message
|
||||||
|
vyos_lldp_interfaces:
|
||||||
|
config:
|
||||||
|
state: merged
|
||||||
|
register: result
|
||||||
|
ignore_errors: True
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result.msg == 'config is required for state merged'
|
||||||
|
|
||||||
|
- name: Replaced with empty config should give appropriate error message
|
||||||
|
vyos_lldp_interfaces:
|
||||||
|
config:
|
||||||
|
state: replaced
|
||||||
|
register: result
|
||||||
|
ignore_errors: True
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result.msg == 'config is required for state replaced'
|
||||||
|
|
||||||
|
- name: Overridden with empty config should give appropriate error message
|
||||||
|
vyos_lldp_interfaces:
|
||||||
|
config:
|
||||||
|
state: overridden
|
||||||
|
register: result
|
||||||
|
ignore_errors: True
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- result.msg == 'config is required for state overridden'
|
Loading…
Reference in a new issue