Debian Codegraph @

ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_sip.py

raw symbols SCIP
1 #!/usr/bin/python
2 # Copyright (c) 2018-2019 Red Hat, Inc.
3 # Copyright (c) 2020 Infoblox, Inc.
4 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 from __future__ import absolute_import, division, print_function
7 __metaclass__ = type
8
9 DOCUMENTATION = '''
10 ---
11 module: nios_dtc_monitor_sip
12 author: "Joachim Buyse (@jbisabel)"
13 version_added: "1.6.0"
14 short_description: Configure Infoblox NIOS DTC SIP monitors
15 description:
16 - Adds and/or removes instances of DTC SIP monitor objects from Infoblox NIOS
17 servers. This module manages C(dtc:monitor:sip) objects using the Infoblox
18 WAPI interface over REST.
19 requirements:
20 - infoblox-client
21 extends_documentation_fragment: infoblox.nios_modules.nios
22 notes:
23 - This module supports C(check_mode).
24 options:
25 name:
26 description:
27 - Configures the display name for this DTC monitor. Values with leading
28 or trailing white space are not valid for this field.
29 required: true
30 type: str
31 port:
32 description:
33 - Configures the port value for SIP requests.
34 type: int
35 default: 5060
36 ciphers:
37 description:
38 - Configures an optional cipher list for the secure TLS/SIPS connection.
39 type: str
40 client_cert:
41 description:
42 - Configures an optional client certificate, supplied in TLS or SIPS mode
43 if present.
44 type: str
45 request:
46 description:
47 - Configures the SIP request to send
48 type: str
49 result:
50 description:
51 - Configures the type of the expected result
52 type: str
53 choices:
54 - ANY
55 - CODE_IS
56 - CODE_IS_NOT
57 default: ANY
58 result_code:
59 description:
60 - Configures the expected return code
61 type: int
62 default: 200
63 transport:
64 description:
65 - Configures the transport layer protocol to use for the SIP check
66 type: str
67 choices:
68 - SIPS
69 - TCP
70 - TLS
71 - UDP
72 default: TCP
73 validate_cert:
74 description:
75 - Configures whether the validation of the remote server's certificate is
76 enabled.
77 type: bool
78 default: true
79 interval:
80 description:
81 - Configures the interval for SIP health check.
82 type: int
83 default: 5
84 retry_down:
85 description:
86 - Configures the value of how many times the server should appear as
87 down to be treated as dead after it was alive.
88 type: int
89 default: 1
90 retry_up:
91 description:
92 - Configures the value of how many times the server should appear as up
93 to be treated as alive after it was dead.
94 type: int
95 default: 1
96 timeout:
97 description:
98 - Configures the timeout for SIP health check in seconds.
99 type: int
100 default: 15
101 extattrs:
102 description:
103 - Allows for the configuration of Extensible Attributes on the
104 instance of the object. This argument accepts a set of key / value
105 pairs for configuration.
106 type: dict
107 comment:
108 description:
109 - Configures a text string comment to be associated with the instance
110 of this object. The provided text string will be configured on the
111 object instance.
112 type: str
113 state:
114 description:
115 - Configures the intended state of the instance of the object on
116 the NIOS server. When this value is set to C(present), the object
117 is configured on the device and when this value is set to C(absent)
118 the value is removed (if necessary) from the device.
119 default: present
120 choices:
121 - present
122 - absent
123 type: str
124 '''
125
126 EXAMPLES = '''
127 - name: Configure a DTC SIP monitor
128 infoblox.nios_modules.nios_dtc_monitor_sip:
129 name: sip_monitor
130 state: present
131 provider:
132 host: "{{ inventory_hostname_short }}"
133 username: admin
134 password: admin
135 connection: local
136
137 - name: Add a comment to an existing DTC SIP monitor
138 infoblox.nios_modules.nios_dtc_monitor_sip:
139 name: sip_monitor
140 comment: this is a test comment
141 state: present
142 provider:
143 host: "{{ inventory_hostname_short }}"
144 username: admin
145 password: admin
146 connection: local
147
148 - name: Remove a DTC SIP monitor from the system
149 infoblox.nios_modules.nios_dtc_monitor_sip:
150 name: sip_monitor
151 state: absent
152 provider:
153 host: "{{ inventory_hostname_short }}"
154 username: admin
155 password: admin
156 connection: local
157 '''
158
159 RETURN = ''' # '''
160
161 from ansible.module_utils.basic import AnsibleModule
162 from ..module_utils.api import WapiModule
163 from ..module_utils.api import NIOS_DTC_MONITOR_SIP
164 from ..module_utils.api import normalize_ib_spec
165
166
167 def main():
168 ''' Main entry point for module execution
169 '''
170
171 ib_spec = dict(
172 name=dict(required=True, ib_req=True),
173
174 port=dict(type='int', default=5060),
175 ciphers=dict(type='str'),
176 client_cert=dict(type='str'),
177 request=dict(type='str'),
178 result=dict(default='ANY', choices=['ANY', 'CODE_IS', 'CODE_IS_NOT']),
179 result_code=dict(type='int', default=200),
180 transport=dict(default='TCP', choices=['SIPS', 'TCP', 'TLS', 'UDP']),
181 validate_cert=dict(type='bool', default=True),
182 interval=dict(type='int', default=5),
183 retry_down=dict(type='int', default=1),
184 retry_up=dict(type='int', default=1),
185 timeout=dict(type='int', default=15),
186
187 extattrs=dict(type='dict'),
188 comment=dict(),
189 )
190
191 argument_spec = dict(
192 provider=dict(required=True),
193 state=dict(default='present', choices=['present', 'absent'])
194 )
195
196 argument_spec.update(normalize_ib_spec(ib_spec))
197 argument_spec.update(WapiModule.provider_spec)
198
199 module = AnsibleModule(argument_spec=argument_spec,
200 supports_check_mode=True)
201
202 wapi = WapiModule(module)
203 result = wapi.run(NIOS_DTC_MONITOR_SIP, ib_spec)
204
205 module.exit_json(**result)
206
207
208 if __name__ == '__main__':
209 main()