Debian Codegraph @

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