Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_um_image_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_um_image_upgrade
15 short_description: The older API for updating the firmware of specific device.
16 version_added: "2.2.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 options:
20 um_image_upgrade:
21 description: The top level parameters set.
22 required: false
23 type: dict
24 suboptions:
25 adom:
26 type: str
27 description: Adom.
28 create_task:
29 type: str
30 description: Create task.
31 device:
32 type: list
33 elements: dict
34 description: Device.
35 suboptions:
36 name:
37 type: str
38 description: Name.
39 vdom:
40 type: str
41 description: Vdom.
42 flags:
43 type: str
44 description: Flags.
45 choices: ['f_boot_alt_partition', 'f_skip_retrieve', 'f_skip_multi_steps',
46 'f_skip_fortiguard_img', 'f_preview']
47 image:
48 type: dict
49 description: Image.
50 suboptions:
51 build:
52 type: str
53 description: Build.
54 id:
55 type: raw
56 description: (list) Id.
57 model:
58 type: str
59 description: Model.
60 release:
61 type: str
62 description: Release.
63 schedule_time:
64 type: str
65 description: Schedule time.
66 '''
67
68 EXAMPLES = '''
69 - name: Example playbook (generated based on argument schema)
70 hosts: fortimanagers
71 connection: httpapi
72 gather_facts: false
73 tasks:
74 - name: The older API for updating the firmware of specific device.
75 fortinet.fortimanager.fmgr_um_image_upgrade:
76 # workspace_locking_adom: <global or your adom name>
77 um_image_upgrade:
78 # adom: <string>
79 # create_task: <string>
80 # device:
81 # - name: <string>
82 # vdom: <string>
83 # flags: <value in [f_boot_alt_partition, f_skip_retrieve, f_skip_multi_steps, ...]>
84 # image:
85 # build: <string>
86 # id: <list or string>
87 # model: <string>
88 # release: <string>
89 # schedule_time: <string>
90 '''
91
92 RETURN = '''
93 meta:
94 description: The result of the request.
95 type: dict
96 returned: always
97 contains:
98 request_url:
99 description: The full url requested.
100 returned: always
101 type: str
102 sample: /sys/login/user
103 response_code:
104 description: The status of api request.
105 returned: always
106 type: int
107 sample: 0
108 response_data:
109 description: The api response.
110 type: list
111 returned: always
112 response_message:
113 description: The descriptive message of the api response.
114 type: str
115 returned: always
116 sample: OK.
117 system_information:
118 description: The information of the target system.
119 type: dict
120 returned: always
121 rc:
122 description: The status the request.
123 type: int
124 returned: always
125 sample: 0
126 version_check_warning:
127 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
128 type: list
129 returned: complex
130 '''
131 from ansible.module_utils.basic import AnsibleModule
132 from ansible.module_utils.connection import Connection
133 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
134 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
135
136
137 def main():
138 urls_list = [
139 '/um/image/upgrade'
140 ]
141 module_arg_spec = {
142 'um_image_upgrade': {
143 'type': 'dict', 'v_range': [['7.2.1', '']],
144 'options': {
145 'adom': {'v_range': [['7.2.1', '']], 'type': 'str'},
146 'create_task': {'v_range': [['7.2.1', '']], 'type': 'str'},
147 'device': {
148 'v_range': [['7.2.1', '']],
149 'type': 'list',
150 'options': {'name': {'v_range': [['7.2.1', '']], 'type': 'str'}, 'vdom': {'v_range': [['7.2.1', '']], 'type': 'str'}},
151 'elements': 'dict'
152 },
153 'flags': {
154 'v_range': [['7.2.1', '']],
155 'choices': ['f_boot_alt_partition', 'f_skip_retrieve', 'f_skip_multi_steps', 'f_skip_fortiguard_img', 'f_preview'],
156 'type': 'str'
157 },
158 'image': {
159 'v_range': [['7.2.1', '']],
160 'type': 'dict',
161 'options': {
162 'build': {'v_range': [['7.2.1', '']], 'type': 'str'},
163 'id': {'v_range': [['7.2.1', '']], 'type': 'raw'},
164 'model': {'v_range': [['7.2.1', '']], 'type': 'str'},
165 'release': {'v_range': [['7.2.1', '']], 'type': 'str'}
166 }
167 },
168 'schedule_time': {'v_range': [['7.2.1', '']], 'type': 'str'}
169 }
170 }
171 }
172
173 module_option_spec = get_module_arg_spec('exec')
174 module_arg_spec.update(module_option_spec)
175 check_galaxy_version(module_arg_spec)
176 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'um_image_upgrade'),
177 supports_check_mode=True)
178 if not module._socket_path:
179 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
180 connection = Connection(module._socket_path)
181 fmgr = NAPIManager('exec', module_arg_spec, urls_list,
182 None, 'data', module, connection)
183 fmgr.process_exec()
184 module.exit_json(meta=module.params)
185
186
187 if __name__ == '__main__':
188 main()