summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoransible-zuul[bot] <48994755+ansible-zuul[bot]@users.noreply.github.com>2019-09-18 21:05:17 +0000
committerGitHub <noreply@github.com>2019-09-18 21:05:17 +0000
commit75582948949168ca2eaa04413db09298c52ada95 (patch)
treeb9123d8b0e1b2948cd9538568b8acb27b5ed9fdd
parent1f9edfd94ba9a558cf8e7438258a7a0c342c1425 (diff)
parent447598ada0da54d91cb563a679cfe261158bd7cd (diff)
downloadvyos.vyos-75582948949168ca2eaa04413db09298c52ada95.tar.gz
vyos.vyos-75582948949168ca2eaa04413db09298c52ada95.zip
Merge pull request #35 from CaptTrews/ansible/collections-sync-master
Updated from network content collector Reviewed-by: https://github.com/apps/ansible-zuul
-rw-r--r--plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py4
-rw-r--r--plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py4
-rw-r--r--plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py4
-rw-r--r--tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml36
-rw-r--r--tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml25
-rw-r--r--tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml36
6 files changed, 109 insertions, 0 deletions
diff --git a/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py b/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py
index e7f788a..af49f42 100644
--- a/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py
+++ b/plugins/module_utils/network/vyos/config/lag_interfaces/lag_interfaces.py
@@ -118,6 +118,10 @@ class Lag_interfaces(ConfigBase):
"""
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":
diff --git a/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py b/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py
index 54606fa..8570874 100644
--- a/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py
+++ b/plugins/module_utils/network/vyos/config/lldp_global/lldp_global.py
@@ -104,6 +104,10 @@ class Lldp_global(ConfigBase):
"""
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":
diff --git a/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py b/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py
index a22c27e..6b76296 100644
--- a/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py
+++ b/plugins/module_utils/network/vyos/config/lldp_interfaces/lldp_interfaces.py
@@ -115,6 +115,10 @@ class Lldp_interfaces(ConfigBase):
"""
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":
diff --git a/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 0000000..50f6d97
--- /dev/null
+++ b/tests/integration/targets/vyos_lag_interfaces/tests/cli/empty_config.yaml
@@ -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.vyos.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.vyos.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.vyos.vyos_lag_interfaces:
+ config:
+ state: overridden
+ register: result
+ ignore_errors: True
+
+- assert:
+ that:
+ - result.msg == 'config is required for state overridden'
diff --git a/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml
new file mode 100644
index 0000000..2497015
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_global/tests/cli/empty_config.yaml
@@ -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.vyos.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.vyos.vyos_lldp_global:
+ config:
+ state: replaced
+ register: result
+ ignore_errors: True
+
+- assert:
+ that:
+ - result.msg == 'config is required for state replaced'
diff --git a/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 0000000..9711791
--- /dev/null
+++ b/tests/integration/targets/vyos_lldp_interfaces/tests/cli/empty_config.yaml
@@ -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.vyos.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.vyos.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.vyos.vyos_lldp_interfaces:
+ config:
+ state: overridden
+ register: result
+ ignore_errors: True
+
+- assert:
+ that:
+ - result.msg == 'config is required for state overridden'