Debian Codegraph @

ansible_collections/cisco/mso/plugins/modules/mso_schema_validate.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2021, Anvitha Jain (@anvitha-jain) <[email protected]>
5 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 from __future__ import absolute_import, division, print_function
8
9 __metaclass__ = type
10
11 ANSIBLE_METADATA = {"metadata_version": "1.1", "status": ["preview"], "supported_by": "community"}
12
13 DOCUMENTATION = r"""
14 ---
15 module: mso_schema_validate
16 short_description: Validate the schema before deploying it to site
17 description:
18 - This module is used to verify if a schema can be deployed to site without any error.
19 - This module can only be used on versions of MSO that are 3.3 or greater.
20 - Starting with MSO 3.3, the schema modules in this collection will skip some validation checks to allow part of the schema to be updated more easily.
21 - This module will check those validation after all changes have been made.
22 author:
23 - Anvitha Jain (@anvitha-jain)
24 version_added: "1.3.0"
25 options:
26 schema:
27 description:
28 - The name of the schema.
29 type: str
30 required: true
31 state:
32 description:
33 - Use C(query) to validate deploying the schema.
34 type: str
35 default: query
36 choices: [ query ]
37 seealso:
38 - module: cisco.mso.mso_schema
39 extends_documentation_fragment: cisco.mso.modules
40 """
41
42 EXAMPLES = r"""
43 - name: Get Validation status
44 mso_schema_validate:
45 host: mso_host
46 username: admin
47 password: SomeSecretPassword
48 schema: Schema 1
49 state: query
50 register: query_validate
51 """
52
53 RETURN = r"""
54 """
55
56 from ansible.module_utils.basic import AnsibleModule
57 from ansible_collections.cisco.mso.plugins.module_utils.mso import MSOModule, mso_argument_spec
58
59
60 def main():
61 argument_spec = mso_argument_spec()
62 argument_spec.update(
63 schema=dict(type="str", required=True),
64 state=dict(type="str", default="query", choices=["query"]),
65 )
66
67 module = AnsibleModule(
68 argument_spec=argument_spec,
69 supports_check_mode=True,
70 )
71
72 schema = module.params.get("schema")
73
74 mso = MSOModule(module)
75
76 mso.existing = mso.validate_schema(schema_id=mso.lookup_schema(schema))
77
78 mso.exit_json()
79
80
81 if __name__ == "__main__":
82 main()