Debian Codegraph @

ansible_collections/fortinet/fortimanager/plugins/modules/fmgr_switchcontroller_switchprofile.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_switchcontroller_switchprofile
15 short_description: Configure FortiSwitch switch profile.
16 version_added: "2.12.0"
17 extends_documentation_fragment:
18 - fortinet.fortimanager.general
19 - fortinet.fortimanager.general.full_crud
20 options:
21 revision_note:
22 description: The change note that can be specified when an object is created or updated.
23 type: str
24 adom:
25 description: The parameter (adom) in requested url.
26 type: str
27 required: true
28 switchcontroller_switchprofile:
29 description: The top level parameters set.
30 required: false
31 type: dict
32 suboptions:
33 login:
34 type: str
35 description: Enable/disable FortiSwitch serial console.
36 choices: ['disable', 'enable']
37 login_passwd:
38 aliases: ['login-passwd']
39 type: list
40 elements: str
41 description: Login password of managed FortiSwitch.
42 login_passwd_override:
43 aliases: ['login-passwd-override']
44 type: str
45 description: Enable/disable overriding the admin administrator password for a managed FortiSwitch with the FortiGate admin administrato...
46 choices: ['disable', 'enable']
47 name:
48 type: str
49 description: FortiSwitch Profile name.
50 required: true
51 revision_backup_on_logout:
52 aliases: ['revision-backup-on-logout']
53 type: str
54 description: Enable/disable automatic revision backup upon logout from FortiSwitch.
55 choices: ['disable', 'enable']
56 revision_backup_on_upgrade:
57 aliases: ['revision-backup-on-upgrade']
58 type: str
59 description: Enable/disable automatic revision backup upon FortiSwitch image upgrade.
60 choices: ['disable', 'enable']
61 '''
62
63 EXAMPLES = '''
64 - name: Example playbook (generated based on argument schema)
65 hosts: fortimanagers
66 connection: httpapi
67 gather_facts: false
68 tasks:
69 - name: Configure FortiSwitch switch profile.
70 fortinet.fortimanager.fmgr_switchcontroller_switchprofile:
71 # workspace_locking_adom: <global or your adom name>
72 adom: <your own value>
73 state: present # <value in [present, absent]>
74 switchcontroller_switchprofile:
75 name: "your value" # Required variable, string
76 # login: <value in [disable, enable]>
77 # login_passwd: <list or string>
78 # login_passwd_override: <value in [disable, enable]>
79 # revision_backup_on_logout: <value in [disable, enable]>
80 # revision_backup_on_upgrade: <value in [disable, enable]>
81 '''
82
83 RETURN = '''
84 meta:
85 description: The result of the request.
86 type: dict
87 returned: always
88 contains:
89 request_url:
90 description: The full url requested.
91 returned: always
92 type: str
93 sample: /sys/login/user
94 response_code:
95 description: The status of api request.
96 returned: always
97 type: int
98 sample: 0
99 response_data:
100 description: The api response.
101 type: list
102 returned: always
103 response_message:
104 description: The descriptive message of the api response.
105 type: str
106 returned: always
107 sample: OK.
108 system_information:
109 description: The information of the target system.
110 type: dict
111 returned: always
112 rc:
113 description: The status the request.
114 type: int
115 returned: always
116 sample: 0
117 version_check_warning:
118 description: Warning if the parameters used in the playbook are not supported by the current FortiManager version.
119 type: list
120 returned: complex
121 '''
122 from ansible.module_utils.basic import AnsibleModule
123 from ansible.module_utils.connection import Connection
124 from ansible_collections.fortinet.fortimanager.plugins.module_utils.napi import NAPIManager, check_galaxy_version, check_parameter_bypass
125 from ansible_collections.fortinet.fortimanager.plugins.module_utils.common import get_module_arg_spec
126
127
128 def main():
129 urls_list = [
130 '/pm/config/adom/{adom}/obj/switch-controller/switch-profile',
131 '/pm/config/global/obj/switch-controller/switch-profile'
132 ]
133 module_arg_spec = {
134 'adom': {'required': True, 'type': 'str'},
135 'revision_note': {'type': 'str'},
136 'switchcontroller_switchprofile': {
137 'type': 'dict', 'v_range': [['7.6.4', '']],
138 'options': {
139 'login': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
140 'login-passwd': {'v_range': [['7.6.4', '']], 'no_log': True, 'type': 'list', 'elements': 'str'},
141 'login-passwd-override': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
142 'name': {'v_range': [['7.6.4', '']], 'required': True, 'type': 'str'},
143 'revision-backup-on-logout': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'},
144 'revision-backup-on-upgrade': {'v_range': [['7.6.4', '']], 'choices': ['disable', 'enable'], 'type': 'str'}
145 }
146 }
147 }
148
149 module_option_spec = get_module_arg_spec('full crud')
150 module_arg_spec.update(module_option_spec)
151 check_galaxy_version(module_arg_spec)
152 module = AnsibleModule(argument_spec=check_parameter_bypass(module_arg_spec, 'switchcontroller_switchprofile'),
153 supports_check_mode=True)
154 if not module._socket_path:
155 module.fail_json(msg='MUST RUN IN HTTPAPI MODE')
156 connection = Connection(module._socket_path)
157 fmgr = NAPIManager('full crud', module_arg_spec, urls_list,
158 'name', 'data', module, connection)
159 fmgr.process_crud()
160 module.exit_json(meta=module.params)
161
162
163 if __name__ == '__main__':
164 main()