Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_pm_config_upgrade.py

raw symbols SCIP
1 #!/usr/bin/python
2 from __future__ import absolute_import, division, print_function
3 # Copyright 2019-2024 Fortinet, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 __metaclass__ = type
7
8 ANSIBLE_METADATA = {'status': ['preview'],
9 'supported_by': 'community',
10 'metadata_version': '1.1'}
11
12 DOCUMENTATION = '''
13 ---
14 module: fmgr_pm_config_upgrade
15 short_description: Upgrade an ADOM to the next version.
16 version_added: "2.1.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 options:
20 adom:
21 description: The parameter (adom) in requested url.
22 type: str
23 required: true
24 '''
25
26 EXAMPLES = '''
27 - name: Example playbook (generated based on argument schema)
28 hosts: fortimanagers
29 connection: httpapi
30 gather_facts: false
31 tasks:
32 - name: Upgrade an ADOM to the next version.
33 fortinet.fortimanager.fmgr_pm_config_upgrade:
34 # workspace_locking_adom: <global or your adom name>
35 adom: <your own value>
36 '''
37
38 RETURN = '''
39 meta:
40 description: The result of the request.
41 type: dict
42 returned: always
43 contains:
44 request_url:
45 description: The full url requested.
46 returned: always
47 type: str
48 sample: /sys/login/user
49 response_code:
50 description: The status of api request.
51 returned: always
52 type: int
53 sample: 0
54 response_data:
55 description: The api response.
56 type: list
57 returned: always
58 response_message:
59 description: The descriptive message of the api response.
60 type: str
61 returned: always
62 sample: OK.
63 system_information:
64 description: The information of the target system.
65 type: dict
66 returned: always
67 rc:
68 description: The status the request.
69 type: int
70 returned: always
71 sample: 0
72 version_check_warning:
73 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
74 type: list
75 returned: complex
76 '''
77 from ansible.module_utils.basic import AnsibleModule
78 from ansible.module_utils.connection import Connection
79 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
80 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
81
82
83 def main():
84 urls_list = [
85 '/pm/config/adom/{adom}/_upgrade',
86 '/pm/config/global/_upgrade'
87 ]
88 module_arg_spec = {
89 'adom': {'required': True, 'type': 'str'}
90 }
91
92 module_option_spec = get_module_arg_spec('exec')
93 module_arg_spec.update(module_option_spec)
94 check_galaxy_version(module_arg_spec)
95 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'pm_config_upgrade'),
96 supports_check_mode=True)
97 if not module._socket_path:
98 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
99 connection = Connection(module._socket_path)
100 fmgr = NAPIManager('exec', module_arg_spec, urls_list,
101 None, 'data', module, connection)
102 fmgr.process_exec()
103 module.exit_json(meta=module.params)
104
105
106 if __name__ == '__main__':
107 main()