Debian Codegraph @

ansible_collections/infoblox/nios_modules/plugins/modules/nios_dtc_monitor_icmp.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_icmp
12 author: "Joachim Buyse (@jbisabel)"
13 version_added: "1.6.0"
14 short_description: Configure Infoblox NIOS DTC ICMP monitors
15 description:
16 - Adds and/or removes instances of DTC ICMP monitor objects from Infoblox NIOS
17 servers. This module manages C(dtc:monitor:icmp) 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 interval:
32 description:
33 - Configures the interval for ICMP health check.
34 type: int
35 default: 5
36 retry_down:
37 description:
38 - Configures the value of how many times the server should appear as
39 down to be treated as dead after it was alive.
40 type: int
41 default: 1
42 retry_up:
43 description:
44 - Configures the value of how many times the server should appear as up
45 to be treated as alive after it was dead.
46 type: int
47 default: 1
48 timeout:
49 description:
50 - Configures the timeout for ICMP health check in seconds.
51 type: int
52 default: 15
53 extattrs:
54 description:
55 - Allows for the configuration of Extensible Attributes on the
56 instance of the object. This argument accepts a set of key / value
57 pairs for configuration.
58 type: dict
59 comment:
60 description:
61 - Configures a text string comment to be associated with the instance
62 of this object. The provided text string will be configured on the
63 object instance.
64 type: str
65 state:
66 description:
67 - Configures the intended state of the instance of the object on
68 the NIOS server. When this value is set to C(present), the object
69 is configured on the device and when this value is set to C(absent)
70 the value is removed (if necessary) from the device.
71 default: present
72 choices:
73 - present
74 - absent
75 type: str
76 '''
77
78 EXAMPLES = '''
79 - name: Configure a DTC ICMP monitor
80 infoblox.nios_modules.nios_dtc_monitor_icmp:
81 name: icmp_monitor
82 port: 8080
83 state: present
84 provider:
85 host: "{{ inventory_hostname_short }}"
86 username: admin
87 password: admin
88 connection: local
89
90 - name: Add a comment to an existing DTC ICMP monitor
91 infoblox.nios_modules.nios_dtc_monitor_icmp:
92 name: icmp_monitor
93 comment: this is a test comment
94 state: present
95 provider:
96 host: "{{ inventory_hostname_short }}"
97 username: admin
98 password: admin
99 connection: local
100
101 - name: Remove a DTC ICMP monitor from the system
102 infoblox.nios_modules.nios_dtc_monitor_icmp:
103 name: icmp_monitor
104 state: absent
105 provider:
106 host: "{{ inventory_hostname_short }}"
107 username: admin
108 password: admin
109 connection: local
110 '''
111
112 RETURN = ''' # '''
113
114 from ansible.module_utils.basic import AnsibleModule
115 from ..module_utils.api import WapiModule
116 from ..module_utils.api import NIOS_DTC_MONITOR_ICMP
117 from ..module_utils.api import normalize_ib_spec
118
119
120 def main():
121 ''' Main entry point for module execution
122 '''
123
124 ib_spec = dict(
125 name=dict(required=True, ib_req=True),
126
127 interval=dict(type='int', default=5),
128 retry_down=dict(type='int', default=1),
129 retry_up=dict(type='int', default=1),
130 timeout=dict(type='int', default=15),
131
132 extattrs=dict(type='dict'),
133 comment=dict(),
134 )
135
136 argument_spec = dict(
137 provider=dict(required=True),
138 state=dict(default='present', choices=['present', 'absent'])
139 )
140
141 argument_spec.update(normalize_ib_spec(ib_spec))
142 argument_spec.update(WapiModule.provider_spec)
143
144 module = AnsibleModule(argument_spec=argument_spec,
145 supports_check_mode=True)
146
147 wapi = WapiModule(module)
148 result = wapi.run(NIOS_DTC_MONITOR_ICMP, ib_spec)
149
150 module.exit_json(**result)
151
152
153 if __name__ == '__main__':
154 main()