3434requirements:
3535 - cdpy
3636options:
37- id :
37+ cluster_id :
3838 description:
39- - If a name is provided, that Data Warehouse Cluster will be described .
40- - environment must be provided if using name to retrieve a Cluster
39+ - The identifier of the Data Warehouse Cluster.
40+ - Mutually exclusive with I(environment).
4141 type: str
42- required: False
4342 aliases:
44- - name
43+ - id
4544 environment:
4645 description:
47- - The name of the Environment in which to find and describe the Data Warehouse Clusters.
48- - Required with name to retrieve a Cluster
46+ - The name or CRN of the Environment in which to find and describe Data Warehouse Clusters.
47+ - Mutually exclusive with I(cluster_id).
4948 type: str
50- required: False
5149 aliases:
5250 - env
5351extends_documentation_fragment:
5856EXAMPLES = r'''
5957# Note: These examples do not set authentication details.
6058
61- # List basic information about all Data Warehouse Clusters
59+ # List information about all Data Warehouse Clusters
6260- cloudera.cloud.dw_cluster_info:
6361
64- # Gather detailed information about a named Cluster
62+ # Gather information about all Data Warehouse Clusters within an Environment
6563- cloudera.cloud.dw_cluster_info:
66- name: example-cluster
6764 env: example-environment
65+
66+ # Gather information about an identified Cluster
67+ - cloudera.cloud.dw_cluster_info:
68+ id: env-xyzabc
6869'''
6970
7071RETURN = r'''
7172---
7273clusters:
7374 description: The information about the named Cluster or Clusters
74- type: list
7575 returned: always
76- elements: complex
76+ type: list
77+ elements: dict
7778 contains:
78- cluster:
79+ id:
80+ description: The cluster identifier.
81+ returned: always
82+ type: str
83+ environmentCrn:
84+ description: The CRN of the cluster's Environment
85+ returned: always
86+ type: str
87+ crn:
88+ description: The cluster's CRN.
89+ returned: always
90+ type: str
91+ creationDate:
92+ description: The creation timestamp of the cluster in UTC.
93+ returned: always
94+ type: str
95+ status:
96+ description: The status of the cluster
97+ returned: always
98+ type: str
99+ creator:
100+ description: The cluster creator details.
101+ returned: always
79102 type: dict
80103 contains:
81- name:
82- description: The name of the cluster.
83- returned: always
84- type: str
85- environmentCrn:
86- description: The crn of the cluster's environment.
87- returned: always
88- type: str
89104 crn:
90- description: The cluster's crn.
91- returned: always
105+ description: The Actor CRN.
92106 type: str
93- creationDate:
94- description: The creation time of the cluster in UTC.
95107 returned: always
108+ email:
109+ description: Email address (users).
96110 type: str
97- status:
98- description: The status of the Cluster
99- returned: always
111+ returned: when supported
112+ workloadUsername:
113+ description: Username (users).
100114 type: str
101- creator:
102- description: The CRN of the cluster creator.
103- returned: always
104- type: dict
105- contains:
106- crn:
107- type: str
108- description: Actor CRN
109- email:
110- type: str
111- description: Email address for users
112- workloadUsername:
113- type: str
114- description: Username for users
115- machineUsername:
116- type: str
117- description: Username for machine users
118- cloudPlatform:
119- description: The cloud platform of the environment that was used to create this cluster
120- returned: always
115+ returned: when supported
116+ machineUsername:
117+ description: Username (machine users).
121118 type: str
119+ returned: when supported
120+ cloudPlatform:
121+ description: The cloud platform of the environment that was used to create this cluster.
122+ returned: always
123+ type: str
122124sdk_out:
123125 description: Returns the captured CDP SDK log.
124126 returned: when supported
@@ -136,8 +138,8 @@ def __init__(self, module):
136138 super (DwClusterInfo , self ).__init__ (module )
137139
138140 # Set variables
139- self .id = self ._get_param ('name ' )
140- self .env = self ._get_param ('env ' )
141+ self .cluster_id = self ._get_param ('cluster_id ' )
142+ self .environment = self ._get_param ('environment ' )
141143
142144 # Initialize return values
143145 self .clusters = []
@@ -147,24 +149,27 @@ def __init__(self, module):
147149
148150 @CdpModule ._Decorators .process_debug
149151 def process (self ):
150- if self .id is not None :
151- cluster_single = self .cdpy .dw .describe_cluster (name = self .id )
152+ if self .cluster_id is not None :
153+ cluster_single = self .cdpy .dw .describe_cluster (self .cluster_id )
152154 if cluster_single is not None :
153155 self .clusters .append (cluster_single )
154- if self .env is not None :
155- env_crn = self .cdpy .environments .resolve_environment_crn (self .env )
156- if env_crn is not None :
157- self .clusters = self .cdpy .dw .gather_clusters ( env_crn )
156+ elif self .environment is not None :
157+ env_crn = self .cdpy .environments .resolve_environment_crn (self .environment )
158+ if env_crn :
159+ self .clusters = self .cdpy .dw .list_clusters ( env_crn = env_crn )
158160 else :
159- self .clusters = self .cdpy .dw .gather_clusters ()
161+ self .clusters = self .cdpy .dw .list_clusters ()
160162
161163
162164def main ():
163165 module = AnsibleModule (
164166 argument_spec = CdpModule .argument_spec (
165- id = dict (required = False , type = 'str' , aliases = ['name ' ]),
166- env = dict (required = False , type = 'str' , aliases = ['environment ' ])
167+ cluster_id = dict (type = 'str' , aliases = ['id ' ]),
168+ environment = dict (type = 'str' , aliases = ['env ' ])
167169 ),
170+ mutually_exclusive = [
171+ ['cluster_id' , 'environment' ]
172+ ],
168173 supports_check_mode = True
169174 )
170175
0 commit comments