2929description:
3030 - Gather information about CDP DE Workspaces
3131author:
32- - "Webster Mudge (@wmudge)"
33- - "Dan Chaffelson (@chaffelson)"
32+ - "Curtis Howard (@curtishoward)"
3433 - "Alan Silva (@acsjumpi)"
3534requirements:
3635 - cdpy
3736options:
38- id :
37+ name :
3938 description:
40- - If a name is provided, that Data Warehouse Cluster will be described.
41- - environment must be provided if using name to retrieve a Cluster
39+ - If a name is provided, that DE service will be described (if it exists)
40+ - Note that there should be only 1 or 0 (non-deleted) services with a given name
4241 type: str
4342 required: False
4443 aliases:
4544 - name
4645 environment:
4746 description:
48- - The name of the Environment in which to find and describe the Data Warehouse Clusters.
49- - Required with name to retrieve a Cluster
47+ - The name of the Environment in which to find and describe the DE service(s).
5048 type: str
5149 required: False
5250 aliases:
6260# List basic information about all DE Services
6361- cloudera.cloud.de_info:
6462
63+ # List basic information about all DE Services within a given environment
64+ - cloudera.cloud.de_info:
65+ environment: example-environment
66+
6567# Gather detailed information about a named DE Service
6668- cloudera.cloud.de_info:
6769 name: example-service
70+
71+ # Gather detailed information about a named DE Service within a particular environment
72+ - cloudera.cloud.de_info:
73+ name: example-service
74+ environment: example-environment
6875'''
6976
7077RETURN = r'''
71- TODO..
78+ services:
79+ description: List of DE service descriptions
80+ type: list
81+ returned: always
82+ elements: complex
83+ contains:
84+ clusterId:
85+ description: Cluster Id of the CDE Service.
86+ returned: always
87+ type: str
88+ creatorEmail:
89+ description: Email Address of the CDE creator.
90+ returned: always
91+ type: str
92+ enablingTime:
93+ description: Timestamp of service enabling.
94+ returned: always
95+ type: str
96+ environmentName:
97+ description: CDP Environment Name.
98+ returned: always
99+ type: str
100+ name:
101+ description: Name of the CDE Service.
102+ returned: always
103+ type: str
104+ status:
105+ description: Status of the CDE Service.
106+ returned: always
107+ type: str
108+ chartValueOverrides:
109+ description: Status of the CDE Service.
110+ returned: if full service description
111+ type: array
112+ elements: complex
113+ contains:
114+ ChartValueOverridesResponse:
115+ type: list
116+ returned: always
117+ contains:
118+ chartName:
119+ description: Name of the chart that has to be overridden.
120+ returned: always
121+ type: str
122+ overrides:
123+ description: Space separated key value-pairs for overriding chart values (colon separated)
124+ returned: always
125+ type: str
126+ cloudPlatform:
127+ description: The cloud platform where the CDE service is enabled.
128+ returned: if full service description
129+ type: str
130+ clusterFqdn:
131+ description: FQDN of the CDE service.
132+ returned: if full service description
133+ type: str
134+ creatorCrn:
135+ description: CRN of the creator.
136+ returned: if full service description
137+ type: str
138+ dataLakeAtlasUIEndpoint:
139+ description: Endpoint of Data Lake Atlas.E
140+ returned: if full service description
141+ type: str
142+ dataLakeFileSystems:
143+ description: The Data lake file system.
144+ returned: if full service description
145+ type: str
146+ environmentCrn:
147+ description: CRN of the environment.
148+ returned: if full service description
149+ type: str
150+ logLocation:
151+ description: Location for the log files of jobs.
152+ returned: if full service description
153+ type: str
154+ resources:
155+ description: Resources details of CDE Service.
156+ returned: if full service description
157+ type: complex
158+ contains:
159+ ServiceResources:
160+ description: Object to store resources for a CDE service.
161+ returned: always
162+ type: complex
163+ contains:
164+ initial_instances:
165+ description: Initial instances for the CDE service.
166+ returned: always
167+ type: str
168+ initial_spot_instances:
169+ description: Initial Spot Instances for the CDE Service.
170+ returned: always
171+ type: str
172+ instance_type:
173+ description: Instance type of the CDE service.
174+ returned: always
175+ type: str
176+ max_instances:
177+ description: Maximum instances for the CDE service.
178+ returned: always
179+ type: str
180+ max_spot_instances:
181+ description: Maximum Number of Spot instances.
182+ returned: always
183+ type: str
184+ min_instances:
185+ description: Minimum Instances for the CDE service.
186+ returned: always
187+ type: str
188+ min_spot_instances:
189+ description: Minimum number of spot instances for the CDE service.
190+ returned: always
191+ type: str
192+ root_vol_size:
193+ description: Root Volume Size.
194+ returned: always
195+ type: str
196+ tenantId:
197+ description: CDP tenant ID.
198+ returned: if full service description
199+ type: str
72200'''
73201
74202
@@ -78,6 +206,7 @@ def __init__(self, module):
78206
79207 # Set variables
80208 self .name = self ._get_param ('name' )
209+ self .env = self ._get_param ('environment' )
81210
82211 # Initialize return values
83212 self .services = []
@@ -87,18 +216,26 @@ def __init__(self, module):
87216
88217 @CdpModule ._Decorators .process_debug
89218 def process (self ):
219+ service_list = self .cdpy .de .list_services (remove_deleted = True )
90220 if self .name :
91- for service in self .cdpy .de .list_services (remove_deleted = True ):
92- if service ['name' ] == self .name :
93- self .services .append (self .cdpy .de .describe_service (service ['clusterId' ]))
221+ name_match = list (filter (lambda s : s ['name' ] == self .name , service_list ))
222+ if self .env :
223+ env_match = list (filter (lambda s : s ['environmentName' ] == self .env , name_match ))
224+ if env_match :
225+ self .services .append (self .cdpy .de .describe_service (env_match [0 ]['clusterId' ]))
226+ elif name_match :
227+ self .services .append (self .cdpy .de .describe_service (name_match [0 ]['clusterId' ]))
228+ elif self .env :
229+ env_match = list (filter (lambda s : s ['environmentName' ] == self .env , service_list ))
230+ self .services .extend (env_match )
94231 else :
95- self .services = self .cdpy .de .list_services (remove_deleted = True )
96-
232+ self .services .extend (service_list )
97233
98234def main ():
99235 module = AnsibleModule (
100236 argument_spec = CdpModule .argument_spec (
101- name = dict (required = False , type = 'str' , aliases = ['workspace' ])
237+ name = dict (required = False , type = 'str' , aliases = ['workspace' ]),
238+ environment = dict (required = False , type = 'str' , aliases = ['env' ])
102239 ),
103240 supports_check_mode = True
104241 )
0 commit comments