@@ -330,6 +330,34 @@ def wait_for_active_cluster_service_commands(active_command):
330
330
print ('Exception waiting for active commands: {}' .format (e ))
331
331
332
332
333
+ def wait_for_active_service_commands (active_command , service_name ):
334
+ """
335
+ Wait until Cloudera Cluster Service finishes running active_command
336
+ :param active_command: Descriptive of what should be running - this just waits if any task is detected running
337
+ :return:
338
+ """
339
+ view = 'summary'
340
+ wait_status = '[*'
341
+ done = '0'
342
+
343
+ while done == '0' :
344
+ sys .stdout .write ('\r %s - Waiting: %s' % (active_command , wait_status ))
345
+ try :
346
+ api_response = services_api .list_active_commands (cluster_name , service_name , view = view )
347
+ if not api_response .items :
348
+ if debug == 'True' :
349
+ pprint (api_response )
350
+ done = '1'
351
+ sys .stdout .write (']\n ' )
352
+ break
353
+ else :
354
+ sys .stdout .flush ()
355
+ time .sleep (10 )
356
+ wait_status = wait_status + '*'
357
+ except ApiException as e :
358
+ print ('Exception waiting for active service commands: {}' .format (e ))
359
+
360
+
333
361
def wait_for_active_mgmt_commands (active_command ):
334
362
"""
335
363
Wait until Cloudera Manager finishes running mgmt active_command
@@ -820,7 +848,7 @@ def monitor_parcel(parcel_product, parcel_version, target_stage):
820
848
if parcel .state .errors :
821
849
raise Exception (str (parcel .state .errors ))
822
850
823
- sys .stdout .write ("\r Parcel %s progress %s: %s / %s" % (parcel_product , parcel .stage , parcel .state .progress ,
851
+ sys .stdout .write ("\r \t Parcel %s progress %s: %s / %s" % (parcel_product , parcel .stage , parcel .state .progress ,
824
852
parcel .state .total_progress ))
825
853
time .sleep (5 )
826
854
sys .stdout .flush ()
@@ -832,20 +860,21 @@ def monitor_parcel(parcel_product, parcel_version, target_stage):
832
860
if parcel .product == parcel_product :
833
861
parcel_version = parcel .version
834
862
835
- print ("Starting Parcel Download for %s - %s" % (parcel_product , parcel_version ))
863
+ print ("\t Starting Parcel Download for %s - %s" % (parcel_product , parcel_version ))
836
864
parcel_api .start_download_command (cluster_name , parcel_product , parcel_version )
837
865
target_stage = 'DOWNLOADED'
838
866
monitor_parcel (parcel_product , parcel_version , target_stage )
839
- print ("\n %s parcel %s version %s on cluster %s" % (target_stage , parcel_product , parcel_version , cluster_name ))
840
- print ("Starting Distribution for %s - %s" % (parcel_product , parcel_version ))
867
+ print ("\n \t %s parcel %s version %s on cluster %s" % (target_stage , parcel_product , parcel_version , cluster_name ))
868
+ print ("\t Starting Distribution for %s - %s" % (parcel_product , parcel_version ))
841
869
parcel_api .start_distribution_command (cluster_name , parcel_product , parcel_version )
842
870
target_stage = 'DISTRIBUTED'
843
871
monitor_parcel (parcel_product , parcel_version , target_stage )
844
- print ("\n %s parcel %s version %s on cluster %s" % (target_stage , parcel_product , parcel_version , cluster_name ))
845
- print ("Activating Parcel %s" % parcel_product )
872
+ print ("\n \t %s parcel %s version %s on cluster %s" % (target_stage , parcel_product , parcel_version , cluster_name ))
873
+ print ("\t Activating Parcel %s" % parcel_product )
846
874
parcel_api .activate_command (cluster_name , parcel_product , parcel_version )
847
875
target_stage = 'ACTIVATED'
848
876
monitor_parcel (parcel_product , parcel_version , target_stage )
877
+ print ('\n \n ' )
849
878
850
879
851
880
def get_parcel_status (parcel_product ):
@@ -1242,7 +1271,7 @@ def push_rcg_config(config):
1242
1271
namenode_java_heapsize , namenode_log_dir , dfs_namenode_servicerpc_address ]
1243
1272
for config in nn_config_list :
1244
1273
push_rcg_config (config )
1245
- create_role (rcg , rcg_roletype , service , snn_host_id , nn_hostname , 1 )
1274
+ create_role (rcg , rcg_roletype , service , nn_host_id , nn_hostname , 1 )
1246
1275
1247
1276
if rcg == 'HDFS-DATANODE-BASE' :
1248
1277
print ('-->Updating RCG: %s' % rcg )
@@ -1296,7 +1325,7 @@ def push_rcg_config(config):
1296
1325
failover_controller_log_dir = [cm_client .ApiConfig (name = 'failover_controller_log_dir' ,
1297
1326
value = LOG_DIR + '/hadoop-hdfs' )]
1298
1327
push_rcg_config (failover_controller_log_dir )
1299
- create_role (rcg , rcg_roletype , service , cm_host_id , cm_hostname , 1 )
1328
+ # create_role(rcg, rcg_roletype, service, snn_host_id, snn_hostname , 1)
1300
1329
1301
1330
if rcg == 'HDFS-HTTPFS-BASE' :
1302
1331
print ('-->Updating RCG: %s' % rcg )
@@ -1326,7 +1355,10 @@ def push_rcg_config(config):
1326
1355
rcg_roletype = 'JOURNALNODE'
1327
1356
dfs_journalnode_edits_dir = [cm_client .ApiConfig (name = 'dfs_journalnode_edits_dir' ,
1328
1357
value = '/data/dfs/jn' )]
1358
+ journalnode_log_dir = [cm_client .ApiConfig (name = 'journalnode_log_dir' ,
1359
+ value = LOG_DIR + '/hadoop-hdfs' )]
1329
1360
push_rcg_config (dfs_journalnode_edits_dir )
1361
+ push_rcg_config (journalnode_log_dir )
1330
1362
create_role (rcg , rcg_roletype , service , nn_host_id , nn_hostname , 1 )
1331
1363
create_role (rcg , rcg_roletype , service , snn_host_id , snn_hostname , 2 )
1332
1364
create_role (rcg , rcg_roletype , service , cm_host_id , cm_hostname , 3 )
@@ -1954,7 +1986,7 @@ def mgmt_role_commands(action):
1954
1986
pprint (api_response )
1955
1987
except ApiException as e :
1956
1988
print ('Exception running MgmtRoleCommandsResourceApi->restart_command {}\n ' .format (e ))
1957
- active_command = action + ' ' + role
1989
+ active_command = ' \t ' + action + ' ' + role
1958
1990
wait_for_active_mgmt_commands (active_command )
1959
1991
1960
1992
if action == 'start_command' :
@@ -1967,7 +1999,7 @@ def mgmt_role_commands(action):
1967
1999
pprint (api_response )
1968
2000
except ApiException as e :
1969
2001
print ('Exception running MgmtRoleCommandsResourceApi->start_command {}\n ' .format (e ))
1970
- active_command = action + ' ' + role
2002
+ active_command = ' \t ' + action + ' ' + role
1971
2003
wait_for_active_mgmt_commands (active_command )
1972
2004
1973
2005
if action == 'stop_command' :
@@ -1980,7 +2012,7 @@ def mgmt_role_commands(action):
1980
2012
pprint (api_response )
1981
2013
except ApiException as e :
1982
2014
print ('Exception running MgmtRoleCommandsResourceApi->stop_command {}\n ' .format (e ))
1983
- active_command = action + ' ' + role
2015
+ active_command = ' \t ' + action + ' ' + role
1984
2016
wait_for_active_mgmt_commands (active_command )
1985
2017
1986
2018
if action == 'jmap_dump' :
@@ -1993,7 +2025,7 @@ def mgmt_role_commands(action):
1993
2025
pprint (api_response )
1994
2026
except ApiException as e :
1995
2027
print ('Exception running MgmtRoleCommandsResourceApi->jmap_dump {}\n ' .format (e ))
1996
- active_command = action + ' ' + role
2028
+ active_command = ' \t ' + action + ' ' + role
1997
2029
wait_for_active_mgmt_commands (active_command )
1998
2030
1999
2031
if action == 'jmap_histo' :
@@ -2006,7 +2038,7 @@ def mgmt_role_commands(action):
2006
2038
pprint (api_response )
2007
2039
except ApiException as e :
2008
2040
print ('Exception running MgmtRoleCommandsResourceApi->jmap_history {}\n ' .format (e ))
2009
- active_command = action + ' ' + role
2041
+ active_command = ' \t ' + action + ' ' + role
2010
2042
wait_for_active_mgmt_commands (active_command )
2011
2043
2012
2044
if action == 'jstack' :
@@ -2019,7 +2051,7 @@ def mgmt_role_commands(action):
2019
2051
pprint (api_response )
2020
2052
except ApiException as e :
2021
2053
print ('Exception running MgmtRoleCommandsResourceApi->jstack {}\n ' .format (e ))
2022
- active_command = action + ' ' + role
2054
+ active_command = ' \t ' + action + ' ' + role
2023
2055
wait_for_active_mgmt_commands (active_command )
2024
2056
2025
2057
if action == 'lsof' :
@@ -2032,7 +2064,7 @@ def mgmt_role_commands(action):
2032
2064
pprint (api_response )
2033
2065
except ApiException as e :
2034
2066
print ('Exception running MgmtRoleCommandsResourceApi->lsof {}\n ' .format (e ))
2035
- active_command = action + ' ' + role
2067
+ active_command = ' \t ' + action + ' ' + role
2036
2068
wait_for_active_mgmt_commands (active_command )
2037
2069
2038
2070
@@ -2094,7 +2126,7 @@ def mgmt_service(action):
2094
2126
pprint (api_response )
2095
2127
except ApiException as e :
2096
2128
print ('Exception calling MgmtServiceResourceApi -> start_command {}\n ' .format (e ))
2097
- active_command = 'MGMT ' + action
2129
+ active_command = '\t MGMT ' + action
2098
2130
wait_for_active_mgmt_commands (active_command )
2099
2131
2100
2132
if action == 'restart_command' :
@@ -2104,7 +2136,7 @@ def mgmt_service(action):
2104
2136
pprint (api_response )
2105
2137
except ApiException as e :
2106
2138
print ('Exception calling MgmtServiceResourceApi -> restart_command {}\n ' .format (e ))
2107
- active_command = 'MGMT ' + action
2139
+ active_command = '\t MGMT ' + action
2108
2140
wait_for_active_mgmt_commands (active_command )
2109
2141
2110
2142
if action == 'stop_command' :
@@ -2114,7 +2146,7 @@ def mgmt_service(action):
2114
2146
pprint (api_response )
2115
2147
except ApiException as e :
2116
2148
print ('Exception calling MgmtServiceResourceApi -> stop_command {}\n ' .format (e ))
2117
- active_command = 'MGMT ' + action
2149
+ active_command = '\t MGMT ' + action
2118
2150
wait_for_active_mgmt_commands (active_command )
2119
2151
2120
2152
if action == 'auto_assign_roles' :
@@ -2124,7 +2156,7 @@ def mgmt_service(action):
2124
2156
pprint (api_response )
2125
2157
except ApiException as e :
2126
2158
print ('Exception calling MgmtServiceResourceApi -> auto_assign_roles {}\n ' .format (e ))
2127
- active_command = 'MGMT ' + action
2159
+ active_command = '\t MGMT ' + action
2128
2160
wait_for_active_mgmt_commands (active_command )
2129
2161
2130
2162
if action == 'auto_configure_roles' :
@@ -2134,7 +2166,7 @@ def mgmt_service(action):
2134
2166
pprint (api_response )
2135
2167
except ApiException as e :
2136
2168
print ('Exception calling MgmtServiceResourceApi -> auto_configure_roles {}\n ' .format (e ))
2137
- active_command = 'MGMT ' + action
2169
+ active_command = '\t MGMT ' + action
2138
2170
wait_for_active_mgmt_commands (active_command )
2139
2171
2140
2172
if action == 'delete_cms' :
@@ -2144,7 +2176,7 @@ def mgmt_service(action):
2144
2176
pprint (api_response )
2145
2177
except ApiException as e :
2146
2178
print ('Exception calling MgmtServiceResourceApi -> delete_cms {}\n ' .format (e ))
2147
- active_command = 'MGMT ' + action
2179
+ active_command = '\t MGMT ' + action
2148
2180
wait_for_active_mgmt_commands (active_command )
2149
2181
2150
2182
if action == 'enter_maintenance_mode' :
@@ -2154,7 +2186,7 @@ def mgmt_service(action):
2154
2186
pprint (api_response )
2155
2187
except ApiException as e :
2156
2188
print ('Exception calling MgmtServiceResourceApi -> enter_maintenance_mode {}\n ' .format (e ))
2157
- active_command = 'MGMT ' + action
2189
+ active_command = '\t MGMT ' + action
2158
2190
wait_for_active_mgmt_commands (active_command )
2159
2191
2160
2192
if action == 'exit_maintenance_mode' :
@@ -2164,7 +2196,7 @@ def mgmt_service(action):
2164
2196
pprint (api_response )
2165
2197
except ApiException as e :
2166
2198
print ('Exception calling MgmtServiceResourceApi -> exit_maintenance_mode {}\n ' .format (e ))
2167
- active_command = 'MGMT ' + action
2199
+ active_command = '\t MGMT ' + action
2168
2200
wait_for_active_mgmt_commands (active_command )
2169
2201
2170
2202
if action == 'auto_configure_roles' :
@@ -2174,7 +2206,7 @@ def mgmt_service(action):
2174
2206
pprint (api_response )
2175
2207
except ApiException as e :
2176
2208
print ('Exception calling MgmtServiceResourceApi -> auto_configure {}\n ' .format (e ))
2177
- active_command = 'MGMT ' + action
2209
+ active_command = '\t MGMT ' + action
2178
2210
wait_for_active_mgmt_commands (active_command )
2179
2211
2180
2212
@@ -2379,10 +2411,12 @@ def update_license():
2379
2411
"""
2380
2412
try :
2381
2413
with open (license_file ) as l :
2382
- body = l .read ()
2414
+ license_data = l .read ()
2415
+ body = license_file
2383
2416
try :
2384
2417
api_response = cloudera_manager_api .update_license (body = body )
2385
2418
if debug == 'True' :
2419
+ print ('License File Content: \n %s' % license_data )
2386
2420
pprint (api_response )
2387
2421
except ApiException as e :
2388
2422
print ('Exception calling Cloudera Manager Resource API -> update_license {}' .format (e ))
@@ -2392,15 +2426,16 @@ def update_license():
2392
2426
begin_trial ()
2393
2427
2394
2428
2395
- def hdfs_enable_nn_ha (nn_hostname , snn_hostname , snn_host_id ):
2429
+ def hdfs_enable_nn_ha (snn_host_id ):
2396
2430
"""
2397
2431
Enable High Availability (HA) with Automatic Failover for an HDFS NameNode.
2398
2432
:return:
2399
2433
"""
2400
- body = cm_client .ApiEnableNnHaArguments (active_nn_name = nn_hostname , standby_nn_name = snn_hostname ,
2401
- standby_nn_host_id = snn_host_id )
2434
+ body = cm_client .ApiEnableNnHaArguments (active_nn_name = 'HDFS-NAMENODE-1' ,
2435
+ standby_nn_host_id = snn_host_id ,
2436
+ nameservice = 'HDFS-HA-%s' % cluster_name )
2402
2437
try :
2403
- api_response = services_api .hdfs_enable_nn_ha_command (cluster_name , 'HDFS' , body = body )
2438
+ api_response = services_api .hdfs_enable_nn_ha_command (cluster_name = cluster_name , service_name = 'HDFS' , body = body )
2404
2439
if debug == 'True' :
2405
2440
pprint (api_response )
2406
2441
except ApiException as e :
@@ -2512,11 +2547,10 @@ def build_cloudera_cluster():
2512
2547
install_success = 'False'
2513
2548
while install_success == 'False' :
2514
2549
install_hosts ()
2515
- active_command = 'Host Agents Installing'
2516
- wait_for_active_cluster_commands (active_command )
2550
+ wait_for_active_cluster_commands ('Host Agents Installing' )
2517
2551
print ('->Host Installation Complete' )
2518
2552
add_hosts_to_cluster (cluster_host_list )
2519
- active_command = 'Hosts Adding to Cluster ' + cluster_name
2553
+ active_command = '\t Hosts Adding to Cluster ' + cluster_name
2520
2554
wait_for_active_cluster_commands (active_command )
2521
2555
if host_install_failure == 'True' :
2522
2556
print ('->Host SCM Agent Install Failure Detected, trying again' )
@@ -2568,10 +2602,15 @@ def build_cloudera_cluster():
2568
2602
api_response = clusters_api .first_run (cluster_name )
2569
2603
if debug == 'True' :
2570
2604
pprint (api_response )
2605
+ active_command = '\t First Run on ' + cluster_name
2606
+ wait_for_active_cluster_commands (active_command )
2607
+ time .sleep (5 )
2571
2608
except ApiException as e :
2572
2609
print ('Exception calling ClustersResourceApi -> first_run {}\n ' .format (e ))
2573
- active_command = 'First Run on ' + cluster_name
2574
- wait_for_active_cluster_commands (active_command )
2610
+ sys .exit ()
2611
+ print ('->Enabling HDFS HA' )
2612
+ hdfs_enable_nn_ha (snn_host_id )
2613
+ wait_for_active_service_commands ('\t Enable HDFS HA' , 'HDFS' )
2575
2614
if secure_cluster == 'True' :
2576
2615
pass
2577
2616
else :
@@ -2586,10 +2625,10 @@ def enable_kerberos():
2586
2625
:return:
2587
2626
"""
2588
2627
config_mgmt_for_kerberos ()
2589
- wait_for_active_mgmt_commands ('Deploying MGMT Kerberos Configuration' )
2628
+ wait_for_active_mgmt_commands ('\t Deploying MGMT Kerberos Configuration' )
2590
2629
print ('-->Import KDC Admin Credentials' )
2591
2630
import_admin_credentials ()
2592
- wait_for_active_cluster_commands ('Importing KDC Account Management Credentials' )
2631
+ wait_for_active_cluster_commands ('\t Importing KDC Account Management Credentials' )
2593
2632
# Set Service Configurations
2594
2633
# SOLR
2595
2634
solr_security_authentication = [cm_client .ApiConfig (name = 'solr_security_authentication' , value = 'kerberos' )]
@@ -2620,21 +2659,21 @@ def enable_kerberos():
2620
2659
update_service_config (service_name = 'ZOOKEEPER' , api_config_items = quorum_auth_enable_sasl )
2621
2660
print ('-->Stop Cluster Services' )
2622
2661
cluster_action ('stop_command' )
2623
- wait_for_active_cluster_service_commands ('Stopping Cluster Services' )
2662
+ wait_for_active_cluster_service_commands ('\t Stopping Cluster Services' )
2624
2663
mgmt_service ('stop_command' )
2625
2664
print ('-->Configure Cluster for Kerberos' )
2626
2665
configure_for_kerberos ()
2627
- wait_for_active_cluster_service_commands ('Configuring for Kerberos' )
2666
+ wait_for_active_cluster_service_commands ('\t Configuring for Kerberos' )
2628
2667
print ('-->Deploy Cluster Kerberos Configuration' )
2629
2668
cluster_action ('deploy_cluster_client_config' )
2630
- wait_for_active_cluster_service_commands ('Deploying Cluster Kerberos Client Config' )
2669
+ wait_for_active_cluster_service_commands ('\t Deploying Cluster Kerberos Client Config' )
2631
2670
print ('-->Start Cluster Services' )
2632
2671
cluster_action ('start_command' )
2633
- wait_for_active_cluster_service_commands ('Starting Cluster Services' )
2672
+ wait_for_active_cluster_service_commands ('\t Starting Cluster Services' )
2634
2673
mgmt_service ('start_command' )
2635
2674
print ('-->Deploy Client Configuration' )
2636
2675
cluster_action ('deploy_client_config' )
2637
- wait_for_active_cluster_commands ('Deploy Cluster Client Config' )
2676
+ wait_for_active_cluster_commands ('\t Deploy Cluster Client Config' )
2638
2677
if debug == 'True' :
2639
2678
print ('->Listing Kerberos Principals' )
2640
2679
get_kerberos_principals ()
@@ -2658,7 +2697,7 @@ def enable_kerberos():
2658
2697
build_api_endpoints (admin_user_name , admin_password )
2659
2698
print ('-->Stop Cluster Services' )
2660
2699
cluster_action ('stop_command' )
2661
- wait_for_active_cluster_service_commands ('Stopping Cluster Services' )
2700
+ wait_for_active_cluster_service_commands ('\t Stopping Cluster Services' )
2662
2701
delete_cluster ()
2663
2702
print ('%s Delete issued' % cluster_name )
2664
2703
exit (0 )
@@ -2714,7 +2753,6 @@ def enable_kerberos():
2714
2753
pprint (cluster_host_list )
2715
2754
print ('->Full Deployment Follows' )
2716
2755
get_deployment_full ()
2717
-
2718
2756
else :
2719
2757
print ('Cluster Check returned null: %s' % cluster_exists )
2720
2758
else :
0 commit comments