summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaptTrews <capttrews@gmail.com>2019-10-01 00:14:01 +0000
committerCaptTrews <capttrews@gmail.com>2019-10-01 00:14:01 +0000
commit50e9bfdb1a7eca7e343ff56440e244e405234d2e (patch)
treeec37ffdc027e6a0458346e198799e2bb35174f4b
parent1c3031ec21cd14952fb3256600e3ab50fc28fd77 (diff)
downloadvyos.vyos-50e9bfdb1a7eca7e343ff56440e244e405234d2e.tar.gz
vyos.vyos-50e9bfdb1a7eca7e343ff56440e244e405234d2e.zip
Updated from network content collector
Signed-off-by: CaptTrews <capttrews@gmail.com>
-rw-r--r--plugins/module_utils/network/vyos/config/interfaces/interfaces.py8
-rw-r--r--plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py8
-rw-r--r--tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml36
-rw-r--r--tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml36
4 files changed, 88 insertions, 0 deletions
diff --git a/plugins/module_utils/network/vyos/config/interfaces/interfaces.py b/plugins/module_utils/network/vyos/config/interfaces/interfaces.py
index e5724f52..d781fd0e 100644
--- a/plugins/module_utils/network/vyos/config/interfaces/interfaces.py
+++ b/plugins/module_utils/network/vyos/config/interfaces/interfaces.py
@@ -114,6 +114,14 @@ 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))
diff --git a/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py b/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py
index 2bd04b69..fb7dbdc2 100644
--- a/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py
+++ b/plugins/module_utils/network/vyos/config/l3_interfaces/l3_interfaces.py
@@ -115,6 +115,14 @@ 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))
diff --git a/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 00000000..ab68fde4
--- /dev/null
+++ b/tests/integration/targets/vyos_interfaces/tests/cli/empty_config.yaml
@@ -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.vyos.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.vyos.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.vyos.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'
diff --git a/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml b/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml
new file mode 100644
index 00000000..530df883
--- /dev/null
+++ b/tests/integration/targets/vyos_l3_interfaces/tests/cli/empty_config.yaml
@@ -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.vyos.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.vyos.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.vyos.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'