diff options
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | changelogs/fragments/replace-check_required.yaml | 3 | ||||
-rw-r--r-- | plugins/modules/vyos_logging.py | 9 | ||||
-rw-r--r-- | plugins/modules/vyos_static_route.py | 9 | ||||
-rw-r--r-- | plugins/modules/vyos_vlan.py | 7 |
5 files changed, 23 insertions, 9 deletions
@@ -29,10 +29,6 @@ Name | Description --- | --- [vyos.vyos.vyos](https://github.com/ansible-collections/vyos.vyos/blob/main/docs/vyos.vyos.vyos_cliconf.rst)|Use vyos cliconf to run command on VyOS platform -### Filter plugins -Name | Description ---- | --- - ### Modules Name | Description --- | --- diff --git a/changelogs/fragments/replace-check_required.yaml b/changelogs/fragments/replace-check_required.yaml new file mode 100644 index 0000000..b955d31 --- /dev/null +++ b/changelogs/fragments/replace-check_required.yaml @@ -0,0 +1,3 @@ +--- +trivial: + - Replace module._check_required_* calls removed in ansible-core 2.11 with calls from common.validation diff --git a/plugins/modules/vyos_logging.py b/plugins/modules/vyos_logging.py index c7780d8..d4f0cfc 100644 --- a/plugins/modules/vyos_logging.py +++ b/plugins/modules/vyos_logging.py @@ -152,7 +152,9 @@ import re from copy import deepcopy +from ansible.module_utils._text import to_text from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.common.validation import check_required_if from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( remove_default_spec, ) @@ -256,7 +258,10 @@ def map_params_to_obj(module, required_if=None): if item.get(key) is None: item[key] = module.params[key] - module._check_required_if(required_if, item) + try: + check_required_if(required_if, item) + except TypeError as exc: + module.fail_json(to_text(exc)) obj.append(item.copy()) else: @@ -294,7 +299,7 @@ def main(): remove_default_spec(aggregate_spec) argument_spec = dict( - aggregate=dict(type="list", elements="dict", options=aggregate_spec), + aggregate=dict(type="list", elements="dict", options=aggregate_spec) ) argument_spec.update(element_spec) diff --git a/plugins/modules/vyos_static_route.py b/plugins/modules/vyos_static_route.py index 3a96997..1f7adef 100644 --- a/plugins/modules/vyos_static_route.py +++ b/plugins/modules/vyos_static_route.py @@ -147,7 +147,9 @@ import re from copy import deepcopy +from ansible.module_utils._text import to_text from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.common.validation import check_required_together from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( remove_default_spec, ) @@ -238,7 +240,10 @@ def map_params_to_obj(module, required_together=None): if item.get(key) is None: item[key] = module.params[key] - module._check_required_together(required_together, item) + try: + check_required_together(required_together, item) + except TypeError as exc: + module.fail_json(to_text(exc)) d = item.copy() if "/" in d["prefix"]: d["mask"] = d["prefix"].split("/")[1] @@ -289,7 +294,7 @@ def main(): remove_default_spec(aggregate_spec) argument_spec = dict( - aggregate=dict(type="list", elements="dict", options=aggregate_spec), + aggregate=dict(type="list", elements="dict", options=aggregate_spec) ) argument_spec.update(element_spec) diff --git a/plugins/modules/vyos_vlan.py b/plugins/modules/vyos_vlan.py index c04ac93..39f371a 100644 --- a/plugins/modules/vyos_vlan.py +++ b/plugins/modules/vyos_vlan.py @@ -167,7 +167,9 @@ import time from copy import deepcopy +from ansible.module_utils._text import to_text from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.common.validation import check_required_one_of from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import ( remove_default_spec, ) @@ -258,7 +260,10 @@ def map_params_to_obj(module): module.fail_json(msg="vlan_id is required") d["vlan_id"] = str(d["vlan_id"]) - module._check_required_one_of(module.required_one_of, item) + try: + check_required_one_of(module.required_one_of, item) + except TypeError as exc: + module.fail_json(to_text(exc)) obj.append(d) else: |