forked from cloudera-labs/cloudera.cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatalake_info.py
310 lines (288 loc) · 9.05 KB
/
datalake_info.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright 2021 Cloudera, Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ansible.module_utils.basic import AnsibleModule
from ansible_collections.cloudera.cloud.plugins.module_utils.cdp_common import CdpModule
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = r'''
---
module: datalake_info
short_description: Gather information about CDP Datalakes
description:
- Gather information about CDP Datalakes
author:
- "Webster Mudge (@wmudge)"
- "Dan Chaffelson (@chaffelson)"
requirements:
- cdpy
options:
name:
description:
- If a name is given, that Datalake will be described.
- If no name is given, all Datalakes will be listed and (optionally) constrained by the C(environment) parameter.
type: str
required: False
aliases:
- datalake
environment:
description:
- The name of the Environment in which to find and describe the Datalake.
type: str
required: False
aliases:
- env
extends_documentation_fragment:
- cloudera.cloud.cdp_sdk_options
- cloudera.cloud.cdp_auth_options
'''
EXAMPLES = r'''
# Note: These examples do not set authentication details.
# List basic information about all Datalakes
- cloudera.cloud.datalake_info:
# Gather detailed information about a named Datalake
- cloudera.cloud.datalake_info:
name: example-datalake
# Gather detailed information about the Datalake in an Environment
- cloudera.cloud.datalake_info:
environment: example-env
'''
RETURN = r'''
---
datalakes:
description: The information about the named Datalake or Datalakes
type: list
returned: on success
elements: complex
contains:
awsConfiguration:
description: AWS-specific configuration details.
returned: when supported
type: dict
contains:
instanceProfile:
description: The instance profile used for the ID Broker instance.
type: str
returned: always
azureConfiguration:
description: Azure-specific environment configuration information.
returned: when supported
type: dict
contains:
managedIdentity:
description: The managed identity used for the ID Broker instance.
type: str
returned: always
cloudPlatform:
description: Cloud provider of the Datalake.
returned: when supported
type: str
sample:
- AWS
- AZURE
clouderaManager:
description: The Cloudera Manager details.
returned: when supported
type: dict
contains:
clouderaManagerRepositoryURL:
description: Cloudera Manager repository URL.
type: str
returned: always
clouderaManagerServerURL:
description: Cloudera Manager server URL.
type: str
returned: when supported
version:
description: Cloudera Manager version.
type: str
returned: always
sample: 7.2.1
creationDate:
description: The timestamp when the Datalake was created.
returned: when supported
type: str
sample: 2020-09-23T11:33:50.847000+00:00
credentialCrn:
description: CRN of the CDP Credential.
returned: when supported
type: str
crn:
description: CRN value for the Datalake.
returned: always
type: str
datalakeName:
description: Name of the Datalake.
returned: always
type: str
endpoints:
description: Details for the exposed service API endpoints of the Datalake.
returned: when supported
type: dict
contains:
endpoints:
description: The exposed API endpoints.
returned: always
type: list
elements: dict
contains:
displayName:
description: User-friendly name of the exposed service.
returned: always
type: str
sample: Atlas
knoxService:
description: The related Knox entry for the service.
returned: always
type: str
sample: ATLAS_API
mode:
description: The Single Sign-On (SSO) mode for the service.
returned: always
type: str
sample: PAM
open:
description: Flag for the access status of the service.
returned: always
type: bool
serviceName:
description: The name of the exposed service.
returned: always
type: str
sample: ATLAS_SERVER
serviceUrl:
description: The server URL for the exposed service’s API.
returned: always
type: str
sample: "https://some.domain/a-datalake/endpoint"
environmentCrn:
description: CRN of the associated Environment.
returned: when supported
type: str
instanceGroups:
description: The instance details of the Datalake.
returned: when supported
type: list
elements: complex
contains:
instances:
description: Details about the instances.
returned: always
type: list
elements: dict
contains:
id:
description: The identifier of the instance.
returned: always
type: str
sample: i-00b58f27be4e7ab9f
state:
description: The state of the instance.
returned: always
type: str
sample: HEALTHY
name:
description: Name of the instance group associated with the instances.
returned: always
type: str
sample: idbroker
productVersions:
description: The product versions.
returned: when supported
type: list
elements: dict
contains:
name:
description: The name of the product.
returned: always
type: str
sample: FLINK
version:
description: The version of the product.
returned: always
type: str
sample: 1.10.0-csa1.2.1.0-cdh7.2.1.0-240-4844562
region:
description: The region of the Datalake.
returned: when supported
type: str
status:
description: The status of the Datalake.
returned: when supported
type: str
sample:
- EXTERNAL_DATABASE_START_IN_PROGRESS
- START_IN_PROGRESS
- RUNNING
- EXTERNAL_DATABASE_START_IN_PROGRESS
- START_IN_PROGRESS
- EXTERNAL_DATABASE_STOP_IN_PROGRESS
- STOP_IN_PROGRESS
- STOPPED
- REQUESTED
- EXTERNAL_DATABASE_CREATION_IN_PROGRESS
- STACK_CREATION_IN_PROGRESS
- EXTERNAL_DATABASE_DELETION_IN_PROGRESS
- STACK_DELETION_IN_PROGRESS
- PROVISIONING_FAILED
statusReason:
description: An explanation of the status.
returned: when supported
type: str
sample: Datalake is running
sdk_out:
description: Returns the captured CDP SDK log.
returned: when supported
type: str
sdk_out_lines:
description: Returns a list of each line of the captured CDP SDK log.
returned: when supported
type: list
elements: str
'''
class DatalakeInfo(CdpModule):
def __init__(self, module):
super(DatalakeInfo, self).__init__(module)
# Set variables
self.name = self._get_param('name')
self.env = self._get_param('environment')
# Initialize return values
self.datalakes = []
# Execute logic process
self.process()
@CdpModule._Decorators.process_debug
def process(self):
if self.name:
datalake_single = self.cdpy.datalake.describe_datalake(self.name)
if datalake_single is not None:
self.datalakes.append(datalake_single)
else:
self.datalakes = self.cdpy.datalake.describe_all_datalakes(self.env)
def main():
module = AnsibleModule(
argument_spec=CdpModule.argument_spec(
name=dict(required=False, type='str', aliases=['datalake']),
environment=dict(required=False, type='str', aliases=['env'])
),
supports_check_mode=True
)
result = DatalakeInfo(module)
output = dict(changed=False, datalakes=result.datalakes)
if result.debug:
output.update(sdk_out=result.log_out, sdk_out_lines=result.log_lines)
module.exit_json(**output)
if __name__ == '__main__':
main()