2021-09-24 07:29:52 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Copyright 2021 Red Hat
|
|
|
|
# GNU General Public License v3.0+
|
|
|
|
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
"""
|
|
|
|
The utils file for all netaddr tests
|
|
|
|
"""
|
|
|
|
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
|
2022-05-26 17:18:57 +00:00
|
|
|
|
2021-09-24 07:29:52 +00:00
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
from ansible.errors import AnsibleError
|
2022-05-26 17:18:57 +00:00
|
|
|
|
2021-09-24 07:29:52 +00:00
|
|
|
from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import (
|
|
|
|
check_argspec,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def _validate_args(plugin, doc, params):
|
2022-04-06 15:30:29 +00:00
|
|
|
"""argspec validator utility function"""
|
2021-09-24 07:29:52 +00:00
|
|
|
|
2022-05-26 17:18:57 +00:00
|
|
|
valid, argspec_result, updated_params = check_argspec(doc, plugin + " test", **params)
|
2021-09-24 07:29:52 +00:00
|
|
|
|
|
|
|
if not valid:
|
|
|
|
raise AnsibleError(
|
|
|
|
"{argspec_result} with errors: {argspec_errors}".format(
|
|
|
|
argspec_result=argspec_result.get("msg"),
|
|
|
|
argspec_errors=argspec_result.get("errors"),
|
2022-06-01 12:35:10 +00:00
|
|
|
),
|
2021-09-24 07:29:52 +00:00
|
|
|
)
|