Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vyosnoconfig tracebackfix #62518

Merged
merged 3 commits into from
Sep 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ def set_state(self, want, have):
"""
commands = []
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':
commands.extend(self._state_overridden(want, have))
elif state == 'deleted':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ def set_state(self, want, have):
"""
commands = []
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':
commands.extend(self._state_deleted(want=None, have=have))
elif state == 'merged':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ def set_state(self, want, have):
"""
commands = []
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':
commands.extend(self._state_overridden(want=want, have=have))
elif state == 'deleted':
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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'
Original file line number Diff line number Diff line change
@@ -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'