Browse code

Deprecate citrix/netscaler module (#28280)

* Deprecate citrix/netscaler module

* renamed: netscaler.py -> _netscaler.py

* Fix legacy files list

George Nikolopoulos authored on 2017/08/26 02:51:15
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,200 @@
0
+#!/usr/bin/python
1
+# -*- coding: utf-8 -*-
2
+
3
+# (c) 2013, Nandor Sivok <nandor@gawker.com>
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
+
10
+ANSIBLE_METADATA = {'metadata_version': '1.1',
11
+                    'status': ['deprecated'],
12
+                    'supported_by': 'community'}
13
+
14
+
15
+DOCUMENTATION = '''
16
+---
17
+module: netscaler
18
+version_added: "1.1"
19
+short_description: Manages Citrix NetScaler entities
20
+description:
21
+     - Manages Citrix NetScaler server and service entities.
22
+deprecated: In 2.4 use M(netscaler_service) and M(netscaler_server) instead.
23
+options:
24
+  nsc_host:
25
+    description:
26
+      - hostname or ip of your netscaler
27
+    required: true
28
+    default: null
29
+    aliases: []
30
+  nsc_protocol:
31
+    description:
32
+      - protocol used to access netscaler
33
+    required: false
34
+    default: https
35
+    aliases: []
36
+  user:
37
+    description:
38
+      - username
39
+    required: true
40
+    default: null
41
+    aliases: []
42
+  password:
43
+    description:
44
+      - password
45
+    required: true
46
+    default: null
47
+    aliases: []
48
+  action:
49
+    description:
50
+      - the action you want to perform on the entity
51
+    required: false
52
+    default: disable
53
+    choices: ["enable", "disable"]
54
+    aliases: []
55
+  name:
56
+    description:
57
+      - name of the entity
58
+    required: true
59
+    default: hostname
60
+    aliases: []
61
+  type:
62
+    description:
63
+      - type of the entity
64
+    required: false
65
+    default: server
66
+    choices: ["server", "service"]
67
+    aliases: []
68
+  validate_certs:
69
+    description:
70
+      - If C(no), SSL certificates for the target url will not be validated. This should only be used
71
+        on personally controlled sites using self-signed certificates.
72
+    required: false
73
+    default: 'yes'
74
+    choices: ['yes', 'no']
75
+
76
+requirements: []
77
+author: "Nandor Sivok (@dominis)"
78
+'''
79
+
80
+EXAMPLES = '''
81
+# Disable the server
82
+- netscaler:
83
+    nsc_host: nsc.example.com
84
+    user: apiuser
85
+    password: apipass
86
+
87
+# Enable the server
88
+- netscaler:
89
+    nsc_host: nsc.example.com
90
+    user: apiuser
91
+    password: apipass
92
+    action: enable
93
+
94
+# Disable the service local:8080
95
+- netscaler:
96
+    nsc_host: nsc.example.com
97
+    user: apiuser
98
+    password: apipass
99
+    name: 'local:8080'
100
+    type: service
101
+    action: disable
102
+'''
103
+
104
+
105
+import base64
106
+import json
107
+import socket
108
+import traceback
109
+
110
+from ansible.module_utils.basic import AnsibleModule
111
+from ansible.module_utils.six.moves.urllib.parse import urlencode
112
+from ansible.module_utils._text import to_native
113
+from ansible.module_utils.urls import fetch_url
114
+
115
+
116
+class netscaler(object):
117
+
118
+    _nitro_base_url = '/nitro/v1/'
119
+
120
+    def __init__(self, module):
121
+        self.module = module
122
+
123
+    def http_request(self, api_endpoint, data_json={}):
124
+        request_url = self._nsc_protocol + '://' + self._nsc_host + self._nitro_base_url + api_endpoint
125
+
126
+        data_json = urlencode(data_json)
127
+        if not len(data_json):
128
+            data_json = None
129
+
130
+        auth = base64.encodestring('%s:%s' % (self._nsc_user, self._nsc_pass)).replace('\n', '').strip()
131
+        headers = {
132
+            'Authorization': 'Basic %s' % auth,
133
+            'Content-Type' : 'application/x-www-form-urlencoded',
134
+        }
135
+
136
+        response, info = fetch_url(self.module, request_url, data=data_json, headers=headers)
137
+
138
+        return json.load(response)
139
+
140
+    def prepare_request(self, action):
141
+        resp = self.http_request(
142
+            'config',
143
+            {
144
+                "object":
145
+                {
146
+                    "params": {"action": action},
147
+                    self._type: {"name": self._name}
148
+                }
149
+            }
150
+        )
151
+
152
+        return resp
153
+
154
+
155
+def core(module):
156
+    n = netscaler(module)
157
+    n._nsc_host = module.params.get('nsc_host')
158
+    n._nsc_user = module.params.get('user')
159
+    n._nsc_pass = module.params.get('password')
160
+    n._nsc_protocol = module.params.get('nsc_protocol')
161
+    n._name = module.params.get('name')
162
+    n._type = module.params.get('type')
163
+    action = module.params.get('action')
164
+
165
+    r = n.prepare_request(action)
166
+
167
+    return r['errorcode'], r
168
+
169
+
170
+def main():
171
+
172
+    module = AnsibleModule(
173
+        argument_spec = dict(
174
+            nsc_host = dict(required=True),
175
+            nsc_protocol = dict(default='https'),
176
+            user = dict(required=True),
177
+            password = dict(required=True, no_log=True),
178
+            action = dict(default='enable', choices=['enable','disable']),
179
+            name = dict(default=socket.gethostname()),
180
+            type = dict(default='server', choices=['service', 'server']),
181
+            validate_certs=dict(default='yes', type='bool'),
182
+        )
183
+    )
184
+
185
+    rc = 0
186
+    try:
187
+        rc, result = core(module)
188
+    except Exception as e:
189
+        module.fail_json(msg=to_native(e), exception=traceback.format_exc())
190
+
191
+    if rc != 0:
192
+        module.fail_json(rc=rc, msg=result)
193
+    else:
194
+        result['changed'] = True
195
+        module.exit_json(**result)
196
+
197
+
198
+if __name__ == '__main__':
199
+    main()
0 200
deleted file mode 100644
... ...
@@ -1,199 +0,0 @@
1
-#!/usr/bin/python
2
-# -*- coding: utf-8 -*-
3
-
4
-# (c) 2013, Nandor Sivok <nandor@gawker.com>
5
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
6
-
7
-from __future__ import absolute_import, division, print_function
8
-__metaclass__ = type
9
-
10
-
11
-ANSIBLE_METADATA = {'metadata_version': '1.1',
12
-                    'status': ['preview'],
13
-                    'supported_by': 'community'}
14
-
15
-
16
-DOCUMENTATION = '''
17
-module: netscaler
18
-version_added: "1.1"
19
-short_description: Manages Citrix NetScaler entities
20
-description:
21
-     - Manages Citrix NetScaler server and service entities.
22
-options:
23
-  nsc_host:
24
-    description:
25
-      - hostname or ip of your netscaler
26
-    required: true
27
-    default: null
28
-    aliases: []
29
-  nsc_protocol:
30
-    description:
31
-      - protocol used to access netscaler
32
-    required: false
33
-    default: https
34
-    aliases: []
35
-  user:
36
-    description:
37
-      - username
38
-    required: true
39
-    default: null
40
-    aliases: []
41
-  password:
42
-    description:
43
-      - password
44
-    required: true
45
-    default: null
46
-    aliases: []
47
-  action:
48
-    description:
49
-      - the action you want to perform on the entity
50
-    required: false
51
-    default: disable
52
-    choices: ["enable", "disable"]
53
-    aliases: []
54
-  name:
55
-    description:
56
-      - name of the entity
57
-    required: true
58
-    default: hostname
59
-    aliases: []
60
-  type:
61
-    description:
62
-      - type of the entity
63
-    required: false
64
-    default: server
65
-    choices: ["server", "service"]
66
-    aliases: []
67
-  validate_certs:
68
-    description:
69
-      - If C(no), SSL certificates for the target url will not be validated. This should only be used
70
-        on personally controlled sites using self-signed certificates.
71
-    required: false
72
-    default: 'yes'
73
-    choices: ['yes', 'no']
74
-
75
-requirements: []
76
-author: "Nandor Sivok (@dominis)"
77
-'''
78
-
79
-EXAMPLES = '''
80
-# Disable the server
81
-- netscaler:
82
-    nsc_host: nsc.example.com
83
-    user: apiuser
84
-    password: apipass
85
-
86
-# Enable the server
87
-- netscaler:
88
-    nsc_host: nsc.example.com
89
-    user: apiuser
90
-    password: apipass
91
-    action: enable
92
-
93
-# Disable the service local:8080
94
-- netscaler:
95
-    nsc_host: nsc.example.com
96
-    user: apiuser
97
-    password: apipass
98
-    name: 'local:8080'
99
-    type: service
100
-    action: disable
101
-'''
102
-
103
-
104
-import base64
105
-import json
106
-import socket
107
-import traceback
108
-
109
-from ansible.module_utils.basic import AnsibleModule
110
-from ansible.module_utils.six.moves.urllib.parse import urlencode
111
-from ansible.module_utils._text import to_native
112
-from ansible.module_utils.urls import fetch_url
113
-
114
-
115
-class netscaler(object):
116
-
117
-    _nitro_base_url = '/nitro/v1/'
118
-
119
-    def __init__(self, module):
120
-        self.module = module
121
-
122
-    def http_request(self, api_endpoint, data_json={}):
123
-        request_url = self._nsc_protocol + '://' + self._nsc_host + self._nitro_base_url + api_endpoint
124
-
125
-        data_json = urlencode(data_json)
126
-        if not len(data_json):
127
-            data_json = None
128
-
129
-        auth = base64.encodestring('%s:%s' % (self._nsc_user, self._nsc_pass)).replace('\n', '').strip()
130
-        headers = {
131
-            'Authorization': 'Basic %s' % auth,
132
-            'Content-Type' : 'application/x-www-form-urlencoded',
133
-        }
134
-
135
-        response, info = fetch_url(self.module, request_url, data=data_json, headers=headers)
136
-
137
-        return json.load(response)
138
-
139
-    def prepare_request(self, action):
140
-        resp = self.http_request(
141
-            'config',
142
-            {
143
-                "object":
144
-                {
145
-                    "params": {"action": action},
146
-                    self._type: {"name": self._name}
147
-                }
148
-            }
149
-        )
150
-
151
-        return resp
152
-
153
-
154
-def core(module):
155
-    n = netscaler(module)
156
-    n._nsc_host = module.params.get('nsc_host')
157
-    n._nsc_user = module.params.get('user')
158
-    n._nsc_pass = module.params.get('password')
159
-    n._nsc_protocol = module.params.get('nsc_protocol')
160
-    n._name = module.params.get('name')
161
-    n._type = module.params.get('type')
162
-    action = module.params.get('action')
163
-
164
-    r = n.prepare_request(action)
165
-
166
-    return r['errorcode'], r
167
-
168
-
169
-def main():
170
-
171
-    module = AnsibleModule(
172
-        argument_spec = dict(
173
-            nsc_host = dict(required=True),
174
-            nsc_protocol = dict(default='https'),
175
-            user = dict(required=True),
176
-            password = dict(required=True, no_log=True),
177
-            action = dict(default='enable', choices=['enable','disable']),
178
-            name = dict(default=socket.gethostname()),
179
-            type = dict(default='server', choices=['service', 'server']),
180
-            validate_certs=dict(default='yes', type='bool'),
181
-        )
182
-    )
183
-
184
-    rc = 0
185
-    try:
186
-        rc, result = core(module)
187
-    except Exception as e:
188
-        module.fail_json(msg=to_native(e), exception=traceback.format_exc())
189
-
190
-    if rc != 0:
191
-        module.fail_json(rc=rc, msg=result)
192
-    else:
193
-        result['changed'] = True
194
-        module.exit_json(**result)
195
-
196
-
197
-if __name__ == '__main__':
198
-    main()
... ...
@@ -253,7 +253,7 @@ lib/ansible/modules/network/asa/asa_command.py
253 253
 lib/ansible/modules/network/asa/asa_config.py
254 254
 lib/ansible/modules/network/bigswitch/bigmon_chain.py
255 255
 lib/ansible/modules/network/bigswitch/bigmon_policy.py
256
-lib/ansible/modules/network/citrix/netscaler.py
256
+lib/ansible/modules/network/citrix/_netscaler.py
257 257
 lib/ansible/modules/net_tools/cloudflare_dns.py
258 258
 lib/ansible/modules/network/cumulus/_cl_bond.py
259 259
 lib/ansible/modules/network/cumulus/_cl_img_install.py