22
22
23
23
import os
24
24
import tarfile
25
- import StringIO
25
+ from io import StringIO
26
26
import logging
27
27
import traceback
28
28
import time
32
32
import spur
33
33
from pywebhdfs .webhdfs import PyWebHdfsClient
34
34
35
- from cm_api .api_client import ApiResource
36
-
37
-
38
- def connect_cm (cm_api , cm_username , cm_password ):
39
- api = ApiResource (
40
- cm_api ,
41
- version = 6 ,
42
- username = cm_username ,
43
- password = cm_password )
44
- return api
45
-
46
-
47
35
def get_nameservice (cm_host , cluster_name , service_name , user_name = 'admin' , password = 'admin' ):
48
36
request_url = 'http://%s:7180/api/v11/clusters/%s/services/%s/nameservices' % (cm_host ,
49
37
cluster_name ,
@@ -66,7 +54,7 @@ def update_hadoop_env(env):
66
54
tmp_env = dict (env )
67
55
logging .debug ('Updating environment descriptor' )
68
56
if env ['hadoop_distro' ] == 'CDH' :
69
- fill_hadoop_env_cdh ( tmp_env )
57
+ logging . error ( 'CDH is not a supported hadoop distribution' )
70
58
elif env ['hadoop_distro' ] == 'HDP' :
71
59
fill_hadoop_env_hdp (tmp_env )
72
60
else :
@@ -184,105 +172,6 @@ def fill_hadoop_env_hdp(env):
184
172
env ['hive_server' ] = '%s' % component_host (component_detail )
185
173
env ['hive_port' ] = '10001'
186
174
187
- def fill_hadoop_env_cdh (env ):
188
- # pylint: disable=E1103
189
- api = connect_cm (
190
- env ['hadoop_manager_host' ],
191
- env ['hadoop_manager_username' ],
192
- env ['hadoop_manager_password' ])
193
-
194
- for cluster_detail in api .get_all_clusters ():
195
- cluster_name = cluster_detail .name
196
- break
197
-
198
- logging .debug ('getting %s' , cluster_name )
199
- env ['cm_status_links' ] = {}
200
- env .pop ('yarn_node_managers' , None )
201
- env .pop ('yarn_resource_manager_host' , None )
202
- env .pop ('zookeeper_quorum' , None )
203
-
204
- cluster = api .get_cluster (cluster_name )
205
- for service in cluster .get_all_services ():
206
- env ['cm_status_links' ]['%s' % service .name ] = service .serviceUrl
207
- if service .type == "HDFS" :
208
- nameservice = get_nameservice (env ['hadoop_manager_host' ], cluster_name ,
209
- service .name ,
210
- user_name = env ['hadoop_manager_username' ],
211
- password = env ['hadoop_manager_password' ])
212
- if nameservice :
213
- env ['name_node' ] = 'hdfs://%s' % nameservice
214
- for role in service .get_all_roles ():
215
- if not nameservice and role .type == "NAMENODE" :
216
- env ['name_node' ] = 'hdfs://%s:8020' % api .get_host (role .hostRef .hostId ).hostname
217
- if role .type == "HTTPFS" :
218
- env ['webhdfs_host' ] = '%s' % api .get_host (role .hostRef .hostId ).hostname
219
- env ['webhdfs_port' ] = '14000'
220
- elif service .type == "YARN" :
221
- for role in service .get_all_roles ():
222
- if role .type == "RESOURCEMANAGER" :
223
- if 'yarn_resource_manager_host' in env :
224
- rm_instance = '_backup'
225
- else :
226
- rm_instance = ''
227
- env ['yarn_resource_manager_host%s' % rm_instance ] = '%s' % api .get_host (role .hostRef .hostId ).hostname
228
- env ['yarn_resource_manager_port%s' % rm_instance ] = '8088'
229
- env ['yarn_resource_manager_mr_port%s' % rm_instance ] = '8032'
230
- if role .type == "NODEMANAGER" :
231
- if 'yarn_node_managers' in env :
232
- env ['yarn_node_managers' ] = '%s,%s' % (env ['yarn_node_managers' ], api .get_host (role .hostRef .hostId ).hostname )
233
- else :
234
- env ['yarn_node_managers' ] = '%s' % api .get_host (
235
- role .hostRef .hostId ).hostname
236
- elif service .type == "MAPREDUCE" :
237
- for role in service .get_all_roles ():
238
- if role .type == "JOBTRACKER" :
239
- env ['job_tracker' ] = '%s:8021' % api .get_host (role .hostRef .hostId ).hostname
240
- break
241
- elif service .type == "ZOOKEEPER" :
242
- for role in service .get_all_roles ():
243
- if role .type == "SERVER" :
244
- if 'zookeeper_quorum' in env :
245
- env ['zookeeper_quorum' ] += ',%s' % api .get_host (role .hostRef .hostId ).hostname
246
- else :
247
- env ['zookeeper_quorum' ] = '%s' % api .get_host (role .hostRef .hostId ).hostname
248
- env ['zookeeper_port' ] = '2181'
249
- elif service .type == "HBASE" :
250
- for role in service .get_all_roles ():
251
- if role .type == "HBASERESTSERVER" :
252
- env ['hbase_rest_server' ] = '%s' % api .get_host (role .hostRef .hostId ).hostname
253
- env ['hbase_rest_port' ] = '20550'
254
- elif role .type == "HBASETHRIFTSERVER" :
255
- env ['hbase_thrift_server' ] = '%s' % api .get_host (role .hostRef .hostId ).hostname
256
- elif service .type == "OOZIE" :
257
- for role in service .get_all_roles ():
258
- if role .type == "OOZIE_SERVER" :
259
- env ['oozie_uri' ] = 'http://%s:11000/oozie' % api .get_host (role .hostRef .hostId ).hostname
260
- break
261
- elif service .type == "HIVE" :
262
- for role in service .get_all_roles ():
263
- if role .type == "HIVESERVER2" :
264
- env ['hive_server' ] = '%s' % api .get_host (role .hostRef .hostId ).hostname
265
- env ['hive_port' ] = '10000'
266
- break
267
- elif service .type == "IMPALA" :
268
- for role in service .get_all_roles ():
269
- if role .type == "IMPALAD" :
270
- env ['impala_host' ] = '%s' % api .get_host (role .hostRef .hostId ).hostname
271
- env ['impala_port' ] = '21050'
272
- break
273
- elif service .type == "KUDU" :
274
- for role in service .get_all_roles ():
275
- if role .type == "KUDU_MASTER" :
276
- env ['kudu_host' ] = '%s' % api .get_host (role .hostRef .hostId ).hostname
277
- env ['kudu_port' ] = '7051'
278
- break
279
- elif service .type == "HUE" :
280
- for role in service .get_all_roles ():
281
- if role .type == "HUE_SERVER" :
282
- env ['hue_host' ] = '%s' % api .get_host (role .hostRef .hostId ).hostname
283
- env ['hue_port' ] = '8888'
284
- break
285
-
286
175
def tree (archive_filepath ):
287
176
file_handle = file (archive_filepath , 'rb' )
288
177
tar_file = tarfile .open (None , 'r' , file_handle )
@@ -299,7 +188,6 @@ def tree(archive_filepath):
299
188
300
189
return root
301
190
302
-
303
191
def canonicalize (path ):
304
192
path = path .replace ('\\ ' , '/' )
305
193
path = path .replace ('//' , '/' )
0 commit comments